Unix Technical Forum

Re: patch(1) w/paths containing spaces

This is a discussion on Re: patch(1) w/paths containing spaces within the mailing.openbsd.tech forums, part of the OpenBSD category; --> On Tue, 26 Oct 2004, Kurt Miller wrote: > From: "Otto Moerbeek" <otto@drijf.net> > > I have this diff ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 08:22 AM
Otto Moerbeek
 
Posts: n/a
Default Re: patch(1) w/paths containing spaces

On Tue, 26 Oct 2004, Kurt Miller wrote:

> From: "Otto Moerbeek" <otto@drijf.net>
> > I have this diff in my tree, which is supposed to handle any funny
> > character in pathnames _except_ tabs. I was not able to find a simple,
> > robust way to handle tabs.

>
> Your diff is working fine for my purposes. It improves patch(1)
> functionality and will fall back to the old behavior if no tabs are
> found. Who cares about tabs anyway?
>
> Your diff combined with my update-patches diff makes the ports
> infrastructure work for creating and applying patches against
> paths that contain spaces or other funky chars (except tabs). The
> current port I'm working on needs this, but is easy to work around
> without it.
>
> -Kurt


Here's a slightly optimized version, based on Jared's proposal, should
have the same behaviour as my original diff, please check,

-Otto

Index: util.c
================================================== =================
RCS file: /cvs/src/usr.bin/patch/util.c,v
retrieving revision 1.28
diff -u -p -r1.28 util.c
--- util.c 5 Aug 2004 21:47:24 -0000 1.28
+++ util.c 29 Oct 2004 13:19:32 -0000
@@ -333,7 +333,7 @@ char *
fetchname(const char *at, bool *exists, int strip_leading)
{
char *fullname, *name, *t;
- int sleading;
+ int sleading, tab;
struct stat filestat;

if (at == NULL || *at == '\0')
@@ -349,8 +349,10 @@ fetchname(const char *at, bool *exists,
return NULL;
name = fullname = t = savestr(at);

+ tab = strchr(t, '\t') != NULL;
/* Strip off up to `strip_leading' path components and NUL terminate. */
- for (sleading = strip_leading; *t != '\0' && !isspace(*t); t++) {
+ for (sleading = strip_leading; *t != '\0' && ((tab && *t != '\t') ||
+ !isspace(*t)); t++) {
if (t[0] == '/' && t[1] != '/' && t[1] != '\0')
if (--sleading >= 0)
name = t + 1;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com