[BACK]Return to arch.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / make

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/make/arch.c between version 1.53 and 1.54

version 1.53, 2006/10/27 21:00:18 version 1.54, 2008/02/14 22:11:20
Line 257  Arch_ParseArchive(char **linePtr, Lst no
Line 257  Arch_ParseArchive(char **linePtr, Lst no
              * Variable spec, so call the Var module to parse the puppy               * Variable spec, so call the Var module to parse the puppy
              * so we can safely advance beyond it...               * so we can safely advance beyond it...
              */               */
             int         length;              size_t      length;
             void        *freeIt;              void        *freeIt;
             char        *result;              char        *result;
   
Line 298  Arch_ParseArchive(char **linePtr, Lst no
Line 298  Arch_ParseArchive(char **linePtr, Lst no
                  * Variable spec, so call the Var module to parse the puppy                   * Variable spec, so call the Var module to parse the puppy
                  * so we can safely advance beyond it...                   * so we can safely advance beyond it...
                  */                   */
                 int     length;                  size_t  length;
                 void    *freeIt;                  void    *freeIt;
                 char    *result;                  char    *result;
   
Line 526  ArchStatMember(char *archive, char *memb
Line 526  ArchStatMember(char *archive, char *memb
 {  {
 #define AR_MAX_NAME_LEN     (sizeof(arh.ar_name)-1)  #define AR_MAX_NAME_LEN     (sizeof(arh.ar_name)-1)
     FILE *        arch;       /* Stream to archive */      FILE *        arch;       /* Stream to archive */
     int           size;       /* Size of archive member */      size_t        size;       /* Size of archive member */
     char          *cp;        /* Useful character pointer */      char          *cp;        /* Useful character pointer */
     char          magic[SARMAG];      char          magic[SARMAG];
     LstNode       ln;         /* Lst member containing archive descriptor */      LstNode       ln;         /* Lst member containing archive descriptor */
Line 617  ArchStatMember(char *archive, char *memb
Line 617  ArchStatMember(char *archive, char *memb
     Hash_InitTable(&ar->members, -1);      Hash_InitTable(&ar->members, -1);
     memName[AR_MAX_NAME_LEN] = '\0';      memName[AR_MAX_NAME_LEN] = '\0';
   
     while (fread((char *)&arh, sizeof(struct ar_hdr), 1, arch) == 1) {      while (fread(&arh, sizeof(struct ar_hdr), 1, arch) == 1) {
         if (strncmp( arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {          if (strncmp( arh.ar_fmag, ARFMAG, sizeof(arh.ar_fmag)) != 0) {
             /*              /*
              * The header is bogus, so the archive is bad               * The header is bogus, so the archive is bad
Line 632  ArchStatMember(char *archive, char *memb
Line 632  ArchStatMember(char *archive, char *memb
              * 'size' field of the header and round it up during the seek.               * 'size' field of the header and round it up during the seek.
              */               */
             arh.ar_size[sizeof(arh.ar_size)-1] = '\0';              arh.ar_size[sizeof(arh.ar_size)-1] = '\0';
             size = (int)strtol(arh.ar_size, NULL, 10);              size = (size_t)strtol(arh.ar_size, NULL, 10);
   
             (void)strncpy(memName, arh.ar_name, sizeof(arh.ar_name));              (void)strncpy(memName, arh.ar_name, sizeof(arh.ar_name));
             for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {              for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) {
Line 671  ArchStatMember(char *archive, char *memb
Line 671  ArchStatMember(char *archive, char *memb
             if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&              if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
                 isdigit((unsigned char)memName[sizeof(AR_EFMT1) - 1])) {                  isdigit((unsigned char)memName[sizeof(AR_EFMT1) - 1])) {
   
                 unsigned int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);                  long elen = atol(&memName[sizeof(AR_EFMT1)-1]);
   
                 if (elen > MAXPATHLEN)                  if (elen > MAXPATHLEN)
                         goto badarch;                          goto badarch;
                 if (fread(memName, elen, 1, arch) != 1)                  if (fread(memName, (size_t)elen, (size_t)1, arch) != 1)
                         goto badarch;                          goto badarch;
                 memName[elen] = '\0';                  memName[elen] = '\0';
                 fseek(arch, -elen, SEEK_CUR);                  fseek(arch, -elen, SEEK_CUR);
Line 689  ArchStatMember(char *archive, char *memb
Line 689  ArchStatMember(char *archive, char *memb
             Hash_SetValue(he, emalloc(sizeof(struct ar_hdr)));              Hash_SetValue(he, emalloc(sizeof(struct ar_hdr)));
             memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));              memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
         }          }
         fseek(arch, (size + 1) & ~1, SEEK_CUR);          fseek(arch, (long)((size + 1) & ~1), SEEK_CUR);
     }      }
   
     fclose(arch);      fclose(arch);
Line 883  ArchFindMember(char *archive, char *memb
Line 883  ArchFindMember(char *archive, char *memb
         tlen = sizeof(arhPtr->ar_name);          tlen = sizeof(arhPtr->ar_name);
     }      }
   
     while (fread((char *)arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {      while (fread(arhPtr, sizeof(struct ar_hdr), 1, arch) == 1) {
         if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof(arhPtr->ar_fmag) ) != 0) {          if (strncmp(arhPtr->ar_fmag, ARFMAG, sizeof(arhPtr->ar_fmag) ) != 0) {
              /*               /*
               * The header is bogus, so the archive is bad                * The header is bogus, so the archive is bad
Line 909  ArchFindMember(char *archive, char *memb
Line 909  ArchFindMember(char *archive, char *memb
                  * the file at the actual member, rather than its header, but                   * the file at the actual member, rather than its header, but
                  * not here...                   * not here...
                  */                   */
                 fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);                  fseek(arch, -(long)sizeof(struct ar_hdr), SEEK_CUR);
                 return (arch);                  return (arch);
             }              }
         } else          } else
Line 922  ArchFindMember(char *archive, char *memb
Line 922  ArchFindMember(char *archive, char *memb
                                         sizeof(AR_EFMT1) - 1) == 0 &&                                          sizeof(AR_EFMT1) - 1) == 0 &&
                 isdigit((unsigned char)arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) {                  isdigit((unsigned char)arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) {
   
                 unsigned int elen = atoi(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);                  long elen = atol(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);
                 char ename[MAXPATHLEN + 1];                  char ename[MAXPATHLEN + 1];
   
                 if (elen > MAXPATHLEN) {                  if (elen > MAXPATHLEN) {
                         fclose(arch);                          fclose(arch);
                         return NULL;                          return NULL;
                 }                  }
                 if (fread(ename, elen, 1, arch) != 1) {                  if (fread(ename, (size_t)elen, (size_t)1, arch) != 1) {
                         fclose(arch);                          fclose(arch);
                         return NULL;                          return NULL;
                 }                  }
                 ename[elen] = '\0';                  ename[elen] = '\0';
                 if (DEBUG(ARCH) || DEBUG(MAKE)) {                  if (DEBUG(ARCH) || DEBUG(MAKE)) {
                     fprintf(debug_file, "ArchFind: Extended format entry for %s\n", ename);                      (void)fprintf(debug_file,
                           "ArchFind: Extended format entry for %s\n", ename);
                 }                  }
                 if (strncmp(ename, member, len) == 0) {                  if (strncmp(ename, member, len) == 0) {
                         /* Found as extended name */                          /* Found as extended name */
                         fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);                          (void)fseek(arch, (long)(-sizeof(struct ar_hdr) - elen),
                               SEEK_CUR);
                         return (arch);                          return (arch);
                 }                  }
                 fseek(arch, -elen, SEEK_CUR);                  (void)fseek(arch, -elen, SEEK_CUR);
                 goto skip;                  goto skip;
         } else          } else
 #endif  #endif
Line 956  skip:
Line 958  skip:
              * header and round it up during the seek.               * header and round it up during the seek.
              */               */
             arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';              arhPtr->ar_size[sizeof(arhPtr->ar_size)-1] = '\0';
             size = (int)strtol(arhPtr->ar_size, NULL, 10);              size = (size_t)strtol(arhPtr->ar_size, NULL, 10);
             fseek(arch, (size + 1) & ~1, SEEK_CUR);              (void)fseek(arch, (long)((size + 1) & ~1), SEEK_CUR);
         }          }
     }      }
   
Line 1001  Arch_Touch(GNode *gn)
Line 1003  Arch_Touch(GNode *gn)
         free(p1);          free(p1);
     if (p2)      if (p2)
         free(p2);          free(p2);
     snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);      (void)snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
   
     if (arch != NULL) {      if (arch != NULL) {
         (void)fwrite((char *)&arh, sizeof(struct ar_hdr), 1, arch);          (void)fwrite(&arh, sizeof(struct ar_hdr), 1, arch);
         fclose(arch);          (void)fclose(arch);
     }      }
 }  }
   
Line 1029  Arch_Touch(GNode *gn)
Line 1031  Arch_Touch(GNode *gn)
  */   */
 void  void
 #if !defined(RANLIBMAG)  #if !defined(RANLIBMAG)
   /*ARGSUSED*/
 Arch_TouchLib(GNode *gn __unused)  Arch_TouchLib(GNode *gn __unused)
 #else  #else
 Arch_TouchLib(GNode *gn)  Arch_TouchLib(GNode *gn)
Line 1135  Arch_MemMTime(GNode *gn)
Line 1138  Arch_MemMTime(GNode *gn)
             nameEnd = strchr(nameStart, ')');              nameEnd = strchr(nameStart, ')');
   
             if ((pgn->flags & REMAKE) &&              if ((pgn->flags & REMAKE) &&
                 strncmp(nameStart, gn->name, nameEnd - nameStart) == 0) {                  strncmp(nameStart, gn->name,
                                      gn->mtime = Arch_MTime(pgn);                  (size_t)(nameEnd - nameStart)) == 0) {
                        gn->mtime = Arch_MTime(pgn);
             }              }
         } else if (pgn->flags & REMAKE) {          } else if (pgn->flags & REMAKE) {
             /*              /*

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

CVSweb <webmaster@jp.NetBSD.org>