~ubuntu-branches/ubuntu/precise/rpm/precise-proposed

« back to all changes in this revision

Viewing changes to lib/rpmrc.c

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-06-28 11:12:30 UTC
  • mfrom: (17.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100628111230-8ggjjhgpvrnr3ybx
Tags: 4.8.1-5
Fix compilation on hurd and kfreebsd (Closes: #587366).

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
    int i;
161
161
 
162
162
    for (i = 0; i < cache->size; i++)
163
 
        if (!strcmp(cache->cache[i].name, key)) return cache->cache + i;
 
163
        if (rstreq(cache->cache[i].name, key)) return cache->cache + i;
164
164
 
165
165
    return NULL;
166
166
}
337
337
        return RPMRC_FAIL;
338
338
    }
339
339
 
340
 
        /* LCL: s != NULL here. */
341
340
    tnum = strtoul(s, &s1, 10);
342
341
    if ((*s1) || (s1 == s) || (tnum == ULONG_MAX)) {
343
342
        rpmlog(RPMLOG_ERR, _("Bad arch/os number: %s (%s:%d)\n"), s,
392
391
{
393
392
    while (tableLen) {
394
393
        tableLen--;
395
 
        if (strcmp(name, table[tableLen].name))
 
394
        if (!rstreq(name, table[tableLen].name))
396
395
            continue;
397
396
        return &(table[tableLen]);
398
397
    }
406
405
{
407
406
    while (tableLen) {
408
407
        tableLen--;
409
 
        if (table[tableLen].name && !strcmp(name, table[tableLen].name))
 
408
        if (table[tableLen].name && rstreq(name, table[tableLen].name))
410
409
            return table[tableLen].defName;
411
410
    }
412
411
 
546
545
 
547
546
            /* Only add macros if appropriate for this arch */
548
547
            if (option->macroize &&
549
 
              (arch == NULL || !strcmp(arch, current[ARCH]))) {
 
548
              (arch == NULL || rstreq(arch, current[ARCH]))) {
550
549
                char *n, *name;
551
550
                n = name = xmalloc(strlen(option->name)+2);
552
551
                if (option->localize)
565
564
            gotit = 0;
566
565
 
567
566
            for (i = 0; i < RPM_MACHTABLE_COUNT; i++) {
568
 
                if (!strncmp(tables[i].key, s, strlen(tables[i].key)))
 
567
                if (rstreqn(tables[i].key, s, strlen(tables[i].key)))
569
568
                    break;
570
569
            }
571
570
 
573
572
                const char *rest = s + strlen(tables[i].key);
574
573
                if (*rest == '_') rest++;
575
574
 
576
 
                if (!strcmp(rest, "compat")) {
 
575
                if (rstreq(rest, "compat")) {
577
576
                    if (machCompatCacheAdd(se, fn, linenum,
578
577
                                                &tables[i].cache))
579
578
                        goto exit;
580
579
                    gotit = 1;
581
580
                } else if (tables[i].hasTranslate &&
582
 
                           !strcmp(rest, "translate")) {
 
581
                           rstreq(rest, "translate")) {
583
582
                    if (addDefault(&tables[i].defaults,
584
583
                                   &tables[i].defaultsLength,
585
584
                                   se, fn, linenum))
586
585
                        goto exit;
587
586
                    gotit = 1;
588
587
                } else if (tables[i].hasCanon &&
589
 
                           !strcmp(rest, "canon")) {
 
588
                           rstreq(rest, "canon")) {
590
589
                    if (addCanon(&tables[i].canons, &tables[i].canonsLength,
591
590
                                 se, fn, linenum))
592
591
                        goto exit;
819
818
        for (i=0; i<4; i++)
820
819
                vendor[8+i] = (unsigned char) (ecx >>(8*i));
821
820
                
822
 
        if (strncmp(vendor, "AuthenticAMD", 12) != 0)  
 
821
        if (!rstreqn(vendor, "AuthenticAMD", 12))  
823
822
                return 0;
824
823
 
825
824
        return 1;
834
833
    *((unsigned int *)&vendor[0]) = ebx;
835
834
    *((unsigned int *)&vendor[4]) = edx;
836
835
    *((unsigned int *)&vendor[8]) = ecx;
837
 
    if (strncmp(vendor, "GenuineIntel", 12) != 0)
 
836
    if (!rstreqn(vendor, "GenuineIntel", 12))
838
837
        return 0;
839
838
    cpuid(1, &eax, &ebx, &ecx, &edx);
840
839
    family = (eax >> 8) & 0x0f;
873
872
    *((unsigned int *)&vendor[0]) = ebx;
874
873
    *((unsigned int *)&vendor[4]) = edx;
875
874
    *((unsigned int *)&vendor[8]) = ecx;
876
 
    if (strncmp(vendor, "GenuineIntel", 12) != 0)
 
875
    if (!rstreqn(vendor, "GenuineIntel", 12))
877
876
        return 0;
878
877
    cpuid(1, &eax, &ebx, &ecx, &edx);
879
878
    family = (eax >> 8) & 0x0f;
905
904
    *((unsigned int *)&vendor[0]) = ebx;
906
905
    *((unsigned int *)&vendor[4]) = edx;
907
906
    *((unsigned int *)&vendor[8]) = ecx;
908
 
    if (strncmp(vendor, "AuthenticAMD", 12) != 0)  
 
907
    if (!rstreqn(vendor, "AuthenticAMD", 12))
909
908
        return 0;
910
909
    cpuid(1, &eax, &ebx, &ecx, &edx);
911
910
    family = (eax >> 8) & 0x0f;
966
965
         */
967
966
        strncpy(un.sysname, "SINIX", sizeof(un.sysname));
968
967
#endif
969
 
        if (!strcmp(un.sysname, "AIX")) {
 
968
        if (rstreq(un.sysname, "AIX")) {
970
969
            strcpy(un.machine, __power_pc() ? "ppc" : "rs6000");
971
970
            sprintf(un.sysname,"aix%s.%s", un.version, un.release);
972
971
        }
973
 
        else if(!strcmp(un.sysname, "Darwin")) { 
 
972
        else if(rstreq(un.sysname, "Darwin")) { 
974
973
#ifdef __ppc__
975
974
            strcpy(un.machine, "ppc");
976
975
#else ifdef __i386__
977
976
            strcpy(un.machine, "i386");
978
977
#endif 
979
978
        }
980
 
        else if (!strcmp(un.sysname, "SunOS")) {
981
 
            if (!strncmp(un.release,"4", 1)) /* SunOS 4.x */ {
 
979
        else if (rstreq(un.sysname, "SunOS")) {
 
980
            if (rstreqn(un.release,"4", 1)) /* SunOS 4.x */ {
982
981
                int fd;
983
982
                for (fd = 0;
984
983
                    (un.release[fd] != 0 && (fd < sizeof(un.release)));
998
997
            /* Solaris on Intel hardware reports i86pc instead of i386
999
998
             * (at least on 2.6 and 2.8)
1000
999
             */
1001
 
            if (!strcmp(un.machine, "i86pc"))
 
1000
            if (rstreq(un.machine, "i86pc"))
1002
1001
                sprintf(un.machine, "i386");
1003
1002
        }
1004
 
        else if (!strcmp(un.sysname, "HP-UX"))
 
1003
        else if (rstreq(un.sysname, "HP-UX"))
1005
1004
            /*make un.sysname look like hpux9.05 for example*/
1006
1005
            sprintf(un.sysname, "hpux%s", strpbrk(un.release, "123456789"));
1007
 
        else if (!strcmp(un.sysname, "OSF1"))
 
1006
        else if (rstreq(un.sysname, "OSF1"))
1008
1007
            /*make un.sysname look like osf3.2 for example*/
1009
1008
            sprintf(un.sysname, "osf%s", strpbrk(un.release, "123456789"));
1010
 
        else if (!strncmp(un.sysname, "IP", 2))
 
1009
        else if (rstreqn(un.sysname, "IP", 2))
1011
1010
            un.sysname[2] = '\0';
1012
 
        else if (!strncmp(un.sysname, "SINIX", 5)) {
 
1011
        else if (rstreqn(un.sysname, "SINIX", 5)) {
1013
1012
            sprintf(un.sysname, "sinix%s",un.release);
1014
 
            if (!strncmp(un.machine, "RM", 2))
 
1013
            if (rstreqn(un.machine, "RM", 2))
1015
1014
                sprintf(un.machine, "mips");
1016
1015
        }
1017
 
        else if ((!strncmp(un.machine, "34", 2) ||
1018
 
                !strncmp(un.machine, "33", 2)) && \
1019
 
                !strncmp(un.release, "4.0", 3))
 
1016
        else if ((rstreqn(un.machine, "34", 2) ||
 
1017
                rstreqn(un.machine, "33", 2)) && \
 
1018
                rstreqn(un.release, "4.0", 3))
1020
1019
        {
1021
1020
            /* we are on ncr-sysv4 */
1022
1021
            char * prelid = NULL;
1099
1098
#       endif   /* hpux */
1100
1099
 
1101
1100
#       if defined(__linux__) && defined(__sparc__)
1102
 
        if (!strcmp(un.machine, "sparc")) {
 
1101
        if (rstreq(un.machine, "sparc")) {
1103
1102
            #define PERS_LINUX          0x00000000
1104
1103
            #define PERS_LINUX_32BIT    0x00800000
1105
1104
            #define PERS_LINUX32        0x00000008
1111
1110
            if (oldpers != -1) {
1112
1111
                if (personality(PERS_LINUX) != -1) {
1113
1112
                    uname(&un);
1114
 
                    if (! strcmp(un.machine, "sparc64")) {
 
1113
                    if (rstreq(un.machine, "sparc64")) {
1115
1114
                        strcpy(un.machine, "sparcv9");
1116
1115
                        oldpers = PERS_LINUX32;
1117
1116
                    }
1194
1193
    if (arch) {
1195
1194
        next = &values[var];
1196
1195
        while (next) {
1197
 
            if (next->arch && !strcmp(next->arch, arch)) return next->value;
 
1196
            if (next->arch && rstreq(next->arch, arch)) return next->value;
1198
1197
            next = next->next;
1199
1198
        }
1200
1199
    }
1217
1216
    if (next->value) {
1218
1217
        if (arch) {
1219
1218
            while (next->next) {
1220
 
                if (next->arch && !strcmp(next->arch, arch)) break;
 
1219
                if (next->arch && rstreq(next->arch, arch)) break;
1221
1220
                next = next->next;
1222
1221
            }
1223
1222
        } else {
1227
1226
            }
1228
1227
        }
1229
1228
 
1230
 
        if (next->arch && arch && !strcmp(next->arch, arch)) {
 
1229
        if (next->arch && arch && rstreq(next->arch, arch)) {
1231
1230
            next->value = _free(next->value);
1232
1231
            next->arch = _free(next->arch);
1233
1232
        } else if (next->arch || arch) {
1272
1271
    canonEntry canon = lookupInCanonTable(name,
1273
1272
                        tables[RPM_MACHTABLE_INSTARCH].canons,
1274
1273
                        tables[RPM_MACHTABLE_INSTARCH].canonsLength);
1275
 
    return (canon != NULL || strcmp(name, "noarch") == 0);
 
1274
    return (canon != NULL || rstreq(name, "noarch"));
1276
1275
}
1277
1276
 
1278
1277
/** \ingroup rpmrc
1310
1309
    }
1311
1310
    if (os == NULL) return;     /* XXX can't happen */
1312
1311
 
1313
 
    if (!current[ARCH] || strcmp(arch, current[ARCH])) {
 
1312
    if (!current[ARCH] || !rstreq(arch, current[ARCH])) {
1314
1313
        current[ARCH] = _free(current[ARCH]);
1315
1314
        current[ARCH] = xstrdup(arch);
1316
1315
        rebuildCompatTables(ARCH, host_cpu);
1317
1316
    }
1318
1317
 
1319
 
    if (!current[OS] || strcmp(os, current[OS])) {
 
1318
    if (!current[OS] || !rstreq(os, current[OS])) {
1320
1319
        char * t = xstrdup(os);
1321
1320
        current[OS] = _free(current[OS]);
1322
1321
        /*
1327
1326
         * XXX used by rpmInstallPackage->{os,arch}Okay->rpmMachineScore->
1328
1327
         * XXX to verify correct arch/os from headers.
1329
1328
         */
1330
 
        if (!strcmp(t, "linux"))
 
1329
        if (rstreq(t, "linux"))
1331
1330
            *t = 'L';
1332
1331
        current[OS] = t;
1333
1332
        
1424
1423
    if (ca == NULL) {
1425
1424
        const char *a = NULL;
1426
1425
        defaultMachine(&a, NULL);
1427
 
        ca = (a) ? xstrdup(a) : NULL;
 
1426
        ca = xstrdup(a ? a : "(arch)");
1428
1427
    }
1429
1428
    for (x = 0; ca[x] != '\0'; x++)
1430
1429
        ca[x] = rtolower(ca[x]);
1432
1431
    if (co == NULL) {
1433
1432
        const char *o = NULL;
1434
1433
        defaultMachine(NULL, &o);
1435
 
        co = (o) ? xstrdup(o) : NULL;
 
1434
        co = xstrdup(o ? o : "(os)");
1436
1435
    }
1437
1436
    for (x = 0; co[x] != '\0'; x++)
1438
1437
        co[x] = rtolower(co[x]);