/[qemacs]/qemacs/util.c
ViewVC logotype

Diff of /qemacs/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by chqrlie, Mon May 9 03:19:36 2005 UTC revision 1.9 by chqrlie, Mon May 9 09:10:38 2005 UTC
# Line 310  char *pathname(char *buf, int buf_size, Line 310  char *pathname(char *buf, int buf_size,
310      return buf;      return buf;
311  }  }
312    
313  char *makepath(char *buf, int buf_size, const char *path, const char *filename)  char *makepath(char *buf, int buf_size, const char *path,
314                   const char *filename)
315  {  {
316      int len;      int len;
317    
# Line 323  char *makepath(char *buf, int buf_size, Line 324  char *makepath(char *buf, int buf_size,
324      return pstrcat(buf, buf_size, filename);      return pstrcat(buf, buf_size, filename);
325  }  }
326    
327  /* copy the nth first char of a string and truncate it. */  void splitpath(char *dirname, int dirname_size,
328                   char *filename, int filename_size, const char *pathname)
329    {
330        const char *base;
331    
332        base = basename(pathname);
333        pstrncpy(dirname, dirname_size, pathname, base - pathname);
334        pstrcpy(filename, filename_size, base);
335    }
336    
337    /* copy the n first char of a string and truncate it. */
338  char *pstrncpy(char *buf, int buf_size, const char *s, int len)  char *pstrncpy(char *buf, int buf_size, const char *s, int len)
339  {  {
340      char *q, *q_end;      char *q;
341      int c;      int c;
342    
343      if (buf_size > 0) {      if (buf_size > 0) {
344          q = buf;          q = buf;
345          q_end = buf + buf_size - 1;          if (len >= buf_size)
346          while (q < q_end && len > 0) {              len = buf_size - 1;
347            while (len > 0) {
348              c = *s++;              c = *s++;
349              if (c == '\0')              if (c == '\0')
350                  break;                  break;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26