tgetopt bug fixed under Win32 - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 445c533b2ee5fa5f4f33fbf0b88b1a21bd75c213
 (DIR) parent c451c6daf36b5469b39ef5ea9cf43e00bdf78363
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Wed, 11 Apr 2001 03:27:51 +0000
       
       getopt bug fixed under Win32
       
       
       Diffstat:
         M src/dopeos.c                        |      18 +++++++++++-------
         M src/dopewars.c                      |      20 ++++++++++++++------
         M src/winmain.c                       |       2 ++
       
       3 files changed, 27 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/src/dopeos.c b/src/dopeos.c
       t@@ -194,22 +194,26 @@ int apos=0;
        int getopt(int argc,char *argv[],char *str) {
           int i,c;
           char *pt;
       -   if (apos>=argc) return EOF;
       -   if (argv[apos] && argv[apos][0]=='-') {
       +   while (apos<argc && argv[apos]) {
       +      if (argv[apos][0]!='-') { apos++; return 0; }
              for (i=1;i<strlen(argv[apos]);i++) {
                 c=argv[apos][i];
                 pt=index(str,c);
                 if (pt) {
       -            if (*(pt+1)==':' && apos<argc-1) {
       -               optarg=argv[apos+1]; argv[apos+1]=NULL;
       -            }
                    argv[apos][i]='-';
       +            if (*(pt+1)==':') {
       +               if (apos+1<argc && i==strlen(argv[apos])-1) {
       +                  apos++;
       +                  optarg=argv[apos];
       +                  apos++;
       +               } else return 0;
       +            }
                    return c;
                 }
              }
       +      apos++;
           }
       -   apos++;
       -   return 0;
       +   return EOF;
        }
        
        void sigemptyset(int *mask) {}
 (DIR) diff --git a/src/dopewars.c b/src/dopewars.c
       t@@ -1589,16 +1589,23 @@ void SetupParameters() {
        /* Now read in the global configuration file */
           ReadConfigFile("/etc/dopewars");
        
       -/* Finally, try to read in the .dopewars file in the user's home directory */
       +/* Next, try to read in the .dopewars file in the user's home directory */
           pt=getenv("HOME");
       -   if (!pt) return;
       -   ConfigFile=g_strdup_printf("%s/.dopewars",pt);
       -   ReadConfigFile(ConfigFile);
       -   g_free(ConfigFile);
       +   if (pt) {
       +      ConfigFile=g_strdup_printf("%s/.dopewars",pt);
       +      ReadConfigFile(ConfigFile);
       +      g_free(ConfigFile);
       +   }
       +
       +#ifdef CYGWIN
       +/* Finally, try dopewars-config.txt in the current directory (Windows
       +   systems only) */
       +   ReadConfigFile("dopewars-config.txt");
       +#endif
        }
        
        void HandleHelpTexts() {
       -   g_print("dopewars version %s\n",VERSION);
       +   g_print(_("dopewars version %s\n"),VERSION);
           if (!WantHelp) return;
        
           g_print(
       t@@ -1644,6 +1651,7 @@ void HandleCmdLine(int argc,char *argv[]) {
                 case 'a': WantAntique=1; WantNetwork=0; break;
                 case 'v': WantVersion=1; break;
                 case 'h':
       +         case  0 :
                 case '?': WantHelp=1; break;
                 case 'f': AssignName(&HiScoreFile,optarg); break;
                 case 'o': AssignName(&ServerName,optarg); break;
 (DIR) diff --git a/src/winmain.c b/src/winmain.c
       t@@ -74,8 +74,10 @@ int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
           g_strfreev(split);
           if (WantVersion || WantHelp) {
              AllocConsole();
       +      g_set_print_handler(Win32PrintFunc);
              HandleHelpTexts();
              newterm(NULL,NULL,NULL);
       +      g_print(_("Press any key..."));
              bgetch();
           } else {
              StartNetworking();