]> granicus.if.org Git - nethack/commitdiff
lev_comp update for older Unix system
authorPatR <rankin@nethack.org>
Wed, 20 Jan 2016 00:27:39 +0000 (16:27 -0800)
committerPatR <rankin@nethack.org>
Wed, 20 Jan 2016 00:27:39 +0000 (16:27 -0800)
Increase the lex paramaters in lev_comp.l and replace use of snprintf
with sprintf in lev_comp.y and lev_main.c.

Also some reformatting for lev_comp.y, but I gave up pretty quickly:
some early tab replacement and adjusting of the spacing for casts.

sys/share/dgn_lex.c
sys/share/dgn_yacc.c
sys/share/lev_lex.c
sys/share/lev_yacc.c
util/lev_comp.l
util/lev_comp.y
util/lev_main.c

index 6679b4d250a4a4c71279f63818da830beb46dec8..22ebd699631be534f1a337fb18e5d6ec126b51d2 100644 (file)
@@ -501,7 +501,7 @@ int yy_flex_debug = 0;
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
-/* NetHack 3.6  dgn_comp.l     $NHDT-Date: 1449615114 2015/12/08 22:51:54 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.17 $ */
+/* NetHack 3.6  dgn_comp.l     $NHDT-Date: 1453249302 2016/01/20 00:21:42 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.18 $ */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /*     Copyright (c) 1990 by M. Stephenson          */
 /* NetHack may be freely redistributed.  See license for details. */
index 9339fd578de5920924730dc4182ba1b7e93459a8..88cb004d5523e8e66b4a79558fb4cdcc4fef6815 100644 (file)
@@ -11,7 +11,7 @@
 #define yyerrok (yyerrflag=0)
 #define YYRECOVERING (yyerrflag!=0)
 #define YYPREFIX "yy"
-/* NetHack 3.6  dgn_comp.y     $NHDT-Date: 1449233106 2015/12/04 12:45:06 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.11 $ */
+/* NetHack 3.6  dgn_comp.y     $NHDT-Date: 1453249313 2016/01/20 00:21:53 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.12 $ */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /*     Copyright (c) 1990 by M. Stephenson                               */
 /* NetHack may be freely redistributed.  See license for details. */
index 2920d2295868395a90fc4034092fe7c52eb23eeb..be13962bad87ba2f55a32f8a2c503deabea8809b 100644 (file)
@@ -1022,7 +1022,7 @@ int yy_flex_debug = 0;
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
-/* NetHack 3.6  lev_comp.l     $NHDT-Date: 1449615116 2015/12/08 22:51:56 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.25 $ */
+/* NetHack 3.6  lev_comp.l     $NHDT-Date: 1453249313 2016/01/20 00:21:53 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.26 $ */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
index 62e1f204294b33609954ada16e21fab82cb0383f..c4a9780a7d3ab13feb3e5e7307f693d4921cc4a0 100644 (file)
@@ -11,8 +11,8 @@
 #define yyerrok (yyerrflag=0)
 #define YYRECOVERING (yyerrflag!=0)
 #define YYPREFIX "yy"
-/* NetHack 3.6  lev_comp.y     $NHDT-Date: 1449233826 2015/12/04 12:57:06 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.19 $ */
-/*     Copyright (c) 1989 by Jean-Christophe Collet */
+/* NetHack 3.6  lev_comp.y     $NHDT-Date: 1453249314 2016/01/20 00:21:54 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
+/*      Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /*
  * and AIX will still see the directive.
  */
 #ifdef _AIX
- #pragma alloca                /* keep leading space! */
+ #pragma alloca         /* keep leading space! */
 #endif
 
 #define SPEC_LEV    /* for USE_OLDARGS (sp_lev.h) */
 #include "hack.h"
 #include "sp_lev.h"
 
-#define ERR            (-1)
+#define ERR             (-1)
 /* many types of things are put in chars for transference to NetHack.
  * since some systems will use signed chars, limit everybody to the
  * same number for portability.
  */
-#define MAX_OF_TYPE    128
+#define MAX_OF_TYPE     128
 
-#define MAX_NESTED_IFS 20
+#define MAX_NESTED_IFS   20
 #define MAX_SWITCH_CASES 20
 
