@@ -87,7 +87,6 @@ static int used_atom_cnt, sort_atom_limit, need_tagged;
8787static int parse_atom (const char * atom , const char * ep )
8888{
8989 const char * sp ;
90- char * n ;
9190 int i , at ;
9291
9392 sp = atom ;
@@ -120,10 +119,7 @@ static int parse_atom(const char *atom, const char *ep)
120119 (sizeof * used_atom ) * used_atom_cnt );
121120 used_atom_type = xrealloc (used_atom_type ,
122121 (sizeof (* used_atom_type ) * used_atom_cnt ));
123- n = xmalloc (ep - atom + 1 );
124- memcpy (n , atom , ep - atom );
125- n [ep - atom ] = 0 ;
126- used_atom [at ] = n ;
122+ used_atom [at ] = xmemdupz (atom , ep - atom );
127123 used_atom_type [at ] = valid_atom [i ].cmp_type ;
128124 return at ;
129125}
@@ -305,46 +301,28 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
305301static const char * copy_line (const char * buf )
306302{
307303 const char * eol = strchr (buf , '\n' );
308- char * line ;
309- int len ;
310304 if (!eol )
311305 return "" ;
312- len = eol - buf ;
313- line = xmalloc (len + 1 );
314- memcpy (line , buf , len );
315- line [len ] = 0 ;
316- return line ;
306+ return xmemdupz (buf , eol - buf );
317307}
318308
319309static const char * copy_name (const char * buf )
320310{
321- const char * eol = strchr (buf , '\n' );
322- const char * eoname = strstr (buf , " <" );
323- char * line ;
324- int len ;
325- if (!(eoname && eol && eoname < eol ))
326- return "" ;
327- len = eoname - buf ;
328- line = xmalloc (len + 1 );
329- memcpy (line , buf , len );
330- line [len ] = 0 ;
331- return line ;
311+ const char * cp ;
312+ for (cp = buf ; * cp != '\n' ; cp ++ ) {
313+ if (!strncmp (cp , " <" , 2 ))
314+ return xmemdupz (buf , cp - buf );
315+ }
316+ return "" ;
332317}
333318
334319static const char * copy_email (const char * buf )
335320{
336321 const char * email = strchr (buf , '<' );
337322 const char * eoemail = strchr (email , '>' );
338- char * line ;
339- int len ;
340323 if (!email || !eoemail )
341324 return "" ;
342- eoemail ++ ;
343- len = eoemail - email ;
344- line = xmalloc (len + 1 );
345- memcpy (line , email , len );
346- line [len ] = 0 ;
347- return line ;
325+ return xmemdupz (email , eoemail + 1 - email );
348326}
349327
350328static void grab_date (const char * buf , struct atom_value * v )
0 commit comments