diff --git a/Files b/Files index c0710ff98..f73471fab 100644 --- a/Files +++ b/Files @@ -6,7 +6,7 @@ from or not transferred to your system if you wish. .: (files in top directory) -DEVEL Files Porting README +Files Porting README dat: (files for all versions) @@ -26,7 +26,7 @@ Guidebook.mn Guidebook.tex Guidebook.txt dgn_comp.6 dgn_comp.txt dlb.6 dlb.txt fixes22.0 fixes30.0 fixes31.1 fixes31.2 fixes31.3 fixes32.0 fixes32.1 fixes32.2 fixes32.3 fixes33.0 fixes33.1 fixes34.0 fixes34.1 -fixes34.2 fixes34.3 fixes34.4 fixes36.0 lev_comp.6 +fixes34.2 fixes34.3 fixes35.0 fixes36.0 lev_comp.6 lev_comp.txt makedefs.6 makedefs.txt nethack.6 nethack.txt recover.6 recover.txt tmac.n window.doc @@ -42,10 +42,10 @@ mkroom.h monattk.h mondata.h monflag.h monst.h monsym.h ntconf.h obj.h objclass.h os2conf.h patchlevel.h pcconf.h permonst.h prop.h qtext.h quest.h rect.h region.h rm.h skills.h -sp_lev.h spell.h system.h tcap.h timeout.h -tosconf.h tradstdc.h trampoli.h trap.h unixconf.h -vision.h vmsconf.h wceconf.h winami.h winprocs.h -wintype.h you.h youprop.h +sp_lev.h spell.h sys.h system.h tcap.h +timeout.h tosconf.h tradstdc.h trampoli.h trap.h +unixconf.h vision.h vmsconf.h wceconf.h winami.h +winprocs.h wintype.h you.h youprop.h (file for tty versions) wintty.h (files for X versions) @@ -79,11 +79,11 @@ potion.c pray.c priest.c quest.c questpgr.c read.c rect.c region.c restore.c rip.c rnd.c role.c rumors.c save.c shk.c shknam.c sit.c sounds.c sp_lev.c spell.c -steal.c steed.c teleport.c timeout.c topten.c -track.c trap.c u_init.c uhitm.c vault.c -version.c vision.c weapon.c were.c wield.c -windows.c wizard.c worm.c worn.c write.c -zap.c +steal.c steed.c sys.c teleport.c timeout.c +topten.c track.c trap.c u_init.c uhitm.c +vault.c version.c vision.c weapon.c were.c +wield.c windows.c wizard.c worm.c worn.c +write.c zap.c sys/amiga: (files for Amiga versions - untested for 3.6.0) @@ -119,8 +119,8 @@ sys/msdos: Install.dos Makefile.BC Makefile.GCC Makefile.MSC moveinit.pat msdos.c msdoshlp.txt ovlinit.c pckeys.c pctiles.c pctiles.h pcvideo.h portio.h schema1.BC schema2.BC -schema3.MSC setup.bat sound.c tile2bin.c video.c -vidtxt.c vidvga.c +schema3.MSC SCHEMA35.MSC setup.bat sound.c tile2bin.c +video.c vidtxt.c vidvga.c (files for running MSDOS binary under Windows) nhico.uu nhpif.uu @@ -129,13 +129,13 @@ sys/os2: Install.os2 Makefile.os2 nhpmico.uu os2.c sys/share: -(files for MSDOS and OS/2 versions) +(files for MSDOS and OS/2 versions - untested for 3.6.0) Makefile.lib termcap.uu -(file for MSDOS, OS/2, NT, Amiga, and Atari versions) +(file for MSDOS, OS/2, NT, Amiga, and Atari versions - untested for 3.6.0) pcmain.c -(files for MSDOS, OS/2, NT, and Atari versions) +(files for MSDOS, OS/2, NT, and Atari versions - untested for 3.6.0) pcsys.c pcunix.c -(file for MSDOS, OS/2, and Atari versions) +(file for MSDOS, OS/2, and Atari versions - untested for 3.6.0) NetHack.cnf pctty.c (files for UNIX and Be versions) ioctl.c unixtty.c @@ -169,7 +169,8 @@ sys/unix: (files for UNIX versions) Install.unx Makefile.dat Makefile.doc Makefile.src Makefile.top Makefile.utl README.linux depend.awk mkmkfile.sh nethack.sh -setup.sh sysconf unixmain.c unixres.c unixunix.c +NewInstall.unx setup.sh sysconf unixmain.c unixres.c +unixunix.c (files for replacement cpp, only needed by some ancient UNIX systems) cpp1.shr cpp2.shr cpp3.shr (file for sound driver for 386 UNIX) @@ -177,8 +178,8 @@ snd86unx.shr sys/unix/hints: (files for configuring UNIX NetHack versions) -linux linux-x11 macosx macosx10.5 macosx10.7 -macosx10.10 unix +linux linux-chroot linux-x11 macosx macosx10.5 +macosx10.7 macosx.sh macosx10.10 unix sys/vms: (files for VMS version - untested for 3.6.0) @@ -196,28 +197,29 @@ mhdlg.h mhfont.c mhfont.h mhinput.c mhinput.h mhmain.c mhmain.h mhmap.c mhmap.h mhmenu.c mhmenu.h mhmsg.h mhmsgwnd.c mhmsgwnd.h mhrip.c mhrip.h mhstatus.c mhstatus.h mhtext.c mhtext.h -mhtxtbuf.c mhtxtbuf.h mswproc.c newres.h resource.h -winMS.h winhack.c winhack.rc winhcksp.rc winmain.c +mhtxtbuf.c mhtxtbuf.h mswproc.c newres.h nhico.uu +resource.h winMS.h winhack.c winhack.rc winhcksp.rc +winmain.c sys/wince/ceinc: -(header files for Windows CE and PocketPC) +(header files for Windows CE and PocketPC - untested for 3.6.0) assert.h errno.h fcntl.h sys/wince/ceinc/sys: -(sys/stat.h for Windows CE and PocketPC) +(sys/stat.h for Windows CE and PocketPC - untested for 3.6.0) stat.h sys/winnt: -(files for Windows 9x, NT and Windows2000 version) +(files for Windows 7/8.x/10 version) Install.nt Makefile.gcc Makefile.msc console.rc defaults.nh nethack.def nh340key.c nhdefkey.c nhico.uu nhraykey.c -nhsetup.bat ntsound.c nttty.c porthelp sysconf -win32api.h winnt.c +nhsetup.bat ntsound.c nttty.c porthelp stubs.c +sysconf win32api.h winnt.c util: (files for all versions) -dgn_main.c dlb_main.c lev_main.c makedefs.c panic.c -recover.c +dgn_main.c dlb_main.c lev_main.c makedefs.c mdgrep.h +mdgrep.pl panic.c recover.c (lex/yacc input for special level and dungeon compilers) dgn_comp.l dgn_comp.y lev_comp.l lev_comp.y @@ -235,14 +237,18 @@ nh_icon.xpm pet_mark.xbm pilemark.xbm rip.xpm tile2x11.c winX.c winmap.c winmenu.c winmesg.c winmisc.c winstat.c wintext.c winval.c +win/chain: +(files for win/chain) +wc_chainin.c wc_chainout.c wc_trace.c + win/gem: -(files for GEM versions) +(files for GEM versions - untested for 3.6.0) Install.gem bitmfile.c gem_rsc.uu gem_rso.uu gr_rect.c gr_rect.h load_img.c tile2img.c title.uu wingem.c wingem1.c xpm2img.c win/gnome: -(files for GNOME versions) +(files for GNOME versions - untested for 3.6.0) README gn_xpms.h gnaskstr.c gnaskstr.h gnbind.c gnbind.h gnglyph.c gnglyph.h gnmain.c gnmain.h gnmap.c gnmap.h gnmenu.c gnmenu.h gnmesg.c @@ -251,11 +257,16 @@ gnplayer.h gnsignal.c gnsignal.h gnstatus.c gnstatus.h gntext.c gntext.h gnworn.c gnworn.h gnyesno.c gnyesno.h mapbg.xpm +win/macosx: +(files for macosx versions) +NetHackGuidebook.applescript NetHackRecover.applescript +NetHackTerm.applescript recover.pl + win/share: (files for versions using optional tiles) gifread.c monsters.txt objects.txt other.txt ppmwrite.c -thintile.c tile.doc tile.h tile2bmp.c tilemap.c -tiletext.c +renumtiles.pl thintile.c tile.doc tile.h tile2bmp.c +tilemap.c tiletext.c win/tty: (files for tty versions) @@ -271,11 +282,20 @@ mhsplash.h mhstatus.c mhstatus.h mhtext.c mhtext.h mnsel.uu mnselcnt.uu mnunsel.uu mswproc.c petmark.uu pilemark.uu resource.h rip.uu splash.uu tiles.mak winMS.h winhack.c winhack.rc + +win/win32/vs2010: (files for Visual Studio 2010 Express Edition builds) -dgncomp.vcxproj dgnstuff.vcxproj dgnstuff.mak dlb_main.vcxproj -levcomp.vcxproj levstuff.vcxproj levstuff.mak makedefs.vcxproj -NetHack.sln uudecode.vcxproj NetHackW.vcxproj tile2bmp.vcxproj -recover.vcxproj tilemap.vcxproj tiles.vcxproj +dgncomp.vcxproj dgnstuff.vcxproj dlb_main.vcxproj levcomp.vcxproj +levstuff.vcxproj makedefs.vcxproj NetHack.sln NetHackW.vcxproj +recover.vcxproj tile2bmp.vcxproj tilemap.vcxproj tiles.vcxproj +uudecode.vcxproj + +win/win32/vs2013: +(files for Visual Studio 2013 Express Edition builds) +dgncomp.vcxproj dgnstuff.vcxproj dlb_main.vcxproj levcomp.vcxproj +levstuff.vcxproj makedefs.vcxproj NetHack.sln NetHack.vcxproj +NetHackW.vcxproj nhdefkey.vcxproj recover.vcxproj tile2bmp.vcxproj +tilemap.vcxproj tiles.vcxproj uudecode.vcxproj This is a list of files produced by auxiliary programs. They can all be regenerated from the files in the distribution. @@ -355,22 +375,22 @@ uudecode.exe DEVEL: (files for people developing changes to NetHack) -DOTGIT code_style.txt nhgitset.pl -Developer.txt git_recipes.txt -code_features.txt hooksdir +code_features.txt code_style.txt Developer.txt git_recipes.txt +nhgitset.pl + +DEVEL/DOTGIT: +TARGET DEVEL/hooksdir: -NHadd nhsub pre-auto-gc -NHgithook.pm post-applypatch pre-commit -NHsubst post-checkout pre-push -NHtext post-commit pre-rebase -TARGET post-merge prepare-commit-msg -applypatch-msg post-rewrite -commit-msg pre-applypatch +applypatch-msg commit-msg NHadd NHgithook.pm +nhsub NHsubst NHtext post-applypatch +post-checkout post-commit post-merge post-rewrite +pre-applypatch pre-auto-gc pre-commit pre-push +pre-rebase prepare-commit-msg TARGET .: (files for win32 that are moved into . at compile time) -nethack.dsw +NetHack.dsw NOTE: If your binaries were compiled with the data librarian (DLB) option, your playground will not contain all of the files listed here. All diff --git a/README b/README index f3f9b78bc..8013ec6f2 100644 --- a/README +++ b/README @@ -61,7 +61,7 @@ Please read items (1), (2) and (3) BEFORE doing anything with your new code. on: Intel Pentium or better (or clone) running Linux, BSDI, or - Windows (XP through 10) + Windows (7 through 10) Intel 80386 or greater (or clone) boxes running Linux, or BSDI Mac OS X 10.9 OpenVMS (aka VMS) V8.4 on Alpha and on Integrity/Itanium/IA64 diff --git a/include/global.h b/include/global.h index 42be8902d..b7a61bd16 100644 --- a/include/global.h +++ b/include/global.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 global.h $NHDT-Date: 1432512780 2015/05/25 00:13:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ */ +/* NetHack 3.6 global.h $NHDT-Date: 1449116298 2015/12/03 04:18:18 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.46 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -7,9 +7,9 @@ #include -#define BETA /* development or beta testing [MRS] */ +/* #define BETA */ /* development or beta testing [MRS] */ -#define DEBUG +/* #define DEBUG */ /* * Files expected to exist in the playground directory. diff --git a/include/lint.h b/include/lint.h index 8fb79b4a9..c50446405 100644 --- a/include/lint.h +++ b/include/lint.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 lint.h $NHDT-Date: 1430897871 2015/05/06 07:37:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */ +/* NetHack 3.6 lint.h $NHDT-Date: 1449269910 2015/12/04 22:58:30 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.3 $ */ /* NetHack may be freely redistributed. See license for details. */ /* @@ -36,19 +36,21 @@ extern unsigned nhUse_dummy; #ifdef DEBUG #define showdebug(file) debugcore(file, TRUE) #define explicitdebug(file) debugcore(file, FALSE) -#define ifdebug(stmt) \ - do { \ - if (showdebug(__FILE__)) \ - stmt; \ +#define ifdebug(stmt) \ + do { \ + if (showdebug(__FILE__)) { \ + stmt; \ + } \ } while (0) #ifdef _MSC_VER /* if we have microsoft's C runtime we can use these instead */ #include -#define crtdebug(stmt) \ - do { \ - if (showdebug(__FILE__)) \ - stmt; \ - _RPT0(_CRT_WARN, "\n"); \ +#define crtdebug(stmt) \ + do { \ + if (showdebug(__FILE__)) { \ + stmt; \ + } \ + _RPT0(_CRT_WARN, "\n"); \ } while (0) #define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str)) #define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg)) diff --git a/include/patchlevel.h b/include/patchlevel.h index 33fc0f606..64cc5e4a4 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -36,8 +36,12 @@ /* Version 3.6.x */ /* - * NetHack 3.6.0, June NN, NNNN + * NetHack 3.6.0, December 7, 2015 * + * Hundreds of bug fixes. + * Some code reorganization. + * Some new features. + * Variations of some community patches rolled in. */ /****************************************************************************/ diff --git a/include/sys.h b/include/sys.h index 6755c9619..10b7c3c5f 100644 --- a/include/sys.h +++ b/include/sys.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 sys.h $NHDT-Date: 1448241778 2015/11/23 01:22:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */ +/* NetHack 3.6 sys.h $NHDT-Date: 1449296291 2015/12/05 06:18:11 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.27 $ */ /* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -20,23 +20,21 @@ struct sysopt { * -1: getenv() didn't find a value for DEBUGFILES. */ int maxplayers; + int seduce; + int check_save_uid; /* restoring savefile checks UID? */ + /* record file */ int persmax; int pers_is_uid; int entrymax; int pointsmin; int tt_oname_maxrank; -#ifdef PANICTRACE + /* panic options */ char *gdbpath; char *greppath; int panictrace_gdb; -#ifdef PANICTRACE_LIBC int panictrace_libc; -#endif -#endif - int seduce; - int check_save_uid; /* restoring savefile checks UID? */ }; extern struct sysopt sysopt; diff --git a/include/system.h b/include/system.h index 59a1ce23b..21ccf8b72 100644 --- a/include/system.h +++ b/include/system.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 system.h $NHDT-Date: 1432512775 2015/05/25 00:12:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */ +/* NetHack 3.6 system.h $NHDT-Date: 1449269772 2015/12/04 22:56:12 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.12 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -514,8 +514,9 @@ E char *FDECL(tgetstr, (const char *, char **)); E char *FDECL(tgoto, (const char *, int, int)); #endif -#ifdef ALLOC_C +#if defined(ALLOC_C) || defined(MAKEDEFS_C) E genericptr_t FDECL(malloc, (size_t)); +E genericptr_t FDECL(realloc, (genericptr_t, size_t)); #endif /* time functions */ diff --git a/src/attrib.c b/src/attrib.c index b0ee0fc11..3866dbf26 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 attrib.c $NHDT-Date: 1446975460 2015/11/08 09:37:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.49 $ */ +/* NetHack 3.6 attrib.c $NHDT-Date: 1449269911 2015/12/04 22:58:31 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.51 $ */ /* Copyright 1988, 1989, 1990, 1992, M. Stephenson */ /* NetHack may be freely redistributed. See license for details. */ @@ -470,8 +470,9 @@ exerchk() /* Check out the periodic accumulations */ exerper(); - if (moves >= context.next_attrib_check) + if (moves >= context.next_attrib_check) { debugpline1("exerchk: ready to test. multi = %d.", multi); + } /* Are we ready for a test? */ if (moves >= context.next_attrib_check && !multi) { debugpline0("exerchk: testing."); @@ -515,8 +516,9 @@ exerchk() ? "Dex" : (i == A_CON) ? "Con" - : (i == A_CHA) ? "Cha?" - : "???", + : (i == A_CHA) + ? "Cha?" + : "???", ax); /* * Law of diminishing returns (Part III): diff --git a/src/bones.c b/src/bones.c index b068e751a..7ca192599 100644 --- a/src/bones.c +++ b/src/bones.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 bones.c $NHDT-Date: 1446369463 2015/11/01 09:17:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */ +/* NetHack 3.6 bones.c $NHDT-Date: 1449269914 2015/12/04 22:58:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.66 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */ /* NetHack may be freely redistributed. See license for details. */ @@ -608,9 +608,10 @@ getbones() if (has_mname(mtmp)) sanitize_name(MNAME(mtmp)); if (mtmp->mhpmax == DEFUNCT_MONSTER) { - if (wizard) + if (wizard) { debugpline1("Removing defunct monster %s from bones.", mtmp->data->mname); + } mongone(mtmp); } else /* to correctly reset named artifacts on the level */ diff --git a/src/dbridge.c b/src/dbridge.c index 1dc43ad4b..7d6bda397 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dbridge.c $NHDT-Date: 1446955279 2015/11/08 04:01:19 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */ +/* NetHack 3.6 dbridge.c $NHDT-Date: 1449269914 2015/12/04 22:58:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.35 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -509,8 +509,9 @@ boolean chunks; { int misses; - if (chunks) + if (chunks) { debugpline0("Do chunks miss?"); + } if (automiss(etmp)) return TRUE; @@ -590,13 +591,14 @@ struct entity *etmp; return; } if (e_missed(etmp, FALSE)) { - if (at_portcullis) + if (at_portcullis) { pline_The("portcullis misses %s!", e_nam(etmp)); - else + } else { debugpline1("The drawbridge misses %s!", e_nam(etmp)); - if (e_survives_at(etmp, oldx, oldy)) + } + if (e_survives_at(etmp, oldx, oldy)) { return; - else { + } else { debugpline0("Mon can't survive here"); if (at_portcullis) must_jump = TRUE; @@ -978,10 +980,11 @@ int x, y; pline("%s hit by a huge chunk of metal!", E_phrase(etmp1, "are")); } else { - if (!Deaf && !is_u(etmp1) && !is_pool(x, y)) + if (!Deaf && !is_u(etmp1) && !is_pool(x, y)) { You_hear("a crushing sound."); - else + } else { debugpline1("%s from shrapnel", E_phrase(etmp1, "die")); + } } killer.format = KILLED_BY_AN; Strcpy(killer.name, "collapsing drawbridge"); diff --git a/src/dig.c b/src/dig.c index 0d1c24187..bbfef5d0b 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dig.c $NHDT-Date: 1446369465 2015/11/01 09:17:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */ +/* NetHack 3.6 dig.c $NHDT-Date: 1449269915 2015/12/04 22:58:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.103 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1864,8 +1864,9 @@ int x, y; { struct obj *otmp, *otmp2; - if (level.objects[x][y] != (struct obj *) 0) + if (level.objects[x][y] != (struct obj *) 0) { debugpline2("bury_objs: at <%d,%d>", x, y); + } for (otmp = level.objects[x][y]; otmp; otmp = otmp2) otmp2 = bury_an_obj(otmp, (boolean *) 0); diff --git a/src/eat.c b/src/eat.c index 8056cc190..fe3e4e071 100644 --- a/src/eat.c +++ b/src/eat.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 eat.c $NHDT-Date: 1446854226 2015/11/06 23:57:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.152 $ */ +/* NetHack 3.6 eat.c $NHDT-Date: 1449269916 2015/12/04 22:58:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.154 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -728,56 +728,57 @@ register struct permonst *ptr; { int res = 0; +#ifdef DEBUG +#define ifdebugresist(Msg) \ + do { \ + if (res) \ + debugpline0(Msg); \ + } while (0) +#else +#define ifdebugresist(Msg) /*empty*/ +#endif switch (type) { case FIRE_RES: res = (ptr->mconveys & MR_FIRE) != 0; - if (res) - debugpline0("can get fire resistance"); + ifdebugresist("can get fire resistance"); break; case SLEEP_RES: res = (ptr->mconveys & MR_SLEEP) != 0; - if (res) - debugpline0("can get sleep resistance"); + ifdebugresist("can get sleep resistance"); break; case COLD_RES: res = (ptr->mconveys & MR_COLD) != 0; - if (res) - debugpline0("can get cold resistance"); + ifdebugresist("can get cold resistance"); break; case DISINT_RES: res = (ptr->mconveys & MR_DISINT) != 0; - if (res) - debugpline0("can get disintegration resistance"); + ifdebugresist("can get disintegration resistance"); break; case SHOCK_RES: /* shock (electricity) resistance */ res = (ptr->mconveys & MR_ELEC) != 0; - if (res) - debugpline0("can get shock resistance"); + ifdebugresist("can get shock resistance"); break; case POISON_RES: res = (ptr->mconveys & MR_POISON) != 0; - if (res) - debugpline0("can get poison resistance"); + ifdebugresist("can get poison resistance"); break; case TELEPORT: res = can_teleport(ptr); - if (res) - debugpline0("can get teleport"); + ifdebugresist("can get teleport"); break; case TELEPORT_CONTROL: res = control_teleport(ptr); - if (res) - debugpline0("can get teleport control"); + ifdebugresist("can get teleport control"); break; case TELEPAT: res = telepathic(ptr); - if (res) - debugpline0("can get telepathy"); + ifdebugresist("can get telepathy"); break; default: /* res stays 0 */ break; } +#undef ifdebugresist return res; } diff --git a/src/files.c b/src/files.c index 1ce0c872e..1b74a56b4 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 files.c $NHDT-Date: 1448323244 2015/11/24 00:00:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.190 $ */ +/* NetHack 3.6 files.c $NHDT-Date: 1449296293 2015/12/05 06:18:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.192 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2224,6 +2224,7 @@ int src; (void) strncpy(dogname, bufp, PL_PSIZ - 1); } else if (match_varname(buf, "CATNAME", 3)) { (void) strncpy(catname, bufp, PL_PSIZ - 1); + #ifdef SYSCF } else if (src == SET_IN_SYS && match_varname(buf, "WIZARDS", 7)) { if (sysopt.wizards) @@ -2249,7 +2250,7 @@ int src; /* if showdebug() has already been called (perhaps we've added some debugpline() calls to option processing) and has found a value for getenv("DEBUGFILES"), don't override that */ - if (sysopt.env_dbgfl == 0) { + if (sysopt.env_dbgfl <= 0) { if (sysopt.debugfiles) free((genericptr_t) sysopt.debugfiles); sysopt.debugfiles = dupstr(bufp); @@ -2320,47 +2321,50 @@ int src; return 0; } sysopt.tt_oname_maxrank = n; -#ifdef PANICTRACE + + /* SYSCF PANICTRACE options */ } else if (src == SET_IN_SYS && match_varname(buf, "PANICTRACE_LIBC", 15)) { -#ifdef PANICTRACE_LIBC n = atoi(bufp); +#if defined(PANICTRACE) && defined(PANICTRACE_LIBC) if (n < 0 || n > 2) { raw_printf("Illegal value in PANICTRACE_LIBC (not 0,1,2)."); return 0; } +#endif sysopt.panictrace_libc = n; -#endif /* PANICTRACE_LIBC */ } else if (src == SET_IN_SYS && match_varname(buf, "PANICTRACE_GDB", 14)) { n = atoi(bufp); +#if defined(PANICTRACE) if (n < 0 || n > 2) { raw_printf("Illegal value in PANICTRACE_GDB (not 0,1,2)."); return 0; } +#endif sysopt.panictrace_gdb = n; } else if (src == SET_IN_SYS && match_varname(buf, "GDBPATH", 7)) { -#ifndef VMS /* VMS panictrace support doesn't use gdb or grep */ +#if defined(PANICTRACE) && !defined(VMS) if (!file_exists(bufp)) { raw_printf("File specified in GDBPATH does not exist."); return 0; } +#endif if (sysopt.gdbpath) free((genericptr_t) sysopt.gdbpath); sysopt.gdbpath = dupstr(bufp); -#endif } else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) { -#ifndef VMS /* VMS panictrace support doesn't use gdb or grep */ +#if defined(PANICTRACE) && !defined(VMS) if (!file_exists(bufp)) { raw_printf("File specified in GREPPATH does not exist."); return 0; } +#endif if (sysopt.greppath) free((genericptr_t) sysopt.greppath); sysopt.greppath = dupstr(bufp); -#endif /* !VMS */ -#endif /* PANICTRACE */ #endif /* SYSCF */ + } else if (match_varname(buf, "BOULDER", 3)) { (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE, 1, "BOULDER"); @@ -2559,7 +2563,7 @@ read_config_file(filename, src) const char *filename; int src; { - char buf[4 * BUFSZ]; + char buf[4 * BUFSZ], *p; FILE *fp; boolean rv = TRUE; /* assume successful parse */ @@ -2577,8 +2581,16 @@ line at this level. OR: Forbid multiline stuff for alternate config sources. */ #endif + if ((p = index(buf, '\n')) != 0) + *p = '\0'; if (!parse_config_line(fp, buf, src)) { - raw_printf("Bad option line: \"%.50s\"", buf); + static const char badoptionline[] = "Bad option line: \"%s\""; + + /* truncate buffer if it's long; this is actually conservative */ + if (strlen(buf) > BUFSZ - sizeof badoptionline) + buf[BUFSZ - sizeof badoptionline] = '\0'; + + raw_printf(badoptionline, buf); wait_synch(); rv = FALSE; } diff --git a/src/makemon.c b/src/makemon.c index c2db6f5d1..102379e4a 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makemon.c $NHDT-Date: 1449052582 2015/12/02 10:36:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.104 $ */ +/* NetHack 3.6 makemon.c $NHDT-Date: 1449269917 2015/12/04 22:58:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.105 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -857,9 +857,10 @@ boolean ghostly; mvitals[mndx].born++; if ((int) mvitals[mndx].born >= lim && !(mons[mndx].geno & G_NOGEN) && !(mvitals[mndx].mvflags & G_EXTINCT)) { - if (wizard) + if (wizard) { debugpline1("Automatically extinguished %s.", makeplural(mons[mndx].mname)); + } mvitals[mndx].mvflags |= G_EXTINCT; reset_rndmonst(mndx); } @@ -1072,9 +1073,10 @@ int mmflags; already been genocided, return */ if (mvitals[mndx].mvflags & G_GENOD) return (struct monst *) 0; - if (wizard && (mvitals[mndx].mvflags & G_EXTINCT)) + if (wizard && (mvitals[mndx].mvflags & G_EXTINCT)) { debugpline1("Explicitly creating extinct monster %s.", mons[mndx].mname); + } } else { /* make a random (common) monster that can survive here. * (the special levels ask for random monsters at specific diff --git a/src/mkmaze.c b/src/mkmaze.c index d1f372b64..eddf6fbd1 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkmaze.c $NHDT-Date: 1448013594 2015/11/20 09:59:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.41 $ */ +/* NetHack 3.6 mkmaze.c $NHDT-Date: 1449269918 2015/12/04 22:58:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.42 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -616,9 +616,10 @@ register const char *s; y_range = y_maze_max - y_maze_min - 2 * INVPOS_Y_MARGIN - 1; if (x_range <= INVPOS_X_MARGIN || y_range <= INVPOS_Y_MARGIN - || (x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE)) - debugpline2("inv_pos: maze is too small! (%d x %d)", x_maze_max, - y_maze_max); + || (x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE)) { + debugpline2("inv_pos: maze is too small! (%d x %d)", + x_maze_max, y_maze_max); + } inv_pos.x = inv_pos.y = 0; /*{occupied() => invocation_pos()}*/ do { x = rn1(x_range, x_maze_min + INVPOS_X_MARGIN + 1); diff --git a/src/mon.c b/src/mon.c index 8116d7877..ade596810 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1447475944 2015/11/14 04:39:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.196 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1449269918 2015/12/04 22:58:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1470,7 +1470,7 @@ struct monst *mtmp, *mtmp2; /* transfer the monster's inventory */ for (otmp = mtmp2->minvent; otmp; otmp = otmp->nobj) { if (otmp->where != OBJ_MINVENT || otmp->ocarry != mtmp) - debugpline0("replmon: minvent inconsistency"); + impossible("replmon: minvent inconsistency"); otmp->ocarry = mtmp2; } mtmp->minvent = 0; diff --git a/src/sp_lev.c b/src/sp_lev.c index eb0c65793..dc454128a 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 sp_lev.c $NHDT-Date: 1449051497 2015/12/02 10:18:17 $ $NHDT-Branch: master $:$NHDT-Revision: 1.76 $ */ +/* NetHack 3.6 sp_lev.c $NHDT-Date: 1449269920 2015/12/04 22:58:40 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.77 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -1033,8 +1033,9 @@ chk: lev = &levl[x][y]; for (; y <= ymax; y++) { if (lev++->typ) { - if (!vault) + if (!vault) { debugpline2("strange area [%d,%d] in check_room.", x, y); + } if (!rn2(3)) return FALSE; if (x < *lowx) diff --git a/src/version.c b/src/version.c index 76492bb80..97c8d0321 100644 --- a/src/version.c +++ b/src/version.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 version.c $NHDT-Date: 1446887538 2015/11/07 09:12:18 $ $NHDT-Branch: master $:$NHDT-Revision: 1.40 $ */ +/* NetHack 3.6 version.c $NHDT-Date: 1449328116 2015/12/05 15:08:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.41 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -15,7 +15,7 @@ #include "patchlevel.h" #endif -#define BETA_INFO "Beta5" +#define BETA_INFO "" STATIC_DCL void FDECL(insert_rtoptions, (winid,char *,const char *)); diff --git a/sys/share/dgn_lex.c b/sys/share/dgn_lex.c index 8c423e297..44ddfc5b3 100644 --- a/sys/share/dgn_lex.c +++ b/sys/share/dgn_lex.c @@ -3,110 +3,37 @@ #define YY_INT_ALIGNED short int -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. +/* A lexical scanner generated by flex via 'flex -S flexhack.skl' + * where flexhack.skl is a nethack-specific alternate skeleton derived + * from flex 2.6.0's skel.c (which in turn was generated from flex.skl). + * + * Support for C++, re-entrancy, and table serialization stripped out. + * NetHack's usage doesn't need them and we want to reduce the size and + * complexity of this skeleton as well as of the generated scanner code. */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif +#define FLEXHACK_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 0 -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; +#include "config.h" + +#include + +/* we don't care if actual types happen to have more bits than their names; + the tables will just take up more space, possibly slowing the parse; + still, allow config.h to override these via typedef+#define if desired */ +#ifndef FLEX_INT32_T typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +#endif +#ifndef FLEX_INT16_T +typedef short int flex_int16_t; +#endif +#ifndef FLEX_UINT16_T typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST #define yyconst const -#else -#define yyconst -#endif /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -116,7 +43,7 @@ typedef unsigned int flex_uint32_t; * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((unsigned int) (uchar) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less @@ -141,10 +68,19 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif -/* The state buf must be large enough to hold one state per character in the main buffer. +/* The state buf must be large enough to hold one state per character + * in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) @@ -159,35 +95,32 @@ typedef size_t yy_size_t; #endif extern yy_size_t yyleng; - extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - #define YY_LESS_LINENO(n) +#define YY_LESS_LINENO(n) +#define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) + YY_LESS_LINENO(yyless_macro_arg); \ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { +struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ @@ -222,8 +155,8 @@ struct yy_buffer_state */ int yy_at_bol; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. @@ -246,7 +179,7 @@ struct yy_buffer_state */ #define YY_BUFFER_EOF_PENDING 2 - }; +}; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ @@ -271,7 +204,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ yy_size_t yyleng; /* Points to current character in buffer. */ @@ -284,50 +217,47 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart FDECL(, (FILE *input_file )); +void yy_switch_to_buffer FDECL(, (YY_BUFFER_STATE new_buffer )); +YY_BUFFER_STATE yy_create_buffer FDECL(, (FILE *file,int size )); +void yy_delete_buffer FDECL(, (YY_BUFFER_STATE b )); +void yy_flush_buffer FDECL(, (YY_BUFFER_STATE b )); +void yypush_buffer_state FDECL(, (YY_BUFFER_STATE new_buffer )); +void yypop_buffer_state FDECL(, (void )); -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack FDECL(, (void )); +static void yy_load_buffer_state FDECL(, (void )); +static void yy_init_buffer FDECL(, (YY_BUFFER_STATE b,FILE *file )); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer FDECL(, (char *base,yy_size_t size )); +YY_BUFFER_STATE yy_scan_string FDECL(, (yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes FDECL(, (yyconst char *bytes,yy_size_t len )); -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc FDECL(, (yy_size_t )); +void *yyrealloc FDECL(, (void *,yy_size_t )); +void yyfree FDECL(, (void * )); #define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + if ( ! YY_CURRENT_BUFFER ) { \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + if ( ! YY_CURRENT_BUFFER ) { \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ @@ -343,12 +273,15 @@ extern int yylineno; int yylineno = 1; extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state FDECL(, (void )); +static yy_state_type yy_try_NUL_trans FDECL(, (yy_state_type current_state )); +static int yy_get_next_buffer FDECL(, (void )); +static void yy_fatal_error FDECL(, (yyconst char msg[] )) NORETURN; /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -395,7 +328,7 @@ static yyconst flex_int16_t yy_accept[196] = } ; -static yyconst flex_int32_t yy_ec[256] = +static yyconst YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, @@ -427,7 +360,7 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[49] = +static yyconst YY_CHAR yy_meta[49] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -436,7 +369,7 @@ static yyconst flex_int32_t yy_meta[49] = 1, 1, 1, 1, 1, 1, 1, 1 } ; -static yyconst flex_int16_t yy_base[198] = +static yyconst flex_uint16_t yy_base[198] = { 0, 0, 213, 218, 220, 215, 220, 213, 210, 207, 196, 190, 196, 37, 191, 197, 186, 188, 171, 164, 172, @@ -488,7 +421,7 @@ static yyconst flex_int16_t yy_def[198] = } ; -static yyconst flex_int16_t yy_nxt[269] = +static yyconst flex_uint16_t yy_nxt[269] = { 0, 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, 13, 14, 4, 4, 4, 4, 15, 4, 4, 4, @@ -568,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: 1449188839 2015/12/04 00:27:19 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */ +/* NetHack 3.6 dgn_comp.l $NHDT-Date: 1449385342 2015/12/06 07:02:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.16 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* Copyright (c) 1990 by M. Stephenson */ /* NetHack may be freely redistributed. See license for details. */ @@ -630,10 +563,12 @@ int FDECL(yyoutput, (int)); #define YY_NO_UNPUT #endif -#ifdef FLEX_SCANNER -#define YY_MALLOC_DECL \ - genericptr_t FDECL(malloc, (size_t)); \ - genericptr_t FDECL(realloc, (genericptr_t,size_t)); +#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) +/* older flex wants this */ +#define YY_MALLOC_DECL genericptr_t FDECL(malloc, (size_t)); \ + genericptr_t FDECL(realloc, (genericptr_t, size_t)); +/* newer flex assumes so needs this in case it's been suppressed */ +YY_MALLOC_DECL #endif void FDECL(init_yyin, (FILE *)); @@ -642,91 +577,68 @@ void FDECL(init_yyout, (FILE *)); /* this doesn't always get put in dgn_comp.h * (esp. when using older versions of bison) */ - extern YYSTYPE yylval; int nh_line_number = 1; #define INITIAL 0 -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); - /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy (void ); - -int yyget_debug (void ); - -void yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE yyget_extra (void ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *yyget_in (void ); - -void yyset_in (FILE * in_str ); - -FILE *yyget_out (void ); - -void yyset_out (FILE * out_str ); - -yy_size_t yyget_leng (void ); - -char *yyget_text (void ); - -int yyget_lineno (void ); - -void yyset_lineno (int line_number ); +int yylex_destroy FDECL(, (void )); +int yyget_debug FDECL(, (void )); +void yyset_debug FDECL(, (int debug_flag )); +YY_EXTRA_TYPE yyget_extra FDECL(, (void )); +void yyset_extra FDECL(, (YY_EXTRA_TYPE user_defined )); +FILE *yyget_in FDECL(, (void )); +void yyset_in FDECL(, (FILE * _in_str )); +FILE *yyget_out FDECL(, (void )); +void yyset_out FDECL(, (FILE * _out_str )); +yy_size_t yyget_leng FDECL(, (void )); +char *yyget_text FDECL(, (void )); +int yyget_lineno FDECL(, (void )); +void yyset_lineno FDECL(, (int _line_number )); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif +extern int yywrap FDECL(, (void )); #endif - static void yyunput (int c,char *buf_ptr ); +#ifndef YY_NO_UNPUT + +static void yyunput FDECL(, (int c,char *buf_ptr )); +#endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy FDECL(, (char *,yyconst char *,int )); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen FDECL(, (yyconst char * )); #endif #ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif +static int input FDECL(, (void )); #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -769,7 +681,6 @@ static int input (void ); clearerr(yyin); \ } \ }\ -\ #endif @@ -791,17 +702,15 @@ static int input (void ); #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif -/* end tables serialization structures and prototypes */ - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int yylex (void); +extern int yylex FDECL(, (void)); -#define YY_DECL int yylex (void) +#define YY_DECL int yylex () #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -813,7 +722,7 @@ extern int yylex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ @@ -826,9 +735,9 @@ extern int yylex (void); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; if ( !(yy_init) ) { @@ -856,7 +765,9 @@ YY_DECL yy_load_buffer_state( ); } - while ( 1 ) /* loops until end-of-file is reached */ + { + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); @@ -873,7 +784,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1187,6 +1098,7 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ + } /* end of user's declarations */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer @@ -1196,151 +1108,132 @@ case YY_STATE_EOF(INITIAL): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (void) +static int yy_get_next_buffer () { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + yy_size_t number_to_move, i; + int ret_val; - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); + if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1]) + YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed"); - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } + if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } + /* Try to read more data. */ - /* Try to read more data. */ + /* First move last chars to start of buffer. */ + number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + for (i = 0; i < number_to_move; ++i) + *(dest++) = *(source++); - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); + if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + } else { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + while (num_to_read <= 0) { + /* Not enough room in the buffer - grow it. */ - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ + if ( b->yy_is_our_buffer ) { + yy_size_t new_size = b->yy_buf_size * 2; - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; + if (! b->yy_ch_buf) + YY_FATAL_ERROR("fatal error - scanner input buffer overflow" ); - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); + } - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; + /* Read in more data. */ + YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } - } + if ((yy_n_chars) == 0) { + if (number_to_move == YY_MORE_ADJ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ); + } else { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; + } + } else + ret_val = EOB_ACT_CONTINUE_SCAN; - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; + if ((yy_size_t) ((yy_n_chars) + number_to_move) + > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) + yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if (! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) + YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()"); + } - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + return ret_val; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ +/* yy_get_previous_state - get the state just before EOB char was reached */ - static yy_state_type yy_get_previous_state (void) +static yy_state_type yy_get_previous_state () { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; yy_current_state = (yy_start); yy_current_state += YY_AT_BOL(); - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) { + + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1353,9 +1246,9 @@ static int yy_get_next_buffer (void) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } + } - return yy_current_state; + return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character @@ -1363,12 +1256,14 @@ static int yy_get_next_buffer (void) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 1; +static yy_state_type yy_try_NUL_trans (yy_current_state ) + yy_state_type yy_current_state; +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1386,9 +1281,13 @@ static int yy_get_next_buffer (void) return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, register char * yy_bp ) +#ifndef YY_NO_UNPUT + +static void yyunput (c,yy_bp ) + int c; + char * yy_bp; { - register char *yy_cp; + char *yy_cp; yy_cp = (yy_c_buf_p); @@ -1398,10 +1297,10 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register yy_size_t number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + yy_size_t number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = + char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -1423,13 +1322,10 @@ static int yy_get_next_buffer (void) (yy_c_buf_p) = yy_cp; } -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) #endif +#ifndef YY_NO_INPUT +static int input () { int c; @@ -1475,11 +1371,7 @@ static int yy_get_next_buffer (void) if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else return input(); -#endif } case EOB_ACT_CONTINUE_SCAN: @@ -1489,7 +1381,7 @@ static int yy_get_next_buffer (void) } } - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + c = *(uchar *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); @@ -1504,7 +1396,9 @@ static int yy_get_next_buffer (void) * * @note This function does not reset the start condition to @c INITIAL . */ - void yyrestart (FILE * input_file ) + +void yyrestart (input_file ) + FILE * input_file; { if ( ! YY_CURRENT_BUFFER ){ @@ -1521,14 +1415,15 @@ static int yy_get_next_buffer (void) * @param new_buffer The new input buffer. * */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +void yy_switch_to_buffer (new_buffer ) + YY_BUFFER_STATE new_buffer; { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); - */ + */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1552,7 +1447,7 @@ static int yy_get_next_buffer (void) (yy_did_buffer_switch_on_eof) = 1; } -static void yy_load_buffer_state (void) +static void yy_load_buffer_state () { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; @@ -1566,7 +1461,9 @@ static void yy_load_buffer_state (void) * * @return the allocated buffer state. */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +YY_BUFFER_STATE yy_create_buffer (file,size ) + FILE * file; + int size; { YY_BUFFER_STATE b; @@ -1574,7 +1471,7 @@ static void yy_load_buffer_state (void) if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = (yy_size_t)size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. @@ -1594,7 +1491,8 @@ static void yy_load_buffer_state (void) * @param b a buffer created with yy_create_buffer() * */ - void yy_delete_buffer (YY_BUFFER_STATE b ) +void yy_delete_buffer (b ) + YY_BUFFER_STATE b; { if ( ! b ) @@ -1613,8 +1511,9 @@ static void yy_load_buffer_state (void) * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - +static void yy_init_buffer (b,file ) + YY_BUFFER_STATE b; + FILE * file; { int oerrno = errno; @@ -1641,7 +1540,8 @@ static void yy_load_buffer_state (void) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ - void yy_flush_buffer (YY_BUFFER_STATE b ) +void yy_flush_buffer (b ) + YY_BUFFER_STATE b; { if ( ! b ) return; @@ -1670,7 +1570,8 @@ static void yy_load_buffer_state (void) * @param new_buffer The new state. * */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (new_buffer ) + YY_BUFFER_STATE new_buffer; { if (new_buffer == NULL) return; @@ -1700,7 +1601,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) * The next element becomes the new top. * */ -void yypop_buffer_state (void) +void yypop_buffer_state () { if (!YY_CURRENT_BUFFER) return; @@ -1719,56 +1620,60 @@ void yypop_buffer_state (void) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void yyensure_buffer_stack (void) +static void yyensure_buffer_stack () { - yy_size_t num_to_alloc; + yy_size_t num_to_alloc; - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. + if (!(yy_buffer_stack)) { + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } +#if 1 /* [PR] avoid C++-style comment; older C compilers choke on it */ + num_to_alloc = 2; /* also changed to match the comment... */ +#else + num_to_alloc = 1; // After all that talk, this was set to 1 anyways... +#endif + (yy_buffer_stack) = (struct yy_buffer_state**) + yyalloc(num_to_alloc * sizeof(struct yy_buffer_state*) ); + if (!(yy_buffer_stack)) + YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + (void) memset((yy_buffer_stack), 0, + num_to_alloc * sizeof(struct yy_buffer_state*)); - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) { + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**) + yyrealloc((yy_buffer_stack),num_to_alloc * sizeof(struct yy_buffer_state*) ); + if (!(yy_buffer_stack)) + YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); + + /* zero only the new slots.*/ + (void) memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, + grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } } -/** Setup the input buffer state to scan directly from a user-specified character buffer. +/** Setup the input buffer state to scan directly from a user-specified + * character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (base,size ) + char * base; + yy_size_t size; { YY_BUFFER_STATE b; @@ -1797,33 +1702,37 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) return b; } -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. +/** Setup the input buffer state to scan a string. The next call to yylex() + * will scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (yystr ) + yyconst char * yystr; { return yy_scan_bytes(yystr,strlen(yystr) ); } -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. +/** Setup the input buffer state to scan the given bytes. The next call to + * yylex() will scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param _yybytes_len the number of bytes in the buffer pointed to by @a + * bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (yybytes,_yybytes_len ) + yyconst char * yybytes; + yy_size_t _yybytes_len; { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; + yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; @@ -1852,9 +1761,10 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yy_fatal_error (msg ) + yyconst char* msg; { - (void) fprintf( stderr, "%s\n", msg ); + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -1862,25 +1772,23 @@ static void yy_fatal_error (yyconst char* msg ) #undef yyless #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) + YY_LESS_LINENO(yyless_macro_arg); \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. * */ -int yyget_lineno (void) +int yyget_lineno () { return yylineno; @@ -1889,7 +1797,7 @@ int yyget_lineno (void) /** Get the input stream. * */ -FILE *yyget_in (void) +FILE *yyget_in () { return yyin; } @@ -1897,7 +1805,7 @@ FILE *yyget_in (void) /** Get the output stream. * */ -FILE *yyget_out (void) +FILE *yyget_out () { return yyout; } @@ -1905,7 +1813,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -yy_size_t yyget_leng (void) +yy_size_t yyget_leng () { return yyleng; } @@ -1914,48 +1822,52 @@ yy_size_t yyget_leng (void) * */ -char *yyget_text (void) +char *yyget_text () { return yytext; } /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void yyset_lineno (int line_number ) +void yyset_lineno (_line_number ) + int _line_number; { - yylineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * * @see yy_switch_to_buffer */ -void yyset_in (FILE * in_str ) +void yyset_in (_in_str ) + FILE * _in_str; { - yyin = in_str ; + yyin = _in_str ; } -void yyset_out (FILE * out_str ) +void yyset_out (_out_str ) + FILE * _out_str; { - yyout = out_str ; + yyout = _out_str ; } -int yyget_debug (void) +int yyget_debug () { return yy_flex_debug; } -void yyset_debug (int bdebug ) +void yyset_debug (_bdebug ) + int _bdebug; { - yy_flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } -static int yy_init_globals (void) +static int yy_init_globals () { /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. @@ -1984,22 +1896,21 @@ static int yy_init_globals (void) } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) +int yylex_destroy () { /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } + while (YY_CURRENT_BUFFER) { + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ + /* Reset the globals. This is important in a non-reentrant scanner + * so the next time yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; @@ -2010,18 +1921,23 @@ int yylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (s1,s2,n ) + char* s1; + yyconst char * s2; + int n; { - register int i; + + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (s ) + yyconst char * s; { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -2029,13 +1945,18 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *yyalloc (yy_size_t size ) +void *yyalloc (size ) + yy_size_t size; { + return (void *) malloc( size ); } -void *yyrealloc (void * ptr, yy_size_t size ) +void *yyrealloc (ptr,size ) + void * ptr; + yy_size_t size; { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -2046,13 +1967,13 @@ void *yyrealloc (void * ptr, yy_size_t size ) return (void *) realloc( (char *) ptr, size ); } -void yyfree (void * ptr ) +void yyfree (ptr ) + void * ptr; { + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } -#define YYTABLES_NAME "yytables" - /* routine to switch to another input file; needed for flex */ void init_yyin( input_f ) @@ -2065,6 +1986,7 @@ FILE *input_f; #endif yyin = input_f; } + /* analogous routine (for completeness) */ void init_yyout( output_f ) diff --git a/sys/share/dgn_yacc.c b/sys/share/dgn_yacc.c index bac1441e9..9339fd578 100644 --- a/sys/share/dgn_yacc.c +++ b/sys/share/dgn_yacc.c @@ -11,7 +11,7 @@ #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" -/* NetHack 3.6 dgn_comp.y $NHDT-Date: 1449188840 2015/12/04 00:27:20 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */ +/* 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 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* Copyright (c) 1990 by M. Stephenson */ /* NetHack may be freely redistributed. See license for details. */ diff --git a/sys/share/lev_lex.c b/sys/share/lev_lex.c index dd76b8484..227649c74 100644 --- a/sys/share/lev_lex.c +++ b/sys/share/lev_lex.c @@ -3,110 +3,37 @@ #define YY_INT_ALIGNED short int -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. +/* A lexical scanner generated by flex via 'flex -S flexhack.skl' + * where flexhack.skl is a nethack-specific alternate skeleton derived + * from flex 2.6.0's skel.c (which in turn was generated from flex.skl). + * + * Support for C++, re-entrancy, and table serialization stripped out. + * NetHack's usage doesn't need them and we want to reduce the size and + * complexity of this skeleton as well as of the generated scanner code. */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif +#define FLEXHACK_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 0 -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; +#include "config.h" + +#include + +/* we don't care if actual types happen to have more bits than their names; + the tables will just take up more space, possibly slowing the parse; + still, allow config.h to override these via typedef+#define if desired */ +#ifndef FLEX_INT32_T typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +#endif +#ifndef FLEX_INT16_T +typedef short int flex_int16_t; +#endif +#ifndef FLEX_UINT16_T typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST #define yyconst const -#else -#define yyconst -#endif /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -116,7 +43,7 @@ typedef unsigned int flex_uint32_t; * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((unsigned int) (uchar) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less @@ -141,10 +68,19 @@ typedef unsigned int flex_uint32_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif -/* The state buf must be large enough to hold one state per character in the main buffer. +/* The state buf must be large enough to hold one state per character + * in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) @@ -159,35 +95,32 @@ typedef size_t yy_size_t; #endif extern yy_size_t yyleng; - extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - #define YY_LESS_LINENO(n) +#define YY_LESS_LINENO(n) +#define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) + YY_LESS_LINENO(yyless_macro_arg); \ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { +struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ @@ -222,8 +155,8 @@ struct yy_buffer_state */ int yy_at_bol; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. @@ -246,7 +179,7 @@ struct yy_buffer_state */ #define YY_BUFFER_EOF_PENDING 2 - }; +}; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ @@ -271,7 +204,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ yy_size_t yyleng; /* Points to current character in buffer. */ @@ -284,50 +217,47 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart (FILE *input_file ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); -void yy_delete_buffer (YY_BUFFER_STATE b ); -void yy_flush_buffer (YY_BUFFER_STATE b ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void yypop_buffer_state (void ); +void yyrestart FDECL(, (FILE *input_file )); +void yy_switch_to_buffer FDECL(, (YY_BUFFER_STATE new_buffer )); +YY_BUFFER_STATE yy_create_buffer FDECL(, (FILE *file,int size )); +void yy_delete_buffer FDECL(, (YY_BUFFER_STATE b )); +void yy_flush_buffer FDECL(, (YY_BUFFER_STATE b )); +void yypush_buffer_state FDECL(, (YY_BUFFER_STATE new_buffer )); +void yypop_buffer_state FDECL(, (void )); -static void yyensure_buffer_stack (void ); -static void yy_load_buffer_state (void ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack FDECL(, (void )); +static void yy_load_buffer_state FDECL(, (void )); +static void yy_init_buffer FDECL(, (YY_BUFFER_STATE b,FILE *file )); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer FDECL(, (char *base,yy_size_t size )); +YY_BUFFER_STATE yy_scan_string FDECL(, (yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes FDECL(, (yyconst char *bytes,yy_size_t len )); -void *yyalloc (yy_size_t ); -void *yyrealloc (void *,yy_size_t ); -void yyfree (void * ); +void *yyalloc FDECL(, (yy_size_t )); +void *yyrealloc FDECL(, (void *,yy_size_t )); +void yyfree FDECL(, (void * )); #define yy_new_buffer yy_create_buffer - #define yy_set_interactive(is_interactive) \ { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + if ( ! YY_CURRENT_BUFFER ) { \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + if ( ! YY_CURRENT_BUFFER ) { \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ @@ -343,12 +273,15 @@ extern int yylineno; int yylineno = 1; extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif #define yytext_ptr yytext -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state FDECL(, (void )); +static yy_state_type yy_try_NUL_trans FDECL(, (yy_state_type current_state )); +static int yy_get_next_buffer FDECL(, (void )); +static void yy_fatal_error FDECL(, (yyconst char msg[] )) NORETURN; /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. @@ -489,7 +422,7 @@ static yyconst flex_int16_t yy_accept[1057] = 198, 198, 48, 32, 44, 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static yyconst YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, @@ -521,7 +454,7 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[75] = +static yyconst YY_CHAR yy_meta[75] = { 0, 1, 2, 3, 2, 2, 1, 1, 2, 1, 1, 1, 2, 4, 2, 4, 1, 1, 1, 5, 5, @@ -533,7 +466,7 @@ static yyconst flex_int32_t yy_meta[75] = 6, 5, 6, 6 } ; -static yyconst flex_int16_t yy_base[1064] = +static yyconst flex_uint16_t yy_base[1064] = { 0, 0, 73, 102, 77, 1254, 1255, 75, 1255, 1250, 1235, 1244, 0, 1204, 1234, 1233, 78, 66, 1230, 1229, 1215, @@ -775,7 +708,7 @@ static yyconst flex_int16_t yy_def[1064] = 1056, 1056, 1056 } ; -static yyconst flex_int16_t yy_nxt[1330] = +static yyconst flex_uint16_t yy_nxt[1330] = { 0, 6, 7, 8, 9, 7, 10, 11, 6, 12, 6, 13, 14, 15, 6, 16, 17, 18, 19, 20, 21, @@ -1089,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: 1449188840 2015/12/04 00:27:20 $ $NHDT-Branch: master $:$NHDT-Revision: 1.22 $ */ +/* NetHack 3.6 lev_comp.l $NHDT-Date: 1449385344 2015/12/06 07:02:24 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.24 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -1149,10 +1082,12 @@ int FDECL(yyoutput, (int)); #define YY_NO_UNPUT #endif -#ifdef FLEX_SCANNER -#define YY_MALLOC_DECL \ - genericptr_t FDECL(malloc, (size_t)); \ - genericptr_t FDECL(realloc, (genericptr_t,size_t)); +#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) +/* older flex wants this */ +#define YY_MALLOC_DECL genericptr_t FDECL(malloc, (size_t)); \ + genericptr_t FDECL(realloc, (genericptr_t, size_t)); +/* newer flex assumes so needs this in case it's been suppressed */ +YY_MALLOC_DECL #endif void FDECL(init_yyin, (FILE *)); @@ -1192,84 +1127,62 @@ FILE *orig_yyin = NULL; #define INITIAL 0 #define MAPC 1 -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); - /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int yylex_destroy (void ); - -int yyget_debug (void ); - -void yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE yyget_extra (void ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *yyget_in (void ); - -void yyset_in (FILE * in_str ); - -FILE *yyget_out (void ); - -void yyset_out (FILE * out_str ); - -yy_size_t yyget_leng (void ); - -char *yyget_text (void ); - -int yyget_lineno (void ); - -void yyset_lineno (int line_number ); +int yylex_destroy FDECL(, (void )); +int yyget_debug FDECL(, (void )); +void yyset_debug FDECL(, (int debug_flag )); +YY_EXTRA_TYPE yyget_extra FDECL(, (void )); +void yyset_extra FDECL(, (YY_EXTRA_TYPE user_defined )); +FILE *yyget_in FDECL(, (void )); +void yyset_in FDECL(, (FILE * _in_str )); +FILE *yyget_out FDECL(, (void )); +void yyset_out FDECL(, (FILE * _out_str )); +yy_size_t yyget_leng FDECL(, (void )); +char *yyget_text FDECL(, (void )); +int yyget_lineno FDECL(, (void )); +void yyset_lineno FDECL(, (int _line_number )); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (void ); -#else -extern int yywrap (void ); -#endif +extern int yywrap FDECL(, (void )); #endif - static void yyunput (int c,char *buf_ptr ); +#ifndef YY_NO_UNPUT + +static void yyunput FDECL(, (int c,char *buf_ptr )); +#endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy FDECL(, (char *,yyconst char *,int )); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen FDECL(, (yyconst char * )); #endif #ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif +static int input FDECL(, (void )); #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1312,7 +1225,6 @@ static int input (void ); clearerr(yyin); \ } \ }\ -\ #endif @@ -1334,17 +1246,15 @@ static int input (void ); #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif -/* end tables serialization structures and prototypes */ - /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int yylex (void); +extern int yylex FDECL(, (void)); -#define YY_DECL int yylex (void) +#define YY_DECL int yylex () #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -1356,7 +1266,7 @@ extern int yylex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ @@ -1369,9 +1279,9 @@ extern int yylex (void); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; if ( !(yy_init) ) { @@ -1399,7 +1309,9 @@ YY_DECL yy_load_buffer_state( ); } - while ( 1 ) /* loops until end-of-file is reached */ + { + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); @@ -1416,7 +1328,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2438,151 +2350,132 @@ case YY_STATE_EOF(MAPC): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer (void) +static int yy_get_next_buffer () { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + yy_size_t number_to_move, i; + int ret_val; - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); + if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1]) + YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed"); - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } + if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) { + /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } else { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } + /* Try to read more data. */ - /* Try to read more data. */ + /* First move last chars to start of buffer. */ + number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + for (i = 0; i < number_to_move; ++i) + *(dest++) = *(source++); - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); + if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING) { + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + } else { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + while (num_to_read <= 0) { + /* Not enough room in the buffer - grow it. */ - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ + if ( b->yy_is_our_buffer ) { + yy_size_t new_size = b->yy_buf_size * 2; - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; - if ( b->yy_is_our_buffer ) - { - yy_size_t new_size = b->yy_buf_size * 2; + if (! b->yy_ch_buf) + YY_FATAL_ERROR("fatal error - scanner input buffer overflow" ); - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); + } - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; + /* Read in more data. */ + YY_INPUT((&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } - } + if ((yy_n_chars) == 0) { + if (number_to_move == YY_MORE_ADJ) { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ); + } else { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; + } + } else + ret_val = EOB_ACT_CONTINUE_SCAN; - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; + if ((yy_size_t) ((yy_n_chars) + number_to_move) + > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) + yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if (! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) + YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()"); + } - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; + return ret_val; } -/* yy_get_previous_state - get the state just before the EOB char was reached */ +/* yy_get_previous_state - get the state just before EOB char was reached */ - static yy_state_type yy_get_previous_state (void) +static yy_state_type yy_get_previous_state () { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; yy_current_state = (yy_start); yy_current_state += YY_AT_BOL(); - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + for (yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp) { + + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2595,9 +2488,9 @@ static int yy_get_next_buffer (void) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } + } - return yy_current_state; + return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character @@ -2605,12 +2498,14 @@ static int yy_get_next_buffer (void) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 1; +static yy_state_type yy_try_NUL_trans (yy_current_state ) + yy_state_type yy_current_state; +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2628,9 +2523,13 @@ static int yy_get_next_buffer (void) return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, register char * yy_bp ) +#ifndef YY_NO_UNPUT + +static void yyunput (c,yy_bp ) + int c; + char * yy_bp; { - register char *yy_cp; + char *yy_cp; yy_cp = (yy_c_buf_p); @@ -2640,10 +2539,10 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register yy_size_t number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + yy_size_t number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = + char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2665,13 +2564,10 @@ static int yy_get_next_buffer (void) (yy_c_buf_p) = yy_cp; } -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) #endif +#ifndef YY_NO_INPUT +static int input () { int c; @@ -2717,11 +2613,7 @@ static int yy_get_next_buffer (void) if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else return input(); -#endif } case EOB_ACT_CONTINUE_SCAN: @@ -2731,7 +2623,7 @@ static int yy_get_next_buffer (void) } } - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + c = *(uchar *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); @@ -2746,7 +2638,9 @@ static int yy_get_next_buffer (void) * * @note This function does not reset the start condition to @c INITIAL . */ - void yyrestart (FILE * input_file ) + +void yyrestart (input_file ) + FILE * input_file; { if ( ! YY_CURRENT_BUFFER ){ @@ -2763,14 +2657,15 @@ static int yy_get_next_buffer (void) * @param new_buffer The new input buffer. * */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +void yy_switch_to_buffer (new_buffer ) + YY_BUFFER_STATE new_buffer; { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); - */ + */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -2794,7 +2689,7 @@ static int yy_get_next_buffer (void) (yy_did_buffer_switch_on_eof) = 1; } -static void yy_load_buffer_state (void) +static void yy_load_buffer_state () { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; @@ -2808,7 +2703,9 @@ static void yy_load_buffer_state (void) * * @return the allocated buffer state. */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +YY_BUFFER_STATE yy_create_buffer (file,size ) + FILE * file; + int size; { YY_BUFFER_STATE b; @@ -2816,7 +2713,7 @@ static void yy_load_buffer_state (void) if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = (yy_size_t)size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. @@ -2836,7 +2733,8 @@ static void yy_load_buffer_state (void) * @param b a buffer created with yy_create_buffer() * */ - void yy_delete_buffer (YY_BUFFER_STATE b ) +void yy_delete_buffer (b ) + YY_BUFFER_STATE b; { if ( ! b ) @@ -2855,8 +2753,9 @@ static void yy_load_buffer_state (void) * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - +static void yy_init_buffer (b,file ) + YY_BUFFER_STATE b; + FILE * file; { int oerrno = errno; @@ -2883,7 +2782,8 @@ static void yy_load_buffer_state (void) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ - void yy_flush_buffer (YY_BUFFER_STATE b ) +void yy_flush_buffer (b ) + YY_BUFFER_STATE b; { if ( ! b ) return; @@ -2912,7 +2812,8 @@ static void yy_load_buffer_state (void) * @param new_buffer The new state. * */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (new_buffer ) + YY_BUFFER_STATE new_buffer; { if (new_buffer == NULL) return; @@ -2942,7 +2843,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) * The next element becomes the new top. * */ -void yypop_buffer_state (void) +void yypop_buffer_state () { if (!YY_CURRENT_BUFFER) return; @@ -2961,56 +2862,60 @@ void yypop_buffer_state (void) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void yyensure_buffer_stack (void) +static void yyensure_buffer_stack () { - yy_size_t num_to_alloc; + yy_size_t num_to_alloc; - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. + if (!(yy_buffer_stack)) { + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } +#if 1 /* [PR] avoid C++-style comment; older C compilers choke on it */ + num_to_alloc = 2; /* also changed to match the comment... */ +#else + num_to_alloc = 1; // After all that talk, this was set to 1 anyways... +#endif + (yy_buffer_stack) = (struct yy_buffer_state**) + yyalloc(num_to_alloc * sizeof(struct yy_buffer_state*) ); + if (!(yy_buffer_stack)) + YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + (void) memset((yy_buffer_stack), 0, + num_to_alloc * sizeof(struct yy_buffer_state*)); - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) { + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**) + yyrealloc((yy_buffer_stack),num_to_alloc * sizeof(struct yy_buffer_state*) ); + if (!(yy_buffer_stack)) + YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); + + /* zero only the new slots.*/ + (void) memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, + grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } } -/** Setup the input buffer state to scan directly from a user-specified character buffer. +/** Setup the input buffer state to scan directly from a user-specified + * character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (base,size ) + char * base; + yy_size_t size; { YY_BUFFER_STATE b; @@ -3039,28 +2944,32 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) return b; } -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. +/** Setup the input buffer state to scan a string. The next call to yylex() + * will scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (yystr ) + yyconst char * yystr; { return yy_scan_bytes(yystr,strlen(yystr) ); } -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. +/** Setup the input buffer state to scan the given bytes. The next call to + * yylex() will scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param _yybytes_len the number of bytes in the buffer pointed to by @a + * bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (yybytes,_yybytes_len ) + yyconst char * yybytes; + yy_size_t _yybytes_len; { YY_BUFFER_STATE b; char *buf; @@ -3094,9 +3003,10 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yy_fatal_error (msg ) + yyconst char* msg; { - (void) fprintf( stderr, "%s\n", msg ); + (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -3104,25 +3014,23 @@ static void yy_fatal_error (yyconst char* msg ) #undef yyless #define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ + do { \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) + YY_LESS_LINENO(yyless_macro_arg); \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. * */ -int yyget_lineno (void) +int yyget_lineno () { return yylineno; @@ -3131,7 +3039,7 @@ int yyget_lineno (void) /** Get the input stream. * */ -FILE *yyget_in (void) +FILE *yyget_in () { return yyin; } @@ -3139,7 +3047,7 @@ FILE *yyget_in (void) /** Get the output stream. * */ -FILE *yyget_out (void) +FILE *yyget_out () { return yyout; } @@ -3147,7 +3055,7 @@ FILE *yyget_out (void) /** Get the length of the current token. * */ -yy_size_t yyget_leng (void) +yy_size_t yyget_leng () { return yyleng; } @@ -3156,48 +3064,52 @@ yy_size_t yyget_leng (void) * */ -char *yyget_text (void) +char *yyget_text () { return yytext; } /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void yyset_lineno (int line_number ) +void yyset_lineno (_line_number ) + int _line_number; { - yylineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * * @see yy_switch_to_buffer */ -void yyset_in (FILE * in_str ) +void yyset_in (_in_str ) + FILE * _in_str; { - yyin = in_str ; + yyin = _in_str ; } -void yyset_out (FILE * out_str ) +void yyset_out (_out_str ) + FILE * _out_str; { - yyout = out_str ; + yyout = _out_str ; } -int yyget_debug (void) +int yyget_debug () { return yy_flex_debug; } -void yyset_debug (int bdebug ) +void yyset_debug (_bdebug ) + int _bdebug; { - yy_flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } -static int yy_init_globals (void) +static int yy_init_globals () { /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. @@ -3226,22 +3138,21 @@ static int yy_init_globals (void) } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (void) +int yylex_destroy () { /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(); - } + while (YY_CURRENT_BUFFER) { + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; - /* Destroy the stack itself. */ - yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ + /* Reset the globals. This is important in a non-reentrant scanner + * so the next time yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; @@ -3252,18 +3163,23 @@ int yylex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (s1,s2,n ) + char* s1; + yyconst char * s2; + int n; { - register int i; + + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (s ) + yyconst char * s; { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -3271,13 +3187,18 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *yyalloc (yy_size_t size ) +void *yyalloc (size ) + yy_size_t size; { + return (void *) malloc( size ); } -void *yyrealloc (void * ptr, yy_size_t size ) +void *yyrealloc (ptr,size ) + void * ptr; + yy_size_t size; { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -3288,13 +3209,13 @@ void *yyrealloc (void * ptr, yy_size_t size ) return (void *) realloc( (char *) ptr, size ); } -void yyfree (void * ptr ) +void yyfree (ptr ) + void * ptr; { + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } -#define YYTABLES_NAME "yytables" - #ifdef AMIGA long * alloc(n) diff --git a/sys/share/lev_yacc.c b/sys/share/lev_yacc.c index 77379b87f..62e1f2042 100644 --- a/sys/share/lev_yacc.c +++ b/sys/share/lev_yacc.c @@ -11,7 +11,7 @@ #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" -/* NetHack 3.6 lev_comp.y $NHDT-Date: 1449188841 2015/12/04 00:27:21 $ $NHDT-Branch: master $:$NHDT-Revision: 1.19 $ */ +/* 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 may be freely redistributed. See license for details. */ diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index b1b032250..0276d61f8 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pcmain.c $NHDT-Date: 1449116934 2015/12/03 04:28:54 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.66 $ */ +/* NetHack 3.6 pcmain.c $NHDT-Date: 1449116336 2015/12/03 04:18:56 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.66 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ diff --git a/sys/unix/Makefile.utl b/sys/unix/Makefile.utl index ef1a496da..d5d30426b 100644 --- a/sys/unix/Makefile.utl +++ b/sys/unix/Makefile.utl @@ -1,5 +1,5 @@ # Makefile for NetHack's utility programs. -# NetHack 3.6 Makefile.utl $NHDT-Date: 1448711183 2015/11/28 11:46:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ +# NetHack 3.6 Makefile.utl $NHDT-Date: 1449386560 2015/12/06 07:22:40 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.27 $ # Root of source tree: NHSROOT=.. @@ -235,13 +235,19 @@ lev_lex.o: lev_lex.c $(HACK_H) ../include/lev_comp.h ../include/sp_lev.h lev_yacc.c: lev_comp.y $(YACC) $(YACCDIST) -d lev_comp.y - sed -e 's#"$(YTABC)"#"$@"#' $(YTABC) > $@ && rm $(YTABC) + sed -e 's#"$(YTABC)"#"$@"#' -e 's#$(YTABC):#$@:#' $(YTABC) > $@ \ + && rm $(YTABC) sed -e 's#"$(YTABH)"#"lev_comp.h"#' $(YTABH) > ../include/lev_comp.h \ && rm $(YTABH) lev_lex.c: lev_comp.l $(LEX) $(FLEXDIST) lev_comp.l - sed -e 's#"$(LEXYYC)"#"$@"#' $(LEXYYC) > $@ && rm $(LEXYYC) + sed -e 's#"$(LEXYYC)"#"$@"#' -e 's# *$$##' $(LEXYYC) > $@ \ + && rm $(LEXYYC) +# note: flex code construction using m4 macros results in some trailing +# spaces; is basic RE substitute for +# and we don't bother stripping trailing tabs because that gets messy; +# make expands into which is RE end-of-line. # with all of extern.h's functions to complain about, we drown in # 'defined but not used' without -u @@ -267,13 +273,16 @@ dgn_lex.o: dgn_lex.c $(CONFIG_H) ../include/dgn_comp.h ../include/dgn_file.h dgn_yacc.c: dgn_comp.y $(YACC) $(YACCDIST) -d dgn_comp.y - sed -e 's#"$(YTABC)"#"$@"#' $(YTABC) > $@ && rm $(YTABC) + sed -e 's#"$(YTABC)"#"$@"#' -e 's#$(YTABC):#$@:#' $(YTABC) > $@ \ + && rm $(YTABC) sed -e 's#"$(YTABH)"#"dgn_comp.h"#' $(YTABH) > ../include/dgn_comp.h \ && rm $(YTABH) dgn_lex.c: dgn_comp.l $(LEX) $(FLEXDIST) dgn_comp.l - sed -e 's#"$(LEXYYC)"#"$@"#' $(LEXYYC) > $@ && rm $(LEXYYC) + sed -e 's#"$(LEXYYC)"#"$@"#' -e 's# *$$##' $(LEXYYC) > $@ \ + && rm $(LEXYYC) +# note: is basic RE substitute for # with all of extern.h's functions to complain about, we drown in # 'defined but not used' without -u diff --git a/util/dgn_comp.l b/util/dgn_comp.l index 73c7054f9..a18b5fefc 100644 --- a/util/dgn_comp.l +++ b/util/dgn_comp.l @@ -1,5 +1,5 @@ %{ -/* NetHack 3.6 dgn_comp.l $NHDT-Date: 1448710672 2015/11/28 11:37:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */ +/* NetHack 3.6 dgn_comp.l $NHDT-Date: 1449385184 2015/12/06 06:59:44 $ $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. */ @@ -61,20 +61,20 @@ int FDECL(yyoutput, (int)); #define YY_NO_UNPUT #endif -#ifdef FLEX_SCANNER -#define YY_MALLOC_DECL \ - genericptr_t FDECL(malloc, (size_t)); \ - genericptr_t FDECL(realloc, (genericptr_t,size_t)); +#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) +/* older flex wants this */ +#define YY_MALLOC_DECL genericptr_t FDECL(malloc, (size_t)); \ + genericptr_t FDECL(realloc, (genericptr_t, size_t)); +/* newer flex assumes so needs this in case it's been suppressed */ +YY_MALLOC_DECL #endif - void FDECL(init_yyin, (FILE *)); void FDECL(init_yyout, (FILE *)); /* this doesn't always get put in dgn_comp.h * (esp. when using older versions of bison) */ - extern YYSTYPE yylval; int nh_line_number = 1; @@ -131,6 +131,7 @@ FILE *input_f; #endif yyin = input_f; } + /* analogous routine (for completeness) */ void init_yyout( output_f ) diff --git a/util/lev_comp.l b/util/lev_comp.l index 44805e0ef..c70c48148 100644 --- a/util/lev_comp.l +++ b/util/lev_comp.l @@ -1,5 +1,5 @@ %{ -/* NetHack 3.6 lev_comp.l $NHDT-Date: 1448710678 2015/11/28 11:37:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.21 $ */ +/* NetHack 3.6 lev_comp.l $NHDT-Date: 1449385191 2015/12/06 06:59:51 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.22 $ */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -59,10 +59,12 @@ int FDECL(yyoutput, (int)); #define YY_NO_UNPUT #endif -#ifdef FLEX_SCANNER -#define YY_MALLOC_DECL \ - genericptr_t FDECL(malloc, (size_t)); \ - genericptr_t FDECL(realloc, (genericptr_t,size_t)); +#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER) +/* older flex wants this */ +#define YY_MALLOC_DECL genericptr_t FDECL(malloc, (size_t)); \ + genericptr_t FDECL(realloc, (genericptr_t, size_t)); +/* newer flex assumes so needs this in case it's been suppressed */ +YY_MALLOC_DECL #endif void FDECL(init_yyin, (FILE *)); diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index b5612d804..593131ad5 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mswproc.c $NHDT-Date: 1449116947 2015/12/03 04:29:07 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.93 $ */ +/* NetHack 3.6 mswproc.c $NHDT-Date: 1449116670 2015/12/03 04:24:30 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.94 $ */ /* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */