14 #define mySKIPSPACE(s) { while (*(s) && isspace(*(s))) (s)++; } 15 #define mySKIPNONSPACE(s) { while (*(s) && !isspace(*(s))) (s)++; } 58 time_t timezone_offset;
59 char * p, * pe, * q, ** idx;
60 char * date = strcpy(
alloca(strlen(datestr) + 1), datestr);
61 static char * days[] =
62 {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat", NULL };
63 static char * months[] =
64 {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
65 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec", NULL };
66 static char lengths[] =
67 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
69 memset(&time, 0,
sizeof(time));
75 if (*p ==
'\0')
return -1;
77 for (idx = days; *idx && strcmp(*idx, p); idx++)
79 if (*idx == NULL)
return -1;
83 if (*p ==
'\0')
return -1;
85 for (idx = months; *idx && strcmp(*idx, p); idx++)
87 if (*idx == NULL)
return -1;
88 time.tm_mon = idx - months;
92 if (*p ==
'\0')
return -1;
98 time.tm_mday = strtol(p, &q, 10);
99 if (!(q && *q ==
'\0'))
return -1;
100 if (time.tm_mday < 0 || time.tm_mday > lengths[time.tm_mon])
return -1;
104 if (*p ==
'\0')
return -1;
106 time.tm_year = strtol(p, &q, 10);
107 if (!(q && *q ==
'\0'))
return -1;
108 if (time.tm_year < 1990 || time.tm_year >= 3000)
return -1;
109 time.tm_year -= 1900;
111 *secs = mktime(&time);
112 if (*secs == -1)
return -1;
116 timezone_offset = mktime(gmtime(secs)) - *secs;
120 *secs += timezone_offset;
126 extern time_t
get_date(
const char * p,
void * now);
141 char *date, *
name, *text;
146 static time_t last = 0;
147 static int oneshot = 0;
151 char * t =
rpmExpand(
"%{?_changelog_truncate}", NULL);
154 long res = strtol(t, &te, 0);
155 if (res >= 0 && *te ==
'\0') {
176 _(
"%%changelog entries must start with *\n"));
182 while(*s && *s !=
'\n') s++;
195 for (i = 0; i < 4; i++) {
204 if (lastTime && lastTime < time) {
206 _(
"%%changelog not in descending chronological order\n"));
220 while (*s !=
'\0') s++;
221 while (s > name && isspace(*s))
240 }
while (*s && (*(s-1) !=
'\n' || *s !=
'*'));
252 || (last < 1000 && nentries < (
int)last)
253 || (last > 1000 && time >= last))
272 #if defined(RPM_VENDOR_MANDRIVA) 288 #if defined(RPM_VENDOR_MANDRIVA)
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
const char * xstrtolocale(const char *str)
Force encoding of string.
char * xstrdup(const char *str)
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
static void rpmlog(int code, const char *fmt,...)
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
Yet Another syslog(3) API clone.
time_t get_date(const char *p, void *now)
static int xisspace(int c)
The structure used to store values parsed from a spec file.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
void addChangelogEntry(Header h, time_t time, const char *name, const char *text)
Add changelog entry to header.
static int dateToTimet(const char *datestr, time_t *secs)
Parse date string to seconds.
enum rpmRC_e rpmRC
RPM return codes.
char * rpmiobStr(rpmiob iob)
Return I/O buffer (as string).
This is the only module users of librpmbuild should need to include.
#define mySKIPNONSPACE(s)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int parseChangelog(Spec spec)
Parse %changelog section of a spec file.
enum rpmParseState_e rpmParseState
static rpmRC addChangelog(Header h, rpmiob iob)
Add changelog section to header.