- fixed configure script to assume chown() doesn't follow symlinks
if lchown() isn't available and configure is not being run as root
- more header file changes for AIX
+ - added :shescape query format type for strings, which prints strings
+ which will survive a single level of shell expansion
2.3.11 -> 2.4:
- changed RPMNLSDIR directories to and @datadir@ to better
unsigned int mtime, unsigned short rdev,
char * owner, char * group, int uid, int gid,
char * linkto);
+static void formatString(const char * format, const char * str,
+ const char * how);
static int queryHeader(Header h, char * chptr) {
int count = 0;
return 0;
}
+static void formatString(const char * format, const char * str,
+ const char * how) {
+ char * dst;
+ const char * src, * buf;
+
+ if (!strcmp(how, "shescape")) {
+ buf = dst = alloca(strlen(str) * 4 + 3);
+ *dst++ = '\'';
+ for (src = str; *src; src++) {
+ if (*src == '\'') {
+ *dst++ = '\'';
+ *dst++ = '\\';
+ *dst++ = '\'';
+ *dst++ = '\'';
+ } else {
+ *dst++ = *src;
+ }
+ }
+ *dst++ = '\'';
+ *dst = '\0';
+ } else {
+ buf = str;
+ }
+
+ printf(format, buf);
+}
+
static char * handleFormat(Header h, char * chptr, int * cntptr,
int arrayNum) {
const char * f = chptr;
switch (type) {
case RPM_STRING_ARRAY_TYPE:
strcat(format, "s");
- printf(format, ((char **) p)[arrayNum]);
+ formatString(format, ((char **) p)[arrayNum], how);
free(p);
break;
case RPM_STRING_TYPE:
strcat(format, "s");
- printf(format, p);
+ formatString(format, p, how);
break;
case RPM_CHAR_TYPE: