aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-07-05 19:00:47 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-07-05 19:00:47 +0000
commit9efd582dc713b90a69682538ec34579a2bd38afb (patch)
tree3a1c4ca9a5a873f39efe93d88528315c2f339090
parent4b571c9dee2f7b1f327debec38811bd862219610 (diff)
downloadbusybox-w32-9efd582dc713b90a69682538ec34579a2bd38afb.tar.gz
busybox-w32-9efd582dc713b90a69682538ec34579a2bd38afb.tar.bz2
busybox-w32-9efd582dc713b90a69682538ec34579a2bd38afb.zip
Removed obsolete function, strdup_substr.
git-svn-id: svn://busybox.net/trunk/busybox@3010 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--editors/sed.c4
-rw-r--r--include/libbb.h4
-rw-r--r--libbb/dirname.c2
-rw-r--r--libbb/libbb.h4
-rw-r--r--libbb/strdup_substr.c34
-rw-r--r--sed.c4
6 files changed, 5 insertions, 47 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 89b16682f..24b62e5fa 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -223,7 +223,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
223 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); 223 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx);
224 if (idx == -1) 224 if (idx == -1)
225 error_msg_and_die("bad format in substitution expression"); 225 error_msg_and_die("bad format in substitution expression");
226 match = strdup_substr(substr, oldidx, idx); 226 match = xstrndup(substr + oldidx, idx - oldidx);
227 227
228 /* determine the number of back references in the match string */ 228 /* determine the number of back references in the match string */
229 /* Note: we compute this here rather than in the do_subst_command() 229 /* Note: we compute this here rather than in the do_subst_command()
@@ -242,7 +242,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
242 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); 242 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx);
243 if (idx == -1) 243 if (idx == -1)
244 error_msg_and_die("bad format in substitution expression"); 244 error_msg_and_die("bad format in substitution expression");
245 sed_cmd->replace = strdup_substr(substr, oldidx, idx); 245 sed_cmd->replace = xstrndup(substr + oldidx, idx - oldidx);
246 246
247 /* process the flags */ 247 /* process the flags */
248 while (substr[++idx]) { 248 while (substr[++idx]) {
diff --git a/include/libbb.h b/include/libbb.h
index c29955b3b..0fc704501 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -254,10 +254,6 @@ extern struct hostent *xgethostbyname(const char *name);
254 254
255char *dirname (const char *path); 255char *dirname (const char *path);
256 256
257static inline char *strdup_substr (const char *s, int start, int end)
258{
259 return xstrndup (s+start, end-start);
260}
261int make_directory (char *path, mode_t mode, int flags); 257int make_directory (char *path, mode_t mode, int flags);
262 258
263#define CT_AUTO 0 259#define CT_AUTO 0
diff --git a/libbb/dirname.c b/libbb/dirname.c
index cc50f5870..5f839945d 100644
--- a/libbb/dirname.c
+++ b/libbb/dirname.c
@@ -45,5 +45,5 @@ char *dirname(const char *path)
45 if (s < path) 45 if (s < path)
46 return xstrdup ("."); 46 return xstrdup (".");
47 else 47 else
48 return strdup_substr (path, 0, s - path + 1); 48 return xstrndup (path, s - path + 1);
49} 49}
diff --git a/libbb/libbb.h b/libbb/libbb.h
index c29955b3b..0fc704501 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -254,10 +254,6 @@ extern struct hostent *xgethostbyname(const char *name);
254 254
255char *dirname (const char *path); 255char *dirname (const char *path);
256 256
257static inline char *strdup_substr (const char *s, int start, int end)
258{
259 return xstrndup (s+start, end-start);
260}
261int make_directory (char *path, mode_t mode, int flags); 257int make_directory (char *path, mode_t mode, int flags);
262 258
263#define CT_AUTO 0 259#define CT_AUTO 0
diff --git a/libbb/strdup_substr.c b/libbb/strdup_substr.c
deleted file mode 100644
index 85030b11a..000000000
--- a/libbb/strdup_substr.c
+++ /dev/null
@@ -1,34 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini strdup_substr function.
4 *
5 * Copyright (C) 2001 Mark Whitley.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/* Return a substring of STR, starting at index START and ending at END,
23 * allocated on the heap. */
24
25#include "libbb.h"
26
27char *strdup_substr(const char *str, int start, int end)
28{
29 int size = end - start + 1;
30 char *newstr = xmalloc(size);
31 memcpy(newstr, str+start, size-1);
32 newstr[size-1] = '\0';
33 return newstr;
34}
diff --git a/sed.c b/sed.c
index 89b16682f..24b62e5fa 100644
--- a/sed.c
+++ b/sed.c
@@ -223,7 +223,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
223 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); 223 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx);
224 if (idx == -1) 224 if (idx == -1)
225 error_msg_and_die("bad format in substitution expression"); 225 error_msg_and_die("bad format in substitution expression");
226 match = strdup_substr(substr, oldidx, idx); 226 match = xstrndup(substr + oldidx, idx - oldidx);
227 227
228 /* determine the number of back references in the match string */ 228 /* determine the number of back references in the match string */
229 /* Note: we compute this here rather than in the do_subst_command() 229 /* Note: we compute this here rather than in the do_subst_command()
@@ -242,7 +242,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
242 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); 242 idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx);
243 if (idx == -1) 243 if (idx == -1)
244 error_msg_and_die("bad format in substitution expression"); 244 error_msg_and_die("bad format in substitution expression");
245 sed_cmd->replace = strdup_substr(substr, oldidx, idx); 245 sed_cmd->replace = xstrndup(substr + oldidx, idx - oldidx);
246 246
247 /* process the flags */ 247 /* process the flags */
248 while (substr[++idx]) { 248 while (substr[++idx]) {