-#define New(type)              \
-       (type *) memset((genericptr_t)alloc(sizeof(type)), 0, sizeof(type))
-#define NewTab(type, size)     (type **) alloc(sizeof(type *) * size)
-#define Free(ptr)              free((genericptr_t)ptr)
+#define New(type) \
+        (type *) memset((genericptr_t) alloc(sizeof (type)), 0, sizeof (type))
+#define NewTab(type, size)      (type **) alloc(sizeof (type *) * size)
+#define Free(ptr)               free((genericptr_t) ptr)
 
 extern void VDECL(lc_error, (const char *, ...));
 extern void VDECL(lc_warning, (const char *, ...));
@@ -70,22 +70,24 @@ extern char FDECL(what_map_char, (CHAR_P));
 extern void FDECL(scan_map, (char *, sp_lev *));
 extern void FDECL(add_opcode, (sp_lev *, int, genericptr_t));
 extern genericptr_t FDECL(get_last_opcode_data1, (sp_lev *, int));
-extern genericptr_t FDECL(get_last_opcode_data2, (sp_lev *, int,int));
+extern genericptr_t FDECL(get_last_opcode_data2, (sp_lev *, int, int));
 extern boolean FDECL(check_subrooms, (sp_lev *));
 extern boolean FDECL(write_level_file, (char *,sp_lev *));
 extern struct opvar *FDECL(set_opvar_int, (struct opvar *, long));
 extern void VDECL(add_opvars, (sp_lev *, const char *, ...));
 extern void FDECL(start_level_def, (sp_lev * *, char *));
 
-extern struct lc_funcdefs *FDECL(funcdef_new,(long,char *));
-extern void FDECL(funcdef_free_all,(struct lc_funcdefs *));
-extern struct lc_funcdefs *FDECL(funcdef_defined,(struct lc_funcdefs *,char *, int));
+extern struct lc_funcdefs *FDECL(funcdef_new, (long,char *));
+extern void FDECL(funcdef_free_all, (struct lc_funcdefs *));
+extern struct lc_funcdefs *FDECL(funcdef_defined, (struct lc_funcdefs *,
+                                                   char *, int));
 extern char *FDECL(funcdef_paramtypes, (struct lc_funcdefs *));
 extern char *FDECL(decode_parm_str, (char *));
 
-extern struct lc_vardefs *FDECL(vardef_new,(long,char *));
-extern void FDECL(vardef_free_all,(struct lc_vardefs *));
-extern struct lc_vardefs *FDECL(vardef_defined,(struct lc_vardefs *,char *, int));
+extern struct lc_vardefs *FDECL(vardef_new, (long,char *));
+extern void FDECL(vardef_free_all, (struct lc_vardefs *));
+extern struct lc_vardefs *FDECL(vardef_defined, (struct lc_vardefs *,
+                                                 char *, int));
 
 extern void NDECL(break_stmt_start);
 extern void FDECL(break_stmt_end, (sp_lev *));
@@ -95,13 +97,14 @@ extern void FDECL(splev_add_from, (sp_lev *, sp_lev *));
 
 extern void FDECL(check_vardef_type, (struct lc_vardefs *, char *, long));
 extern void FDECL(vardef_used, (struct lc_vardefs *, char *));
-extern struct lc_vardefs *FDECL(add_vardef_type, (struct lc_vardefs *, char *, long));
+extern struct lc_vardefs *FDECL(add_vardef_type, (struct lc_vardefs *,
+                                                  char *, long));
 
 extern int FDECL(reverse_jmp_opcode, (int));
 
 struct coord {
-       long x;
-       long y;
+    long x;
+    long y;
 };
 
 struct forloopdef {
@@ -3222,7 +3225,7 @@ case 148:
                      }
 
                      /* first, define a variable for the for-loop end value */
-                     snprintf(buf, 255, "%s end", yyvsp[-4].map);
+                     Sprintf(buf, "%s end", yyvsp[-4].map);
                      /* the value of which is already in stack (the 2nd math_expr) */
                      add_opvars(splev, "iso", VA_PASS3(0, buf, SPO_VAR_INIT));
 
@@ -3232,7 +3235,7 @@ case 148:
                      add_opvars(splev, "iso", VA_PASS3(0, yyvsp[-4].map, SPO_VAR_INIT));
 
                      /* calculate value for the loop "step" variable */
-                     snprintf(buf2, 255, "%s step", yyvsp[-4].map);
+                     Sprintf(buf2, "%s step", yyvsp[-4].map);
                      /* end - start */
                      add_opvars(splev, "vvo",
                                 VA_PASS3(buf, yyvsp[-4].map, SPO_MATH_SUB));
