From: dyer@rtsg.mot.com (Bill Dyer)
Subject: Diff for mapit.c
Summary: Here is the diff for mapit.c
Keywords: mapit, diff
Organization: Motorola Inc., Cellular Infrastructure Group
Date: Tue, 17 Nov 1992 22:37:56 GMT

Here is a diff that makes mapit much more friendly.  It solves
a couple of pointer problems and a toupper problem.  This diff
should be applied to the original mapit.c that was in the mapit
1.2 distribution that appeared here.   I have run this program on 
my Sun 3/60 and nowhere else.  I will be trying it on my PC
(dos) tonight.

This is a nifty program, much better than my illegible  scribbles
that usually end up on the map.  I highly recommend it to anyone
who plays diplo on the judge.  Of course you can simulate the 
judge output and use it for any diplo game.

Later,

-Bill

*** mapit.old	Tue Sep 15 13:54:11 1992
--- mapit.c	Tue Nov 17 16:30:43 1992
***************
*** 70,77 ****
  */
  #include <stdio.h>
  #include <string.h>
! #include <stdlib.h>
  
  #define MIN(x,y) (x<y?x:y)
  
  #define MAXNAMES 500
--- 70,79 ----
  */
  #include <stdio.h>
  #include <string.h>
! #include <ctype.h>
  
+ extern char *strstr(char *,char *);
+ 
  #define MIN(x,y) (x<y?x:y)
  
  #define MAXNAMES 500
***************
*** 190,196 ****
      
  
  #define DEADLINE "HAS A DEADLINE OF"
!     if (strstr(copy,DEADLINE,strlen(DEADLINE)) != NULL) {
        strcpy(message,line);
        continue;
      }
--- 192,198 ----
      
  
  #define DEADLINE "HAS A DEADLINE OF"
!     if (strstr(copy,DEADLINE) != NULL) {
        strcpy(message,line);
        continue;
      }
***************
*** 339,345 ****
    char *p0,*p1,*p2;             /* some char pointers */
    int i,j,k;                    /* misc counters */
  
!   char *country;
    char unit;                    /* unit type, "A" or "F" */
    int order;                    /* one of the following: */
    int si,di,di2;                /* index of source and destination location(s) */
--- 341,347 ----
    char *p0,*p1,*p2;             /* some char pointers */
    int i,j,k;                    /* misc counters */
  
!   char country[BUFSIZ];
    char unit;                    /* unit type, "A" or "F" */
    int order;                    /* one of the following: */
    int si,di,di2;                /* index of source and destination location(s) */
***************
*** 371,377 ****
    }
    unitcount = 0;
  
!   country = "unknown";
    ordernum = 0;
    graphicnum = 0;
    error = 0;
--- 373,379 ----
    }
    unitcount = 0;
  
!   strcpy(country,"unknown");
    ordernum = 0;
    graphicnum = 0;
    error = 0;
***************
*** 1146,1152 ****
    char *p0,*p1,*p2;             /* some char pointers */
    int i,j,k;                    /* misc counters */
  
!   char *country;
    char unit;                    /* unit type, "A" or "F" */
    int order;                    /* one of the following: */
    int si;                       /* index of source location) */
--- 1148,1154 ----
    char *p0,*p1,*p2;             /* some char pointers */
    int i,j,k;                    /* misc counters */
  
!   char country[BUFSIZ];
    char unit;                    /* unit type, "A" or "F" */
    int order;                    /* one of the following: */
    int si;                       /* index of source location) */
***************
*** 1164,1170 ****
    }
    unitcount = 0;
  
!   country = "unknown";
    ordernum = 0;
    error = 0;
    while ( gets(line) ) {
--- 1166,1172 ----
    }
    unitcount = 0;
  
!   strcpy(country,"unknown");
    ordernum = 0;
    error = 0;
    while ( gets(line) ) {
***************
*** 1363,1369 ****
  drawnew()
  {
    int i,j,k;
!   char *country;
  
    if (unitcount==0)
      return;
--- 1365,1371 ----
  drawnew()
  {
    int i,j,k;
!   char country[BUFSIZ];
  
    if (unitcount==0)
      return;
***************
*** 1371,1380 ****
    qsort(units,unitcount,sizeof(struct unitstruct),country_compare);
  
    /* run though twice, once to draw units, and once to draw order list */
!   country = "unknown";
    for (i=0; i<unitcount; ++i) {
      if (strcmp(country,units[i].country)) {
!       country = units[i].country;
        printf("%s\n",country);
      }
      if (units[i].loc>0)
--- 1373,1382 ----
    qsort(units,unitcount,sizeof(struct unitstruct),country_compare);
  
    /* run though twice, once to draw units, and once to draw order list */
!   strcpy(country,"unknown");
    for (i=0; i<unitcount; ++i) {
      if (strcmp(country,units[i].country)) {
!       strcpy(country,units[i].country);
        printf("%s\n",country);
      }
      if (units[i].loc>0)
***************
*** 1384,1393 ****
    }
  
    printf("OrderReport\n");
!   country = "unknown";
    for (i=0; i<unitcount; ++i) {
      if (strcmp(country,units[i].country)) {
!       country = units[i].country;
        printf("(%s) WriteOrder\n",country);
      }
      if (units[i].loc>0)
--- 1386,1395 ----
    }
  
    printf("OrderReport\n");
!   strcpy(country,"unknown");
    for (i=0; i<unitcount; ++i) {
      if (strcmp(country,units[i].country)) {
!       strcpy(country,units[i].country);
        printf("(%s) WriteOrder\n",country);
      }
      if (units[i].loc>0)
***************
*** 1413,1419 ****
--- 1415,1424 ----
        }
      } else {
        white = 0;
+       if (islower(*s2))
        	*(s1++) = toupper(*s2);
+       else
+       	*(s1++) = *s2;
      }
    }
    *s1 = '\0';


-- 
_____________________________________________________________________
|  I am not a .sig, but I play    |Bill Dyer  (708) 632-7081        |
|  one on the net.                | dyer@rtsg.mot.com  (work)       |
|                                 | or p00112@mail.psi.net (home)   |
Newsgroups: rec.games.diplomacy