Print this page
make: translate using gettext, rather than the unmaintainable catgets

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/lib/vroot/lock.cc
          +++ new/usr/src/cmd/make/lib/vroot/lock.cc
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#include <avo/intl.h>   /* for NOCATGETS */
  27   26  #include <stdio.h>
  28   27  #include <stdlib.h>
  29   28  #include <string.h>
  30   29  #include <sys/errno.h>
  31   30  #include <sys/param.h>
  32   31  #include <sys/stat.h>
  33   32  #include <sys/types.h>
  34   33  #include <unistd.h>
  35   34  #include <vroot/vroot.h>
  36      -#include <mksdmsi18n/mksdmsi18n.h>
  37   35  #include <signal.h>
  38   36  #include <errno.h>                      /* errno */
       37 +#include <libintl.h>
  39   38  
  40   39  extern  char            *sys_errlist[];
  41   40  extern  int             sys_nerr;
  42   41  
  43   42  static  void            file_lock_error(char *msg, char *file, char *str, int arg1, int arg2);
  44   43  
  45   44  #define BLOCK_INTERUPTS sigfillset(&newset) ; \
  46   45          sigprocmask(SIG_SETMASK, &newset, &oldset)
  47   46  
  48   47  #define UNBLOCK_INTERUPTS \
↓ open down ↓ 53 lines elided ↑ open up ↑
 102  101                  BLOCK_INTERUPTS;
 103  102                  r = symlink(name, lockname);
 104  103                  if (r == 0) {
 105  104                          *file_locked = 1;
 106  105                          UNBLOCK_INTERUPTS;
 107  106                          return 0; /* success */
 108  107                  }
 109  108                  UNBLOCK_INTERUPTS;
 110  109  
 111  110                  if (errno != EEXIST) {
 112      -                        file_lock_error(msg, name, (char *)NOCATGETS("symlink(%s, %s)"),
      111 +                        file_lock_error(msg, name, (char *)"symlink(%s, %s)",
 113  112                              (int) name, (int) lockname);
 114  113                          fprintf(stderr, "%s", msg);
 115  114                          return errno;
 116  115                  }
 117  116  
 118  117                  counter = 0;
 119  118                  for (;;) {
 120  119                          sleep(1); 
 121  120                          r = lstat(lockname, &statb);
 122  121                          if (r == -1) {
↓ open down ↓ 1 lines elided ↑ open up ↑
 124  123                                   * The lock must have just gone away - try 
 125  124                                   * again.
 126  125                                   */
 127  126                                  break;
 128  127                          }
 129  128  
 130  129                          if ((counter > 5) && (!printed_warning)) {
 131  130                                  /* Print waiting message after 5 secs */
 132  131                                  (void) getcwd(msg, MAXPATHLEN);
 133  132                                  fprintf(stderr,
 134      -                                        catgets(libmksdmsi18n_catd, 1, 162, "file_lock: file %s is already locked.\n"),
      133 +                                        gettext("file_lock: file %s is already locked.\n"),
 135  134                                          name);
 136  135                                  fprintf(stderr,
 137      -                                        catgets(libmksdmsi18n_catd, 1, 163, "file_lock: will periodically check the lockfile %s for two minutes.\n"),
      136 +                                        gettext("file_lock: will periodically check the lockfile %s for two minutes.\n"),
 138  137                                          lockname);
 139  138                                  fprintf(stderr,
 140      -                                        catgets(libmksdmsi18n_catd, 1, 144, "Current working directory %s\n"),
      139 +                                        gettext("Current working directory %s\n"),
 141  140                                          msg);
 142  141  
 143  142                                  printed_warning = 1;
 144  143                          }
 145  144  
 146  145                          if (++counter > timeout ) {
 147  146                                  /*
 148  147                                   * Waited enough - return an error..
 149  148                                   */
 150  149                                  return EEXIST;
↓ open down ↓ 4 lines elided ↑ open up ↑
 155  154  }
 156  155  
 157  156  /*
 158  157   * Format a message telling why the lock could not be created.
 159  158   */
 160  159  static  void
 161  160  file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
 162  161  {
 163  162          int             len;
 164  163  
 165      -        sprintf(msg, catgets(libmksdmsi18n_catd, 1, 145, "Could not lock file `%s'; "), file);
      164 +        sprintf(msg, gettext("Could not lock file `%s'; "), file);
 166  165          len = strlen(msg);
 167  166          sprintf(&msg[len], str, arg1, arg2);
 168      -        strcat(msg, catgets(libmksdmsi18n_catd, 1, 146, " failed - "));
      167 +        strcat(msg, gettext(" failed - "));
 169  168          if (errno < sys_nerr) {
 170  169                  strcat(msg, strerror(errno));
 171  170          } else {
 172  171                  len = strlen(msg);
 173      -                sprintf(&msg[len], NOCATGETS("errno %d"), errno);
      172 +                sprintf(&msg[len], "errno %d", errno);
 174  173          }
 175  174  }
 176  175  
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX