X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffilename.c;h=0c085776f5b889aefc23dfc9fb8174273bcc759e;hb=92fb12eb06716d14c05b781f5d9dcde956d77c30;hp=b8f8332fdb9057f753435aedd92e84ae33d27d14;hpb=4de79b34b329d1da6cdeb145993d3efd911e2967;p=pspp diff --git a/src/filename.c b/src/filename.c index b8f8332fdb..0c085776f5 100644 --- a/src/filename.c +++ b/src/filename.c @@ -1,5 +1,5 @@ /* PSPP - computes sample statistics. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. Written by Ben Pfaff . This program is free software; you can redistribute it and/or @@ -530,6 +530,18 @@ fn_basename (const char *filename) abort (); } #endif + +/* Returns the extension part of FILENAME as a malloc()'d string. + If FILENAME does not have an extension, returns an empty + string. */ +char * +fn_extension (const char *filename) +{ + const char *extension = strrchr (filename, '.'); + if (extension == NULL) + extension = ""; + return xstrdup (extension); +} #if unix /* Returns the current working directory, as a malloc()'d string. @@ -691,7 +703,7 @@ fn_open (const char *fn, const char *mode) #ifdef unix if (fn[0] == '|') { - if (safer_mode()) + if (get_safer_mode ()) return safety_violation (fn); return popen (&fn[1], mode); @@ -701,7 +713,7 @@ fn_open (const char *fn, const char *mode) char *s; FILE *f; - if (safer_mode()) + if (get_safer_mode ()) return safety_violation (fn); s = local_alloc (strlen (fn));