From faa650125c10a2bab643450492813701d58362f2 Mon Sep 17 00:00:00 2001 From: joerg Date: Fri, 6 Nov 2015 20:33:21 +0000 Subject: Fix a number of cases of plainly invalid C and portability issues. --- lang/ucblogo/distinfo | 11 ++++++----- lang/ucblogo/patches/patch-graphics.c | 18 ++++++++--------- lang/ucblogo/patches/patch-intern.c | 18 +++++++++++++++++ lang/ucblogo/patches/patch-print.c | 15 ++++++++++++--- lang/ucblogo/patches/patch-wrksp.c | 35 +++++++++++++++++++++++++++++++--- lang/ucblogo/patches/patch-xgraphics.c | 17 +++++++++++++---- 6 files changed, 90 insertions(+), 24 deletions(-) create mode 100644 lang/ucblogo/patches/patch-intern.c (limited to 'lang') diff --git a/lang/ucblogo/distinfo b/lang/ucblogo/distinfo index a70fdb4ab14..ff7f5710079 100644 --- a/lang/ucblogo/distinfo +++ b/lang/ucblogo/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.10 2015/11/03 22:50:45 agc Exp $ +$NetBSD: distinfo,v 1.11 2015/11/06 20:33:21 joerg Exp $ SHA1 (ucblogo-6.0/ucblogo.tar.gz) = ad62c689c264b1aeb7bd58dd9c08ca602bade8f1 RMD160 (ucblogo-6.0/ucblogo.tar.gz) = 7cd9ec8eeff00fb3440f5036d57a9b29383ab310 @@ -7,10 +7,11 @@ Size (ucblogo-6.0/ucblogo.tar.gz) = 6694879 bytes SHA1 (patch-aa) = 54cefcc2821247706675cf2466ef4f1452c9968f SHA1 (patch-configure) = 329c31aed56a37b53383a3e7421fd9f429468f6c SHA1 (patch-docs_makefile) = 1c0efb2ee37dc535b3aabbf0a7ce02e40bc6ac52 -SHA1 (patch-graphics.c) = 00b99bfcf8785e66634786026950ac95a7872bd0 +SHA1 (patch-graphics.c) = 232ed36d7e1dd058ada493040acd467c96257dd3 +SHA1 (patch-intern.c) = 2ed10c027fbea3410585838629477a0e085c1e83 SHA1 (patch-makehelp.c) = e236bbf271337d6f45474c071f2ea26f14b09744 -SHA1 (patch-print.c) = 48f6e453e260770a2a03b421c5a99dae35d7d41f +SHA1 (patch-print.c) = d988911dddb5a27228366b607a4acd442facef42 SHA1 (patch-term.c) = 621b4a5a02e0e6c150d8655957f945a81177cb08 -SHA1 (patch-wrksp.c) = a0c52544a4a54289c08e3300474655915a4b9e5d -SHA1 (patch-xgraphics.c) = d1f58d85260d650a37f0b3bf12097656f352078c +SHA1 (patch-wrksp.c) = cca5b7192d359355cbf14d0f44047ff5bc77cba4 +SHA1 (patch-xgraphics.c) = e12f2ff10f990b4d9d00041db970de87ec41684d SHA1 (patch-xgraphics.h) = 3b4c6a74cd328241dd2ea8c601879bd24911570d diff --git a/lang/ucblogo/patches/patch-graphics.c b/lang/ucblogo/patches/patch-graphics.c index 98f4dc38598..2b24b3f6023 100644 --- a/lang/ucblogo/patches/patch-graphics.c +++ b/lang/ucblogo/patches/patch-graphics.c @@ -1,4 +1,4 @@ -$NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ +$NetBSD: patch-graphics.c,v 1.3 2015/11/06 20:33:21 joerg Exp $ --- graphics.c.orig 2008-09-03 17:58:13.000000000 +0000 +++ graphics.c @@ -7,7 +7,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ #endif - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); prepare_to_draw_turtle; save_pen(&saved_pen); plain_xor_pen(); @@ -16,7 +16,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ void right(FLONUM a) { - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); draw_turtle(); turtle_heading += a; turtle_heading = pfmod(turtle_heading,360.0); @@ -25,7 +25,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ internal_hideturtle(); // #endif - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); draw_turtle(); forward_helper(d); draw_turtle(); @@ -43,7 +43,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ void internal_hideturtle() { if(!graphics_setup) graphics_setup++; - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); if (turtle_shown) { draw_turtle(); turtle_shown = FALSE; @@ -70,7 +70,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ clearing_screen++; #endif - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); clear_screen; #if defined(x_window) && !HAVE_WX clearing_screen==0; @@ -79,7 +79,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ void setpos_bynumber(FLONUM target_x, FLONUM target_y) { if (NOT_THROWING) { - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); draw_turtle(); move_to(g_round(screen_x_coord), g_round(screen_y_coord)); setpos_commonpart(target_x, target_y); @@ -88,7 +88,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ if (NOT_THROWING) { internal_hideturtle(); - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); draw_turtle(); move_to(g_round(screen_x_coord), g_round(screen_y_coord)); target_x = ((xnode == NIL) ? @@ -205,7 +205,7 @@ $NetBSD: patch-graphics.c,v 1.2 2015/10/11 07:02:39 ryoon Exp $ } - prepare_to_draw; -+ prepare_to_draw2(UNBOUND); ++ prepare_to_draw(UNBOUND); if(!graphics_setup){ done_drawing; return; diff --git a/lang/ucblogo/patches/patch-intern.c b/lang/ucblogo/patches/patch-intern.c new file mode 100644 index 00000000000..999600c44ec --- /dev/null +++ b/lang/ucblogo/patches/patch-intern.c @@ -0,0 +1,18 @@ +$NetBSD: patch-intern.c,v 1.1 2015/11/06 20:33:21 joerg Exp $ + +--- intern.c.orig 2015-11-06 16:15:17.000000000 +0000 ++++ intern.c +@@ -39,11 +39,11 @@ FIXNUM hash(char *s, int len) { + /* and Ullman's book, Compilers: Principles, Techniques, and */ + /* Tools; figure 7.35. */ + +- unsigned FIXNUM h = 0, g; ++ unsigned long FIXNUM h = 0, g; + + while (--len >= 0) { + h = (h << 4) + (FIXNUM)(*s++); +- g = h & (0xf << (WORDSIZE-4)); ++ g = h & (0xfUL << (WORDSIZE-4)); + if (g != 0) { + h ^= g ^ (g >> (WORDSIZE-8)); + } diff --git a/lang/ucblogo/patches/patch-print.c b/lang/ucblogo/patches/patch-print.c index 4d3cf4ff865..b599aa1d0b2 100644 --- a/lang/ucblogo/patches/patch-print.c +++ b/lang/ucblogo/patches/patch-print.c @@ -1,8 +1,17 @@ -$NetBSD: patch-print.c,v 1.1 2013/07/18 12:05:09 joerg Exp $ +$NetBSD: patch-print.c,v 1.2 2015/11/06 20:33:21 joerg Exp $ ---- print.c.orig 2013-07-17 14:26:15.000000000 +0000 +--- print.c.orig 2008-03-01 01:04:41.000000000 +0000 +++ print.c -@@ -229,7 +229,7 @@ void real_print_node(FILE *strm, NODE *n +@@ -254,7 +254,7 @@ void real_print_node(FILE *strm, NODE *n + } else if ((unsigned int)nd < 200) { /* for debugging */ + char num[] = "{small} "; + +- sprintf(&num[7],"%d",nd); ++ snprintf(&num[7], sizeof(num) - 7,"%u",(unsigned int)nd); + ndprintf(strm,num); + } else if ((ndty = nodetype(nd)) & NT_PRIM) { + ndprintf(strm, "PRIM"); +@@ -281,7 +281,7 @@ void real_print_node(FILE *strm, NODE *n if (print_backslashes && (getarrorg(nd) != 1)) { char org[] = "@ "; diff --git a/lang/ucblogo/patches/patch-wrksp.c b/lang/ucblogo/patches/patch-wrksp.c index fe412128826..9eafaceffff 100644 --- a/lang/ucblogo/patches/patch-wrksp.c +++ b/lang/ucblogo/patches/patch-wrksp.c @@ -1,8 +1,8 @@ -$NetBSD: patch-wrksp.c,v 1.1 2013/07/18 12:05:09 joerg Exp $ +$NetBSD: patch-wrksp.c,v 1.2 2015/11/06 20:33:21 joerg Exp $ ---- wrksp.c.orig 2013-07-17 14:30:28.000000000 +0000 +--- wrksp.c.orig 2008-08-23 19:51:14.000000000 +0000 +++ wrksp.c -@@ -30,6 +30,7 @@ +@@ -38,6 +38,7 @@ int wxEditFile(char *); #ifdef HAVE_UNISTD_H #include #endif @@ -10,3 +10,32 @@ $NetBSD: patch-wrksp.c,v 1.1 2013/07/18 12:05:09 joerg Exp $ #ifdef ibm #include "process.h" +@@ -55,6 +56,8 @@ int wxEditFile(char *); + #endif + #endif + ++#include ++ + char *editor, *editorname, *tempdir; + int to_pending = 0; + +@@ -293,7 +296,7 @@ char *strncasestr(char *big, char *littl + FIXNUM i; + + while (*big != '\0') { +- while ((pc = *big++) != '\0' && tolower(pc) != tolower(*little)) ; ++ while ((pc = *big++) != '\0' && tolower((unsigned char)pc) != tolower((unsigned char)*little)) ; + if (pc == '\0') return NULL; + p = big; q = little+1; i = len; + while (--i > 0 && (qc = *q++) != '\0') { +@@ -1713,8 +1716,8 @@ NODE *cpdf_newname(NODE *name, NODE*titl + p1 = titlestr+strcspn(titlestr, " \t"); + p1 = p1+strspn(p1, " \t"); + p2 = p1+strcspn(p1, " \t"); +- sprintf(buf, "%.*s%.*s%s", +- p1-titlestr, titlestr, getstrlen(nname), namestr, p2); ++ snprintf(buf, sizeof(buf), "%.*s%.*s%s", ++ (int)(p1-titlestr), titlestr, (int)getstrlen(nname), namestr, p2); + return make_strnode(buf, NULL, strlen(buf), STRING, strcpy); + } + diff --git a/lang/ucblogo/patches/patch-xgraphics.c b/lang/ucblogo/patches/patch-xgraphics.c index 2a4da3f76aa..41673c09ca0 100644 --- a/lang/ucblogo/patches/patch-xgraphics.c +++ b/lang/ucblogo/patches/patch-xgraphics.c @@ -1,8 +1,17 @@ -$NetBSD: patch-xgraphics.c,v 1.1 2012/11/01 19:55:37 joerg Exp $ +$NetBSD: patch-xgraphics.c,v 1.2 2015/11/06 20:33:21 joerg Exp $ ---- xgraphics.c.orig 2012-10-30 22:05:56.000000000 +0000 +--- xgraphics.c.orig 2007-12-05 21:00:23.000000000 +0000 +++ xgraphics.c -@@ -289,7 +289,7 @@ void placate_x() +@@ -314,7 +314,7 @@ void check_X11_stop() { + + int get_button() + { +- checkX; ++ checkX2(-1); + + placate_x(); + +@@ -323,7 +323,7 @@ int get_button() int get_mouse_x() { @@ -11,7 +20,7 @@ $NetBSD: patch-xgraphics.c,v 1.1 2012/11/01 19:55:37 joerg Exp $ placate_x(); -@@ -299,7 +299,7 @@ int get_mouse_x() +@@ -333,7 +333,7 @@ int get_mouse_x() int get_mouse_y() { -- cgit v1.2.3