| @@ -1,17 +1,17 @@ | | | @@ -1,17 +1,17 @@ |
1 | /* | | 1 | /* |
2 | * $OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $ | | 2 | * $OpenBSD: util.c,v 1.32 2006/03/11 19:41:30 otto Exp $ |
3 | * $DragonFly: src/usr.bin/patch/util.c,v 1.9 2007/09/29 23:11:10 swildner Exp $ | | 3 | * $DragonFly: src/usr.bin/patch/util.c,v 1.9 2007/09/29 23:11:10 swildner Exp $ |
4 | * $NetBSD: util.c,v 1.3 2009/05/09 20:09:33 joerg Exp $ | | 4 | * $NetBSD: util.c,v 1.4 2010/01/23 23:08:03 joerg Exp $ |
5 | */ | | 5 | */ |
6 | | | 6 | |
7 | /* | | 7 | /* |
8 | * patch - a program to apply diffs to original files | | 8 | * patch - a program to apply diffs to original files |
9 | * | | 9 | * |
10 | * Copyright 1986, Larry Wall | | 10 | * Copyright 1986, Larry Wall |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following condition is met: | | 13 | * modification, are permitted provided that the following condition is met: |
14 | * 1. Redistributions of source code must retain the above copyright notice, | | 14 | * 1. Redistributions of source code must retain the above copyright notice, |
15 | * this condition and the following disclaimer. | | 15 | * this condition and the following disclaimer. |
16 | * | | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY | | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY |
| @@ -317,28 +317,30 @@ ignore_signals(void) | | | @@ -317,28 +317,30 @@ ignore_signals(void) |
317 | * true, ignore the last element of `filename'. | | 317 | * true, ignore the last element of `filename'. |
318 | */ | | 318 | */ |
319 | | | 319 | |
320 | void | | 320 | void |
321 | makedirs(const char *filename, bool striplast) | | 321 | makedirs(const char *filename, bool striplast) |
322 | { | | 322 | { |
323 | char *tmpbuf; | | 323 | char *tmpbuf; |
324 | | | 324 | |
325 | if ((tmpbuf = strdup(filename)) == NULL) | | 325 | if ((tmpbuf = strdup(filename)) == NULL) |
326 | fatal("out of memory\n"); | | 326 | fatal("out of memory\n"); |
327 | | | 327 | |
328 | if (striplast) { | | 328 | if (striplast) { |
329 | char *s = strrchr(tmpbuf, '/'); | | 329 | char *s = strrchr(tmpbuf, '/'); |
330 | if (s == NULL) | | 330 | if (s == NULL) { |
| | | 331 | free(tmpbuf); |
331 | return; /* nothing to be done */ | | 332 | return; /* nothing to be done */ |
| | | 333 | } |
332 | *s = '\0'; | | 334 | *s = '\0'; |
333 | } | | 335 | } |
334 | if (mkpath(tmpbuf) != 0) | | 336 | if (mkpath(tmpbuf) != 0) |
335 | pfatal("creation of %s failed", tmpbuf); | | 337 | pfatal("creation of %s failed", tmpbuf); |
336 | free(tmpbuf); | | 338 | free(tmpbuf); |
337 | } | | 339 | } |
338 | | | 340 | |
339 | /* | | 341 | /* |
340 | * Make filenames more reasonable. | | 342 | * Make filenames more reasonable. |
341 | */ | | 343 | */ |
342 | char * | | 344 | char * |
343 | fetchname(const char *at, bool *exists, int strip_leading) | | 345 | fetchname(const char *at, bool *exists, int strip_leading) |
344 | { | | 346 | { |