Ignore:
Timestamp:
Mar 31, 2018, 1:27:52 AM (7 years ago)
Author:
bird
Message:

kmk_cp: use getopt_r and stop using global and static variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/cp.c

    r3192 r3221  
    6060 */
    6161
     62
     63/*********************************************************************************************************************************
     64*   Header Files                                                                                                                 *
     65*********************************************************************************************************************************/
     66#define FAKES_NO_GETOPT_H /* bird */
    6267#include "config.h"
    6368#include <sys/types.h>
     
    7378#include <string.h>
    7479#include <unistd.h>
    75 #include "getopt.h"
     80#include "getopt_r.h"
    7681#include "k/kDefs.h"
    7782#ifdef _MSC_VER
     
    8792
    8893
     94/*********************************************************************************************************************************
     95*   Defined Constants And Macros                                                                                                 *
     96*********************************************************************************************************************************/
    8997#ifndef S_IFWHT
    9098#define S_IFWHT 0
     
    116124}
    117125
     126/*********************************************************************************************************************************
     127*   Structures and Typedefs                                                                                                      *
     128*********************************************************************************************************************************/
     129typedef struct CPINSTANCE
     130{
     131        CPUTILSINSTANCE Utils;
     132        int Rflag, rflag;
     133        int cp_ignore_non_existing, cp_changed_only;
     134        KBUILDPROTECTION g_ProtData;
     135} CPINSTANCE;
     136
    118137/* have wrappers for globals in cp_extern! */
    119138
    120 static KBUILDPROTECTION g_ProtData;
    121 const char *cp_argv0;
    122 static char emptystring[] = "";
    123 
    124 PATH_T to = { to.p_path, emptystring, "" };
    125 
    126 int fflag, iflag, nflag, pflag, vflag;
    127 static int Rflag, rflag;
    128 volatile sig_atomic_t info;
    129 static int cp_ignore_non_existing, cp_changed_only;
    130139
    131140enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
    132141
     142
     143/*********************************************************************************************************************************
     144*   Global Variables                                                                                                             *
     145*********************************************************************************************************************************/
    133146enum cp_arg {
    134147    CP_OPT_HELP = 261,
     
    142155    CP_OPT_PROTECTION_DEPTH
    143156};
     157
    144158static struct option long_options[] =
    145159{
     
    156170};
    157171
    158 
    159 static int copy(PKMKBUILTINCTX pCtx, char *[], enum op, int);
     172static char emptystring[] = "";
     173
     174#if defined(SIGINFO) && defined(KMK_BUILTIN_STANDALONE)
     175volatile sig_atomic_t g_cp_info;
     176#endif
     177
     178
     179/*********************************************************************************************************************************
     180*   Internal Functions                                                                                                           *
     181*********************************************************************************************************************************/
     182static int copy(CPINSTANCE *pThis, char * const *, enum op, int);
     183#ifdef FTSCALL
     184static int FTSCALL mastercmp(const FTSENT * const *, const FTSENT * const *);
     185#else
    160186static int mastercmp(const FTSENT **, const FTSENT **);
    161 #ifdef SIGINFO
     187#endif
     188#if defined(SIGINFO) && defined(KMK_BUILTIN_STANDALONE)
    162189static void siginfo(int __unused);
    163190#endif
     
    167194kmk_builtin_cp(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx)
    168195{
     196        CPINSTANCE This;
     197        struct getopt_state_r gos;
    169198        struct stat to_stat, tmp_stat;
    170199        enum op type;
     
    173202
    174203        /* init globals */
    175         cp_argv0 = argv[0];
    176         to.p_end = to.p_path;
    177         to.target_end = emptystring;
    178         memset(to.p_path, 0, sizeof(to.p_path));
    179         fflag = iflag = nflag = pflag = vflag = Rflag = rflag = 0;
    180         info = 0;
    181         cp_ignore_non_existing = cp_changed_only = 0;
    182         kBuildProtectionInit(&g_ProtData, pCtx);
    183 
    184         /* reset getopt and set progname. */
    185         opterr = 1;
    186         optarg = NULL;
    187         optopt = 0;
    188         optind = 0; /* init */
     204        This.Utils.pCtx = pCtx;
     205        This.Utils.to.p_end = This.Utils.to.p_path;
     206        This.Utils.to.target_end = emptystring;
     207        memset(This.Utils.to.p_path, 0, sizeof(This.Utils.to.p_path));
     208        This.Utils.fflag = 0;
     209        This.Utils.iflag = 0;
     210        This.Utils.nflag = 0;
     211        This.Utils.pflag = 0;
     212        This.Utils.vflag = 0;
     213        This.Rflag = 0;
     214        This.rflag = 0;
     215        This.cp_ignore_non_existing = This.cp_changed_only = 0;
     216        kBuildProtectionInit(&This.g_ProtData, pCtx);
    189217
    190218        Hflag = Lflag = Pflag = 0;
    191         while ((ch = getopt_long(argc, argv, "HLPRfinprv", long_options, NULL)) != -1)
     219        getopt_initialize_r(&gos, argc, argv, "HLPRfinprv", long_options, envp, pCtx);
     220        while ((ch = getopt_long_r(&gos, NULL)) != -1)
    192221                switch (ch) {
    193222                case 'H':
     
    204233                        break;
    205234                case 'R':
    206                         Rflag = 1;
     235                        This.Rflag = 1;
    207236                        break;
    208237                case 'f':
    209                         fflag = 1;
    210                         iflag = nflag = 0;
     238                        This.Utils.fflag = 1;
     239                        This.Utils.iflag = This.Utils.nflag = 0;
    211240                        break;
    212241                case 'i':
    213                         iflag = 1;
    214                         fflag = nflag = 0;
     242                        This.Utils.iflag = 1;
     243                        This.Utils.fflag = This.Utils.nflag = 0;
    215244                        break;
    216245                case 'n':
    217                         nflag = 1;
    218                         fflag = iflag = 0;
     246                        This.Utils.nflag = 1;
     247                        This.Utils.fflag = This.Utils.iflag = 0;
    219248                        break;
    220249                case 'p':
    221                         pflag = 1;
     250                        This.Utils.pflag = 1;
    222251                        break;
    223252                case 'r':
    224                         rflag = 1;
     253                        This.rflag = 1;
    225254                        break;
    226255                case 'v':
    227                         vflag = 1;
     256                        This.Utils.vflag = 1;
    228257                        break;
    229258                case CP_OPT_HELP:
    230259                        usage(pCtx, 0);
    231                         kBuildProtectionTerm(&g_ProtData);
     260                        kBuildProtectionTerm(&This.g_ProtData);
    232261                        return 0;
    233262                case CP_OPT_VERSION:
    234                         kBuildProtectionTerm(&g_ProtData);
     263                        kBuildProtectionTerm(&This.g_ProtData);
    235264                        return kbuild_version(argv[0]);
    236265                case CP_OPT_IGNORE_NON_EXISTING:
    237                         cp_ignore_non_existing = 1;
     266                        This.cp_ignore_non_existing = 1;
    238267                        break;
    239268                case CP_OPT_CHANGED:
    240                         cp_changed_only = 1;
     269                        This.cp_changed_only = 1;
    241270                        break;
    242271                case CP_OPT_DISABLE_PROTECTION:
    243                         kBuildProtectionDisable(&g_ProtData, KBUILDPROTECTIONTYPE_RECURSIVE);
     272                        kBuildProtectionDisable(&This.g_ProtData, KBUILDPROTECTIONTYPE_RECURSIVE);
    244273                        break;
    245274                case CP_OPT_ENABLE_PROTECTION:
    246                         kBuildProtectionEnable(&g_ProtData, KBUILDPROTECTIONTYPE_RECURSIVE);
     275                        kBuildProtectionEnable(&This.g_ProtData, KBUILDPROTECTIONTYPE_RECURSIVE);
    247276                        break;
    248277                case CP_OPT_ENABLE_FULL_PROTECTION:
    249                         kBuildProtectionEnable(&g_ProtData, KBUILDPROTECTIONTYPE_FULL);
     278                        kBuildProtectionEnable(&This.g_ProtData, KBUILDPROTECTIONTYPE_FULL);
    250279                        break;
    251280                case CP_OPT_DISABLE_FULL_PROTECTION:
    252                         kBuildProtectionDisable(&g_ProtData, KBUILDPROTECTIONTYPE_FULL);
     281                        kBuildProtectionDisable(&This.g_ProtData, KBUILDPROTECTIONTYPE_FULL);
    253282                        break;
    254283                case CP_OPT_PROTECTION_DEPTH:
    255                         if (kBuildProtectionSetDepth(&g_ProtData, optarg)) {
    256                                 kBuildProtectionTerm(&g_ProtData);
     284                        if (kBuildProtectionSetDepth(&This.g_ProtData, gos.optarg)) {
     285                                kBuildProtectionTerm(&This.g_ProtData);
    257286                                return 1;
    258287                        }
    259288                        break;
    260289                default:
    261                         kBuildProtectionTerm(&g_ProtData);
     290                        kBuildProtectionTerm(&This.g_ProtData);
    262291                        return usage(pCtx, 1);
    263292                }
    264         argc -= optind;
    265         argv += optind;
     293        argc -= gos.optind;
     294        argv += gos.optind;
    266295
    267296        if (argc < 2) {
    268                 kBuildProtectionTerm(&g_ProtData);
     297                kBuildProtectionTerm(&This.g_ProtData);
    269298                return usage(pCtx, 1);
    270299        }
    271300
    272301        fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
    273         if (rflag) {
    274                 if (Rflag) {
    275                         kBuildProtectionTerm(&g_ProtData);
     302        if (This.rflag) {
     303                if (This.Rflag) {
     304                        kBuildProtectionTerm(&This.g_ProtData);
    276305                        return errx(pCtx, 1,
    277306                    "the -R and -r options may not be specified together.");
     
    283312                fts_options |= FTS_LOGICAL;
    284313        }
    285         if (Rflag) {
     314        if (This.Rflag) {
    286315                if (Hflag)
    287316                        fts_options |= FTS_COMFOLLOW;
     
    294323                fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
    295324        }
    296 #ifdef SIGINFO
     325#if defined(SIGINFO) && defined(KMK_BUILTIN_STANDALONE)
    297326        (void)signal(SIGINFO, siginfo);
    298327#endif
     
    300329        /* Save the target base in "to". */
    301330        target = argv[--argc];
    302         if (strlcpy(to.p_path, target, sizeof(to.p_path)) >= sizeof(to.p_path)) {
    303                 kBuildProtectionTerm(&g_ProtData);
     331        if (strlcpy(This.Utils.to.p_path, target, sizeof(This.Utils.to.p_path)) >= sizeof(This.Utils.to.p_path)) {
     332                kBuildProtectionTerm(&This.g_ProtData);
    304333                return errx(pCtx, 1, "%s: name too long", target);
    305334        }
    306         to.p_end = to.p_path + strlen(to.p_path);
    307         if (to.p_path == to.p_end) {
    308                 *to.p_end++ = '.';
    309                 *to.p_end = 0;
     335        This.Utils.to.p_end = This.Utils.to.p_path + strlen(This.Utils.to.p_path);
     336        if (This.Utils.to.p_path == This.Utils.to.p_end) {
     337                *This.Utils.to.p_end++ = '.';
     338                *This.Utils.to.p_end = 0;
    310339        }
    311         have_trailing_slash = IS_SLASH(to.p_end[-1]);
     340        have_trailing_slash = IS_SLASH(This.Utils.to.p_end[-1]);
    312341        if (have_trailing_slash)
    313                 STRIP_TRAILING_SLASH(to);
    314         to.target_end = to.p_end;
     342                STRIP_TRAILING_SLASH(This.Utils.to);
     343        This.Utils.to.target_end = This.Utils.to.p_end;
    315344
    316345        /* Set end of argument list for fts(3). */
     
    331360         * In (2), the real target is not directory, but "directory/source".
    332361         */
    333         r = stat(to.p_path, &to_stat);
     362        r = stat(This.Utils.to.p_path, &to_stat);
    334363        if (r == -1 && errno != ENOENT) {
    335                 kBuildProtectionTerm(&g_ProtData);
    336                 return err(pCtx, 1, "stat: %s", to.p_path);
     364                kBuildProtectionTerm(&This.g_ProtData);
     365                return err(pCtx, 1, "stat: %s", This.Utils.to.p_path);
    337366        }
    338367        if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
     
    341370                 */
    342371                if (argc > 1) {
    343                         kBuildProtectionTerm(&g_ProtData);
     372                        kBuildProtectionTerm(&This.g_ProtData);
    344373                        return usage(pCtx, 1);
    345374                }
     
    352381                 */
    353382                if (r == -1) {
    354                         if (rflag || (Rflag && (Lflag || Hflag)))
     383                        if (This.rflag || (This.Rflag && (Lflag || Hflag)))
    355384                                stat(*argv, &tmp_stat);
    356385                        else
    357386                                lstat(*argv, &tmp_stat);
    358387
    359                         if (S_ISDIR(tmp_stat.st_mode) && (Rflag || rflag))
     388                        if (S_ISDIR(tmp_stat.st_mode) && (This.Rflag || This.rflag))
    360389                                type = DIR_TO_DNE;
    361390                        else
     
    365394
    366395                if (have_trailing_slash && type == FILE_TO_FILE) {
    367                         kBuildProtectionTerm(&g_ProtData);
     396                        kBuildProtectionTerm(&This.g_ProtData);
    368397                        if (r == -1)
    369398                                return errx(pCtx, 1, "directory %s does not exist",
    370                                             to.p_path);
     399                                            This.Utils.to.p_path);
    371400                        else
    372                                 return errx(pCtx, 1, "%s is not a directory", to.p_path);
     401                                return errx(pCtx, 1, "%s is not a directory", This.Utils.to.p_path);
    373402                }
    374403        } else
     
    380409        /* Finally, check that the "to" directory isn't protected. */
    381410        rc = 1;
    382         if (!kBuildProtectionScanEnv(&g_ProtData, envp, "KMK_CP_")
    383          && !kBuildProtectionEnforce(&g_ProtData,
    384                                      Rflag || rflag
     411        if (!kBuildProtectionScanEnv(&This.g_ProtData, envp, "KMK_CP_")
     412         && !kBuildProtectionEnforce(&This.g_ProtData,
     413                                     This.Rflag || This.rflag
    385414                                     ? KBUILDPROTECTIONTYPE_RECURSIVE
    386415                                     : KBUILDPROTECTIONTYPE_FULL,
    387                                      to.p_path)) {
    388             rc = copy(pCtx, argv, type, fts_options);
     416                                     This.Utils.to.p_path)) {
     417            rc = copy(&This, argv, type, fts_options);
    389418        }
    390419
    391         kBuildProtectionTerm(&g_ProtData);
     420        kBuildProtectionTerm(&This.g_ProtData);
    392421        return rc;
    393422}
     
    402431
    403432static int
    404 copy(PKMKBUILTINCTX pCtx, char *argv[], enum op type, int fts_options)
     433copy(CPINSTANCE *pThis, char * const *argv, enum op type, int fts_options)
    405434{
    406435        struct stat to_stat;
     
    420449
    421450        if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
    422                 return err(pCtx, 1, "fts_open");
     451                return err(pThis->Utils.pCtx, 1, "fts_open");
    423452        for (badcp = rval = 0; (curr = fts_read(ftsp)) != NULL; badcp = 0) {
    424453                int copied = 0;
     
    426455                switch (curr->fts_info) {
    427456                case FTS_NS:
    428                         if (   cp_ignore_non_existing
     457                        if (   pThis->cp_ignore_non_existing
    429458                            && curr->fts_errno == ENOENT) {
    430                                 if (vflag) {
    431                                         warnx(pCtx, "fts: %s: %s", curr->fts_path,
     459                                if (pThis->Utils.vflag) {
     460                                        warnx(pThis->Utils.pCtx, "fts: %s: %s", curr->fts_path,
    432461                                              strerror(curr->fts_errno));
    433462                                }
     
    437466                case FTS_DNR:
    438467                case FTS_ERR:
    439                         warnx(pCtx, "fts: %s: %s",
     468                        warnx(pThis->Utils.pCtx, "fts: %s: %s",
    440469                            curr->fts_path, strerror(curr->fts_errno));
    441470                        badcp = rval = 1;
    442471                        continue;
    443472                case FTS_DC:                    /* Warn, continue. */
    444                         warnx(pCtx, "%s: directory causes a cycle", curr->fts_path);
     473                        warnx(pThis->Utils.pCtx, "%s: directory causes a cycle", curr->fts_path);
    445474                        badcp = rval = 1;
    446475                        continue;
     
    492521                        p = &curr->fts_path[base];
    493522                        nlen = curr->fts_pathlen - base;
    494                         target_mid = to.target_end;
     523                        target_mid = pThis->Utils.to.target_end;
    495524                        if (!IS_SLASH(*p) && !IS_SLASH(target_mid[-1]))
    496525                                *target_mid++ = '/';
    497526                        *target_mid = 0;
    498                         if (target_mid - to.p_path + nlen >= PATH_MAX) {
    499                                 warnx(pCtx, "%s%s: name too long (not copied)",
    500                                     to.p_path, p);
     527                        if (target_mid - pThis->Utils.to.p_path + nlen >= PATH_MAX) {
     528                                warnx(pThis->Utils.pCtx, "%s%s: name too long (not copied)",
     529                                    pThis->Utils.to.p_path, p);
    501530                                badcp = rval = 1;
    502531                                continue;
    503532                        }
    504533                        (void)strncat(target_mid, p, nlen);
    505                         to.p_end = target_mid + nlen;
    506                         *to.p_end = 0;
    507                         STRIP_TRAILING_SLASH(to);
     534                        pThis->Utils.to.p_end = target_mid + nlen;
     535                        *pThis->Utils.to.p_end = 0;
     536                        STRIP_TRAILING_SLASH(pThis->Utils.to);
    508537                }
    509538
     
    525554                         * normally want to preserve them on directories.
    526555                         */
    527                         if (pflag) {
    528                                 if (setfile(pCtx, curr->fts_statp, -1))
     556                        if (pThis->Utils.pflag) {
     557                                if (copy_file_attribs(&pThis->Utils, curr->fts_statp, -1))
    529558                                    rval = 1;
    530559                        } else {
     
    532561                                if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
    533562                                    ((mode | S_IRWXU) & mask) != (mode & mask))
    534                                         if (chmod(to.p_path, mode & mask) != 0){
    535                                                 warn(pCtx, "chmod: %s", to.p_path);
     563                                        if (chmod(pThis->Utils.to.p_path, mode & mask) != 0){
     564                                                warn(pThis->Utils.pCtx, "chmod: %s", pThis->Utils.to.p_path);
    536565                                                rval = 1;
    537566                                        }
     
    541570
    542571                /* Not an error but need to remember it happened */
    543                 if (stat(to.p_path, &to_stat) == -1)
     572                if (stat(pThis->Utils.to.p_path, &to_stat) == -1)
    544573                        dne = 1;
    545574                else {
     
    548577                            to_stat.st_ino == curr->fts_statp->st_ino &&
    549578                            to_stat.st_ino != 0) {
    550                                 warnx(pCtx, "%s and %s are identical (not copied).",
    551                                     to.p_path, curr->fts_path);
     579                                warnx(pThis->Utils.pCtx, "%s and %s are identical (not copied).",
     580                                    pThis->Utils.to.p_path, curr->fts_path);
    552581                                badcp = rval = 1;
    553582                                if (S_ISDIR(curr->fts_statp->st_mode))
     
    557586                        if (!S_ISDIR(curr->fts_statp->st_mode) &&
    558587                            S_ISDIR(to_stat.st_mode)) {
    559                                 warnx(pCtx, "cannot overwrite directory %s with "
     588                                warnx(pThis->Utils.pCtx, "cannot overwrite directory %s with "
    560589                                    "non-directory %s",
    561                                     to.p_path, curr->fts_path);
     590                                    pThis->Utils.to.p_path, curr->fts_path);
    562591                                badcp = rval = 1;
    563592                                continue;
     
    573602                            ((fts_options & FTS_COMFOLLOW) &&
    574603                            curr->fts_level == 0)) {
    575                                 if (copy_file(pCtx, curr, dne, cp_changed_only, &copied))
     604                                if (copy_file(&pThis->Utils, curr, dne, pThis->cp_changed_only, &copied))
    576605                                        badcp = rval = 1;
    577606                        } else {
    578                                 if (copy_link(pCtx, curr, !dne))
     607                                if (copy_link(&pThis->Utils, curr, !dne))
    579608                                        badcp = rval = 1;
    580609                        }
     
    582611#endif
    583612                case S_IFDIR:
    584                         if (!Rflag && !rflag) {
    585                                 warnx(pCtx, "%s is a directory (not copied).",
     613                        if (!pThis->Rflag && !pThis->rflag) {
     614                                warnx(pThis->Utils.pCtx, "%s is a directory (not copied).",
    586615                                    curr->fts_path);
    587616                                (void)fts_set(ftsp, curr, FTS_SKIP);
     
    598627                         */
    599628                        if (dne) {
    600                                 if (mkdir(to.p_path,
     629                                if (mkdir(pThis->Utils.to.p_path,
    601630                                    curr->fts_statp->st_mode | S_IRWXU) < 0)
    602                                         return err(pCtx, 1, "mkdir: %s", to.p_path);
     631                                        return err(pThis->Utils.pCtx, 1, "mkdir: %s", pThis->Utils.to.p_path);
    603632                        } else if (!S_ISDIR(to_stat.st_mode)) {
    604633                                errno = ENOTDIR;
    605                                 return err(pCtx, 1, "to-mode: %s", to.p_path);
     634                                return err(pThis->Utils.pCtx, 1, "to-mode: %s", pThis->Utils.to.p_path);
    606635                        }
    607636                        /*
     
    610639                         * directory, or if the -p flag is in effect.
    611640                         */
    612                         curr->fts_number = pflag || dne;
     641                        curr->fts_number = pThis->Utils.pflag || dne;
    613642                        break;
    614643#ifdef S_IFBLK
     
    616645#endif
    617646                case S_IFCHR:
    618                         if (Rflag) {
    619                                 if (copy_special(pCtx, curr->fts_statp, !dne))
     647                        if (pThis->Rflag) {
     648                                if (copy_special(&pThis->Utils, curr->fts_statp, !dne))
    620649                                        badcp = rval = 1;
    621650                        } else {
    622                                 if (copy_file(pCtx, curr, dne, cp_changed_only, &copied))
     651                                if (copy_file(&pThis->Utils, curr, dne, pThis->cp_changed_only, &copied))
    623652                                        badcp = rval = 1;
    624653                        }
     
    627656                case S_IFIFO:
    628657#endif
    629                         if (Rflag) {
    630                                 if (copy_fifo(pCtx, curr->fts_statp, !dne))
     658                        if (pThis->Rflag) {
     659                                if (copy_fifo(&pThis->Utils, curr->fts_statp, !dne))
    631660                                        badcp = rval = 1;
    632661                        } else {
    633                                 if (copy_file(pCtx, curr, dne, cp_changed_only, &copied))
     662                                if (copy_file(&pThis->Utils, curr, dne, pThis->cp_changed_only, &copied))
    634663                                        badcp = rval = 1;
    635664                        }
    636665                        break;
    637666                default:
    638                         if (copy_file(pCtx, curr, dne, cp_changed_only, &copied))
     667                        if (copy_file(&pThis->Utils, curr, dne, pThis->cp_changed_only, &copied))
    639668                                badcp = rval = 1;
    640669                        break;
    641670                }
    642                 if (vflag && !badcp)
    643                         kmk_builtin_ctx_printf(pCtx, 0, copied ? "%s -> %s\n" : "%s matches %s - not copied\n",
    644                                                curr->fts_path, to.p_path);
     671                if (pThis->Utils.vflag && !badcp)
     672                        kmk_builtin_ctx_printf(pThis->Utils.pCtx, 0, copied ? "%s -> %s\n" : "%s matches %s - not copied\n",
     673                                               curr->fts_path, pThis->Utils.to.p_path);
    645674        }
    646675        if (errno)
    647                 return err(pCtx, 1, "fts_read");
     676                return err(pThis->Utils.pCtx, 1, "fts_read");
    648677        return (rval);
    649678}
     
    657686 *      files first reduces seeking.
    658687 */
    659 static int
    660 mastercmp(const FTSENT **a, const FTSENT **b)
     688#ifdef FTSCALL
     689static int FTSCALL mastercmp(const FTSENT * const *a, const FTSENT * const *b)
     690#else
     691static int mastercmp(const FTSENT **a, const FTSENT **b)
     692#endif
    661693{
    662694        int a_info, b_info;
     
    675707}
    676708
    677 #ifdef SIGINFO
     709#if defined(SIGINFO) && defined(KMK_BUILTIN_STANDALONE)
    678710static void
    679711siginfo(int sig __unused)
    680712{
    681713
    682         info = 1;
     714        g_cp_info = 1;
    683715}
    684716#endif
Note: See TracChangeset for help on using the changeset viewer.