projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add define for Kirk Smith's USR Courier driver. Change default baud
[unix-history]
/
usr
/
src
/
usr.bin
/
window
/
string.c
diff --git
a/usr/src/usr.bin/window/string.c
b/usr/src/usr.bin/window/string.c
index
a9d0719
..
dd781fa
100644
(file)
--- a/
usr/src/usr.bin/window/string.c
+++ b/
usr/src/usr.bin/window/string.c
@@
-1,7
+1,13
@@
#ifndef lint
#ifndef lint
-static char
*sccsid = "@(#)string.c 3.3 84/01/05
";
+static char
sccsid[] = "@(#)string.c 3.8 %G%
";
#endif
#endif
+/*
+ * Copyright (c) 1983 Regents of the University of California,
+ * All rights reserved. Redistribution permitted subject to
+ * the terms of the Berkeley Software License Agreement.
+ */
+
#include "string.h"
char *malloc();
#include "string.h"
char *malloc();
@@
-22,6
+28,26
@@
register char *s;
return str;
}
return str;
}
+char *
+str_ncpy(s, n)
+register char *s;
+register n;
+{
+ int l = strlen(s);
+ char *str;
+ register char *p;
+
+ if (n > l)
+ n = l;
+ str = p = str_alloc(n + 1);
+ if (p == 0)
+ return 0;
+ while (--n >= 0)
+ *p++ = *s++;
+ *p = 0;
+ return str;
+}
+
char *
str_itoa(i)
int i;
char *
str_itoa(i)
int i;
@@
-63,10
+89,6
@@
register min;
}
#ifdef STR_DEBUG
}
#ifdef STR_DEBUG
-struct string str_head = {
- &str_head, &str_head
-};
-
char *
str_alloc(l)
int l;
char *
str_alloc(l)
int l;
@@
-76,6
+98,8
@@
int l;
s = (struct string *) malloc((unsigned)l + str_offset);
if (s == 0)
return 0;
s = (struct string *) malloc((unsigned)l + str_offset);
if (s == 0)
return 0;
+ if (str_head.s_forw == 0)
+ str_head.s_forw = str_head.s_back = &str_head;
s->s_forw = str_head.s_forw;
s->s_back = &str_head;
str_head.s_forw = s;
s->s_forw = str_head.s_forw;
s->s_back = &str_head;
str_head.s_forw = s;
@@
-86,7
+110,7
@@
int l;
str_free(str)
char *str;
{
str_free(str)
char *str;
{
- register struct string *s
= str_stos(s)
;
+ register struct string *s;
for (s = str_head.s_forw; s != &str_head && s->s_data != str;
s = s->s_forw)
for (s = str_head.s_forw; s != &str_head && s->s_data != str;
s = s->s_forw)
@@
-95,6
+119,6
@@
char *str;
abort();
s->s_back->s_forw = s->s_forw;
s->s_forw->s_back = s->s_back;
abort();
s->s_back->s_forw = s->s_forw;
s->s_forw->s_back = s->s_back;
- free(
s->s_data
);
+ free(
(char *)s
);
}
#endif
}
#endif