Added langpatt:
authormarc <devnull@localhost>
Fri, 20 Mar 1998 04:34:09 +0000 (04:34 +0000)
committermarc <devnull@localhost>
Fri, 20 Mar 1998 04:34:09 +0000 (04:34 +0000)
CVS patchset: 2038
CVS date: 1998/03/20 04:34:09

CHANGES
build/files.c
lib/rpmlib.h
lib/rpmrc.c

diff --git a/CHANGES b/CHANGES
index efd24b3..0ce249a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2.4.104 -> 2.4.105:
+       - added langpath: to rpmrc, and mark files with matches
+
 2.4.103 -> 2.4.104:
        - fixed popt/Makefile.in to use CPP from configure
        - use tmppath from rpmrc to for ftp'd files (rather then /var/tmp)
index a768db1..fb561a1 100644 (file)
@@ -8,6 +8,8 @@
 #include <string.h>
 #include <malloc.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <regex.h>
 
 #include "spec.h"
 #include "package.h"
@@ -94,6 +96,7 @@ static int parseForVerify(char *buf, struct FileList *fl);
 static int parseForLang(char *buf, struct FileList *fl);
 static int parseForAttr(char *buf, struct FileList *fl);
 static int parseForConfig(char *buf, struct FileList *fl);
+static int parseForRegexLang(char *fileName, char **lang);
 static int myGlobPatternP(char *pattern);
 static int glob_error(const char *foo, int bar);
 static void timeCheck(int tc, Header h);
@@ -719,6 +722,7 @@ static int addFile(struct FileList *fl, char *name, struct stat *statp)
     int_16 fileMode;
     int fileUid, fileGid;
     char *fileUname, *fileGname;
+    char *lang;
     
     strcpy(fileName, cleanFileName(name));
 
@@ -824,9 +828,14 @@ static int addFile(struct FileList *fl, char *name, struct stat *statp)
        fl->fileList[fl->fileListRecsUsed].uname = fileUname;
        fl->fileList[fl->fileListRecsUsed].gname = fileGname;
 
-       fl->fileList[fl->fileListRecsUsed].lang =
-           strdup(fl->currentLang ? fl->currentLang : "");
-       
+       if (fl->currentLang) {
+           fl->fileList[fl->fileListRecsUsed].lang = strdup(fl->currentLang);
+       } else if (! parseForRegexLang(fileName, &lang)) {
+           fl->fileList[fl->fileListRecsUsed].lang = strdup(lang);
+       } else {
+           fl->fileList[fl->fileListRecsUsed].lang = strdup("");
+       }
+
        fl->fileList[fl->fileListRecsUsed].flags = fl->currentFlags;
        fl->fileList[fl->fileListRecsUsed].verifyFlags =
            fl->currentVerifyFlags;
@@ -1021,6 +1030,47 @@ static int parseForVerify(char *buf, struct FileList *fl)
     return 0;
 }
 
+static int parseForRegexLang(char *fileName, char **lang)
+{
+    static int initialized = 0;
+    static int hasRegex = 0;
+    static regex_t compiledPatt;
+    static char buf[BUFSIZ];
+    int x;
+    regmatch_t matches[2];
+    char *patt, *s;
+
+    if (! initialized) {
+       initialized = 1;
+       patt = rpmGetVar(RPMVAR_LANGPATT);
+       if (! patt) {
+           return 1;
+       }
+       if (regcomp(&compiledPatt, patt, REG_EXTENDED)) {
+           return -1;
+       }
+       hasRegex = 1;
+    }
+    
+    if (! hasRegex) {
+       return 1;
+    }
+
+    if (! regexec(&compiledPatt, fileName, 2, matches, REG_NOTEOL)) {
+       /* Got match */
+       s = fileName + matches[1].rm_eo - 1;
+       x = matches[1].rm_eo - matches[1].rm_so;
+       buf[x] = '\0';
+       while (x) {
+           buf[--x] = *s--;
+       }
+       *lang = buf;
+       return 0;
+    }
+
+    return 1;
+}
+
 static int parseForLang(char *buf, struct FileList *fl)
 {
     char *p, *start, *end;
index 67c7922..f92e9ce 100644 (file)
@@ -221,8 +221,9 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
 #define RPMVAR_BUILDSHELL               39
 #define RPMVAR_INSTCHANGELOG            40
 #define RPMVAR_BZIP2BIN                41
+#define RPMVAR_LANGPATT                 42
 
-#define RPMVAR_NUM                     42     /* number of RPMVAR entries */
+#define RPMVAR_NUM                     43     /* number of RPMVAR entries */
 
 char * rpmGetVar(int var);
 int rpmGetBooleanVar(int var);
index 8e4d648..d79cbaf 100644 (file)
@@ -112,6 +112,7 @@ static struct rpmOption optionTable[] = {
     { "ftpproxy",              RPMVAR_FTPPROXY,                0, 0 },
     { "gzipbin",               RPMVAR_GZIPBIN,                 0, 1 },
     { "instchangelog",         RPMVAR_INSTCHANGELOG,           0, 0 },
+    { "langpatt",               RPMVAR_LANGPATT,                0, 0 },
     { "messagelevel",          RPMVAR_MESSAGELEVEL,            0, 0 },
     { "netsharedpath",         RPMVAR_NETSHAREDPATH,           0, 0 },
     { "optflags",              RPMVAR_OPTFLAGS,                1, 0 },