@@ -3258,9 +3261,10 @@ break;
 case 150:
 {
                      char buf[256], buf2[256];
+
                      n_forloops--;
-                     snprintf(buf, 255, "%s step", forloop_list[n_forloops].varname);
-                     snprintf(buf2, 255, "%s end", forloop_list[n_forloops].varname);
+                     Sprintf(buf, "%s step", forloop_list[n_forloops].varname);
+                     Sprintf(buf2, "%s end", forloop_list[n_forloops].varname);
                      /* compare for-loop var to end value */
                      add_opvars(splev, "vvo",
                                 VA_PASS3(forloop_list[n_forloops].varname,
@@ -3993,8 +3997,8 @@ case 253:
                      add_opvars(splev, "iiiii iiiii iiso",
                                 VA_PASS14(yyvsp[-4].lregn.x1, yyvsp[-4].lregn.y1, yyvsp[-4].lregn.x2, yyvsp[-4].lregn.y2, yyvsp[-4].lregn.area,
                                           yyvsp[-2].lregn.x1, yyvsp[-2].lregn.y1, yyvsp[-2].lregn.x2, yyvsp[-2].lregn.y2, yyvsp[-2].lregn.area,
-                                     (long)((yyvsp[0].i) ? LR_UPSTAIR : LR_DOWNSTAIR),
-                                          0, (char *)0, SPO_LEVREGION));
+                                    (long) ((yyvsp[0].i) ? LR_UPSTAIR : LR_DOWNSTAIR),
+                                          0, (char *) 0, SPO_LEVREGION));
                  }
 break;
 case 254:
@@ -4025,8 +4029,8 @@ case 256:
                      add_opvars(splev, "iiiii iiiii iiso",
                                 VA_PASS14(yyvsp[-2].lregn.x1, yyvsp[-2].lregn.y1, yyvsp[-2].lregn.x2, yyvsp[-2].lregn.y2, yyvsp[-2].lregn.area,
                                           yyvsp[0].lregn.x1, yyvsp[0].lregn.y1, yyvsp[0].lregn.x2, yyvsp[0].lregn.y2, yyvsp[0].lregn.area,
-                                          (long)LR_BRANCH, 0,
-                                          (char *)0, SPO_LEVREGION));
+                                          (long) LR_BRANCH, 0,
+                                          (char *) 0, SPO_LEVREGION));
                  }
 break;
 case 257:
@@ -4421,7 +4425,8 @@ case 329:
                           lc_error("Unknown monster \"%s\"!", yyvsp[0].map);
                           yyval.i = -1;
                       } else
-                          yyval.i = SP_MONST_PACK(m, def_monsyms[(int)mons[m].mlet].sym);
+                          yyval.i = SP_MONST_PACK(m,
+                                         def_monsyms[(int) mons[m].mlet].sym);
                       Free(yyvsp[0].map);
                   }
 break;
