fontforge/fontforge-20090923-rel-path.patch

48 lines
1.7 KiB
Diff

diff -Nur fontforge-20090923.orig/gutils/fsys.c fontforge-20090923/gutils/fsys.c
--- fontforge-20090923.orig/gutils/fsys.c 2009-01-25 11:06:49.000000000 -0700
+++ fontforge-20090923/gutils/fsys.c 2009-12-31 09:59:54.000000000 -0700
@@ -41,6 +41,15 @@
static char dirname_[1024];
+static void savestrcpy(char *dest,const char *src) {
+ forever {
+ *dest = *src;
+ if ( *dest=='\0' )
+ break;
+ ++dest; ++src;
+ }
+}
+
char *GFileGetAbsoluteName(char *name, char *result, int rsiz) {
/* result may be the same as name */
char buffer[1000];
@@ -62,13 +71,13 @@
if ( *spt=='/' ) ++spt;
for ( pt = spt; *pt!='\0' && *pt!='/'; ++pt );
if ( pt==spt ) /* Found // in a path spec, reduce to / (we've*/
- strcpy(spt,pt); /* skipped past the :// of the machine name) */
- else if ( pt==spt+1 && spt[0]=='.' ) /* Noop */
- strcpy(spt,pt);
- else if ( pt==spt+2 && spt[0]=='.' && spt[1]=='.' ) {
+ savestrcpy(spt,spt+1); /* skipped past the :// of the machine name) */
+ else if ( pt==spt+1 && spt[0]=='.' ) { /* Noop */
+ savestrcpy(spt,spt+2);
+ } else if ( pt==spt+2 && spt[0]=='.' && spt[1]=='.' ) {
for ( bpt=spt-2 ; bpt>rpt && *bpt!='/'; --bpt );
if ( bpt>=rpt && *bpt=='/' ) {
- strcpy(bpt,pt);
+ savestrcpy(bpt,pt);
spt = bpt;
} else {
rpt = pt;
@@ -99,7 +108,7 @@
if ( dir==NULL || *dir=='\0' ) {
if ( strlen( fname )<size-1 ) /* valgrind didn't like my strncpies but this complication makes it happy */
- strcpy(buffer,fname);
+ savestrcpy(buffer,fname);
else {
strncpy(buffer,fname,size-1);
buffer[size-1]='\0';