#!/bin/sh /usr/share/dpatch/dpatch-run ## 11_history_fullpath.dpatch by Joshua Kwan ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Store absolute paths, however gnarly, into history, when relative file ## DP: paths are used on the command line. --- abiword-2.2.0/abi/src/wp/ap/xp/ap_App.cpp~ 2004-11-23 02:02:17.000000000 -0800 +++ abiword-2.2.0/abi/src/wp/ap/xp/ap_App.cpp 2004-11-23 02:02:04.000000000 -0800 @@ -18,6 +18,8 @@ * 02111-1307, USA. */ +#include + #include "ap_Features.h" #include "ap_App.h" #include "ap_Args.h" @@ -50,13 +50,45 @@ { int kWindowsOpened = 0; const char *file = NULL; + +#ifdef WIN32 +# define arch_separator '\\' +#else +# define arch_separator '/' +#endif + char cwd[PATH_MAX]; poptContext poptcon = args->poptcon; + + getcwd(cwd, PATH_MAX); while ((file = poptGetArg (poptcon)) != NULL) { XAP_Frame * pFrame = newFrame(); + char* fullpath = NULL; + + if (*file != arch_separator) + { + size_t file_len = strlen(file); +#ifdef WIN32 + if (file_len > 1 && (file[1] != ':' || !(file[0] != '\\' && file[1] != '\\'))) /* check for C:\Blah.doc and \\share\Blah.doc */ +#endif + { + size_t len = strlen(cwd) + file_len + 2; /* C/F + NUL */ + fullpath = (char*)malloc(len); + + /* First, resolve the path into an absolute one as best as we can */ + snprintf(fullpath, len, "%s%c%s", cwd, arch_separator, file); + } + } UT_Error error = pFrame->loadDocument - (file, IEFT_Unknown, true); + (fullpath ? fullpath : file, IEFT_Unknown, true); + + if (fullpath != NULL) + { + free (fullpath); + fullpath = NULL; + } + if (!error) { kWindowsOpened++; @@ -74,6 +106,7 @@ pFrame->loadDocument(NULL, IEFT_Unknown); pFrame->raise(); + /* OK to use relative path here. We get it */ errorMsgBadFile (pFrame, file, error); }