@@ -4643,7 +4648,7 @@ break;
 case 363:
 {
                              long len = strlen( yyvsp[-2].map );
-                             char *tmp = (char *)alloc(len + 2);
+                             char *tmp = (char *) alloc(len + 2);
                              sprintf(tmp, "%c%s", (char) yyvsp[0].i, yyvsp[-2].map );
                              Free( yyvsp[-2].map );
                              yyval.map = tmp;
@@ -4810,13 +4815,21 @@ break;
 case 404:
 {
                        if (yyvsp[-7].i <= 0 || yyvsp[-7].i >= COLNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (x1)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (x1)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
                        else if (yyvsp[-5].i < 0 || yyvsp[-5].i >= ROWNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (y1)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (y1)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
                        else if (yyvsp[-3].i <= 0 || yyvsp[-3].i >= COLNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (x2)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (x2)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
                        else if (yyvsp[-1].i < 0 || yyvsp[-1].i >= ROWNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (y2)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (y2)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
                        yyval.lregn.x1 = yyvsp[-7].i;
                        yyval.lregn.y1 = yyvsp[-5].i;
                        yyval.lregn.x2 = yyvsp[-3].i;
@@ -4828,14 +4841,22 @@ case 405:
 {
 /* This series of if statements is a hack for MSC 5.1.  It seems that its
    tiny little brain cannot compile if these are all one big if statement. */
-                       if (yyvsp[-7].i < 0 || yyvsp[-7].i > (int)max_x_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (x1)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
-                       else if (yyvsp[-5].i < 0 || yyvsp[-5].i > (int)max_y_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (y1)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
-                       else if (yyvsp[-3].i < 0 || yyvsp[-3].i > (int)max_x_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (x2)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
-                       else if (yyvsp[-1].i < 0 || yyvsp[-1].i > (int)max_y_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (y2)!", yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                       if (yyvsp[-7].i < 0 || yyvsp[-7].i > (int) max_x_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (x1)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                       else if (yyvsp[-5].i < 0 || yyvsp[-5].i > (int) max_y_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (y1)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                       else if (yyvsp[-3].i < 0 || yyvsp[-3].i > (int) max_x_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (x2)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
+                       else if (yyvsp[-1].i < 0 || yyvsp[-1].i > (int) max_y_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (y2)!",
+                                     yyvsp[-7].i, yyvsp[-5].i, yyvsp[-3].i, yyvsp[-1].i);
                        yyval.lregn.area = 0;
                        yyval.lregn.x1 = yyvsp[-7].i;
                        yyval.lregn.y1 = yyvsp[-5].i;
index c70c48148c160829c725d572b58d67486c9d5085..35f4eb252d667c63f724fdab2b598ba9df20847d 100644 (file)
@@ -102,9 +102,9 @@ FILE *orig_yyin = NULL;
 #define ST_RETF(y, x) do { savetoken(yytext); y; return x; } while (0);
 
 %}
-%e 2000
-%p 5000
-%n 700
+%e 2500
+%p 10000
+%n 1500
 %s MAPC
 %%
 <MAPC>ENDMAP   {
index 6831564d109e05e3d12e09b0f0ec935c0f4393d8..5be78d8402f7ca3fc725aef7761a4e8af766e8dd 100644 (file)
@@ -1,6 +1,6 @@
 %{
 /* NetHack 3.6  lev_comp.y     $NHDT-Date: 1448074095 2015/11/21 02:48:15 $  $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
-/*     Copyright (c) 1989 by Jean-Christophe Collet */
+/*      Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /*
  * and AIX will still see the directive.
  */
 #ifdef _AIX
- #pragma alloca                /* keep leading space! */
+ #pragma alloca         /* keep leading space! */
 #endif
 
 #define SPEC_LEV    /* for USE_OLDARGS (sp_lev.h) */
 #include "hack.h"
 #include "sp_lev.h"
 
-#define ERR            (-1)
+#define ERR             (-1)
 /* many types of things are put in chars for transference to NetHack.
  * since some systems will use signed chars, limit everybody to the
  * same number for portability.
  */
-#define MAX_OF_TYPE    128
+#define MAX_OF_TYPE     128
 
-#define MAX_NESTED_IFS 20
+#define MAX_NESTED_IFS   20
 #define MAX_SWITCH_CASES 20
 
-#define New(type)              \
-       (type *) memset((genericptr_t)alloc(sizeof(type)), 0, sizeof(type))
-#define NewTab(type, size)     (type **) alloc(sizeof(type *) * size)
-#define Free(ptr)              free((genericptr_t)ptr)
+#define New(type) \
+        (type *) memset((genericptr_t) alloc(sizeof (type)), 0, sizeof (type))
+#define NewTab(type, size)      (type **) alloc(sizeof (type *) * size)
+#define Free(ptr)               free((genericptr_t) ptr)
 
 extern void VDECL(lc_error, (const char *, ...));
 extern void VDECL(lc_warning, (const char *, ...));
@@ -58,22 +58,24 @@ extern char FDECL(what_map_char, (CHAR_P));
 extern void FDECL(scan_map, (char *, sp_lev *));
 extern void FDECL(add_opcode, (sp_lev *, int, genericptr_t));
 extern genericptr_t FDECL(get_last_opcode_data1, (sp_lev *, int));
-extern genericptr_t FDECL(get_last_opcode_data2, (sp_lev *, int,int));
+extern genericptr_t FDECL(get_last_opcode_data2, (sp_lev *, int, int));
 extern boolean FDECL(check_subrooms, (sp_lev *));
 extern boolean FDECL(write_level_file, (char *,sp_lev *));
 extern struct opvar *FDECL(set_opvar_int, (struct opvar *, long));
 extern void VDECL(add_opvars, (sp_lev *, const char *, ...));
 extern void FDECL(start_level_def, (sp_lev * *, char *));
 
-extern struct lc_funcdefs *FDECL(funcdef_new,(long,char *));
-extern void FDECL(funcdef_free_all,(struct lc_funcdefs *));
-extern struct lc_funcdefs *FDECL(funcdef_defined,(struct lc_funcdefs *,char *, int));
+extern struct lc_funcdefs *FDECL(funcdef_new, (long,char *));
+extern void FDECL(funcdef_free_all, (struct lc_funcdefs *));
+extern struct lc_funcdefs *FDECL(funcdef_defined, (struct lc_funcdefs *,
+                                                   char *, int));
 extern char *FDECL(funcdef_paramtypes, (struct lc_funcdefs *));
 extern char *FDECL(decode_parm_str, (char *));
 
-extern struct lc_vardefs *FDECL(vardef_new,(long,char *));
-extern void FDECL(vardef_free_all,(struct lc_vardefs *));
-extern struct lc_vardefs *FDECL(vardef_defined,(struct lc_vardefs *,char *, int));
+extern struct lc_vardefs *FDECL(vardef_new, (long,char *));
+extern void FDECL(vardef_free_all, (struct lc_vardefs *));
+extern struct lc_vardefs *FDECL(vardef_defined, (struct lc_vardefs *,
+                                                 char *, int));
 
 extern void NDECL(break_stmt_start);
 extern void FDECL(break_stmt_end, (sp_lev *));
@@ -83,13 +85,14 @@ extern void FDECL(splev_add_from, (sp_lev *, sp_lev *));
 
 extern void FDECL(check_vardef_type, (struct lc_vardefs *, char *, long));
 extern void FDECL(vardef_used, (struct lc_vardefs *, char *));
-extern struct lc_vardefs *FDECL(add_vardef_type, (struct lc_vardefs *, char *, long));
+extern struct lc_vardefs *FDECL(add_vardef_type, (struct lc_vardefs *,
+                                                  char *, long));
 
 extern int FDECL(reverse_jmp_opcode, (int));
 
 struct coord {
-       long x;
-       long y;
+    long x;
+    long y;
 };
 
 struct forloopdef {
@@ -979,7 +982,7 @@ forstmt_start       : FOR_ID any_var_or_unk '=' math_expr_var for_to_span math_expr_va
                      }
 
                      /* first, define a variable for the for-loop end value */
-                     snprintf(buf, 255, "%s end", $2);
+                     Sprintf(buf, "%s end", $2);
                      /* the value of which is already in stack (the 2nd math_expr) */
                      add_opvars(splev, "iso", VA_PASS3(0, buf, SPO_VAR_INIT));
 
@@ -989,7 +992,7 @@ forstmt_start       : FOR_ID any_var_or_unk '=' math_expr_var for_to_span math_expr_va
                      add_opvars(splev, "iso", VA_PASS3(0, $2, SPO_VAR_INIT));
 
                      /* calculate value for the loop "step" variable */
-                     snprintf(buf2, 255, "%s step", $2);
+                     Sprintf(buf2, "%s step", $2);
                      /* end - start */
                      add_opvars(splev, "vvo",
                                 VA_PASS3(buf, $2, SPO_MATH_SUB));
@@ -1015,9 +1018,10 @@ forstatement     : forstmt_start
                 stmt_block
                  {
                      char buf[256], buf2[256];
+
                      n_forloops--;
-                     snprintf(buf, 255, "%s step", forloop_list[n_forloops].varname);
-                     snprintf(buf2, 255, "%s end", forloop_list[n_forloops].varname);
+                     Sprintf(buf, "%s step", forloop_list[n_forloops].varname);
+                     Sprintf(buf2, "%s end", forloop_list[n_forloops].varname);
                      /* compare for-loop var to end value */
                      add_opvars(splev, "vvo",
                                 VA_PASS3(forloop_list[n_forloops].varname,
@@ -1747,8 +1751,8 @@ stair_region      : STAIR_ID ':' lev_region ',' lev_region ',' UP_OR_DOWN
                      add_opvars(splev, "iiiii iiiii iiso",
                                 VA_PASS14($3.x1, $3.y1, $3.x2, $3.y2, $3.area,
                                           $5.x1, $5.y1, $5.x2, $5.y2, $5.area,
-                                     (long)(($7) ? LR_UPSTAIR : LR_DOWNSTAIR),
-                                          0, (char *)0, SPO_LEVREGION));
+                                    (long) (($7) ? LR_UPSTAIR : LR_DOWNSTAIR),
+                                          0, (char *) 0, SPO_LEVREGION));
                  }
                ;
 
@@ -1782,8 +1786,8 @@ branch_region     : BRANCH_ID ':' lev_region ',' lev_region
                      add_opvars(splev, "iiiii iiiii iiso",
                                 VA_PASS14($3.x1, $3.y1, $3.x2, $3.y2, $3.area,
                                           $5.x1, $5.y1, $5.x2, $5.y2, $5.area,
-                                          (long)LR_BRANCH, 0,
-                                          (char *)0, SPO_LEVREGION));
+                                          (long) LR_BRANCH, 0,
+                                          (char *) 0, SPO_LEVREGION));
                  }
                ;
 
@@ -2207,7 +2211,8 @@ encodemonster     : STRING
                           lc_error("Unknown monster \"%s\"!", $1);
                           $$ = -1;
                       } else
-                          $$ = SP_MONST_PACK(m, def_monsyms[(int)mons[m].mlet].sym);
+                          $$ = SP_MONST_PACK(m,
+                                         def_monsyms[(int) mons[m].mlet].sym);
                       Free($1);
                   }
                 | CHAR
@@ -2423,7 +2428,7 @@ func_call_param_list      : func_call_param_part
                        | func_call_param_list ',' func_call_param_part
                          {
                              long len = strlen( $1 );
-                             char *tmp = (char *)alloc(len + 2);
+                             char *tmp = (char *) alloc(len + 2);
                              sprintf(tmp, "%c%s", (char) $3, $1 );
                              Free( $1 );
                              $$ = tmp;
@@ -2593,13 +2598,21 @@ lev_region      : region
                | LEV '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'
                  {
                        if ($3 <= 0 || $3 >= COLNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (x1)!", $3, $5, $7, $9);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (x1)!",
+                                     $3, $5, $7, $9);
                        else if ($5 < 0 || $5 >= ROWNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (y1)!", $3, $5, $7, $9);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (y1)!",
+                                     $3, $5, $7, $9);
                        else if ($7 <= 0 || $7 >= COLNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (x2)!", $3, $5, $7, $9);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (x2)!",
+                                     $3, $5, $7, $9);
                        else if ($9 < 0 || $9 >= ROWNO)
-                           lc_error("Region (%li,%li,%li,%li) out of level range (y2)!", $3, $5, $7, $9);
+                           lc_error(
+                          "Region (%ld,%ld,%ld,%ld) out of level range (y2)!",
+                                     $3, $5, $7, $9);
                        $$.x1 = $3;
                        $$.y1 = $5;
                        $$.x2 = $7;
@@ -2612,14 +2625,22 @@ region          : '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'
                  {
 /* This series of if statements is a hack for MSC 5.1.  It seems that its
    tiny little brain cannot compile if these are all one big if statement. */
-                       if ($2 < 0 || $2 > (int)max_x_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (x1)!", $2, $4, $6, $8);
-                       else if ($4 < 0 || $4 > (int)max_y_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (y1)!", $2, $4, $6, $8);
-                       else if ($6 < 0 || $6 > (int)max_x_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (x2)!", $2, $4, $6, $8);
-                       else if ($8 < 0 || $8 > (int)max_y_map)
-                           lc_error("Region (%li,%li,%li,%li) out of map range (y2)!", $2, $4, $6, $8);
+                       if ($2 < 0 || $2 > (int) max_x_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (x1)!",
+                                     $2, $4, $6, $8);
+                       else if ($4 < 0 || $4 > (int) max_y_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (y1)!",
+                                     $2, $4, $6, $8);
+                       else if ($6 < 0 || $6 > (int) max_x_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (x2)!",
+                                     $2, $4, $6, $8);
+                       else if ($8 < 0 || $8 > (int) max_y_map)
+                           lc_error(
+                            "Region (%ld,%ld,%ld,%ld) out of map range (y2)!",
+                                     $2, $4, $6, $8);
                        $$.area = 0;
                        $$.x1 = $2;
                        $$.y1 = $4;
index c95441bce2e0eb0f946d844741e16e8384422b85..3dce1a72070b8f17e529f6bd3f1cb0a2a8599b96 100644 (file)
@@ -1,5 +1,5 @@
 /* NetHack 3.6 lev_main.c      $NHDT-Date: 1448074107 2015/11/21 02:48:27 $  $NHDT-Branch: master $:$NHDT-Revision: 1.43 $ */
-/*     Copyright (c) 1989 by Jean-Christophe Collet */
+/*      Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /*
@@ -939,7 +939,7 @@ long spovar;
 
     togl = ((togl + 1) % 2);
 
-    snprintf(buf[togl], 127, "%s%s", n, (is_array ? " array" : ""));
+    Sprintf(buf[togl], "%s%s", n, (is_array ? " array" : ""));
     return buf[togl];
 }