Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/tip deal in a saner way with const strings.
details: https://anonhg.NetBSD.org/src/rev/868d2ae93bd8
branches: trunk
changeset: 565947:868d2ae93bd8
user: christos <christos%NetBSD.org@localhost>
date: Fri Apr 23 22:24:34 2004 +0000
description:
deal in a saner way with const strings.
diffstat:
usr.bin/tip/remote.c | 11 +++++++----
usr.bin/tip/tip.c | 16 +++++++++++-----
2 files changed, 18 insertions(+), 9 deletions(-)
diffs (92 lines):
diff -r 58dfea4ffac2 -r 868d2ae93bd8 usr.bin/tip/remote.c
--- a/usr.bin/tip/remote.c Fri Apr 23 22:14:57 2004 +0000
+++ b/usr.bin/tip/remote.c Fri Apr 23 22:24:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: remote.c,v 1.10 2004/04/23 22:11:44 christos Exp $ */
+/* $NetBSD: remote.c,v 1.11 2004/04/23 22:24:34 christos Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: remote.c,v 1.10 2004/04/23 22:11:44 christos Exp $");
+__RCSID("$NetBSD: remote.c,v 1.11 2004/04/23 22:24:34 christos Exp $");
#endif /* not lint */
#include "pathnames.h"
@@ -66,6 +66,9 @@
static void getremcap __P((char *));
+static char tiprecord[] = "tip.record";
+static char wspace[] = "\t\n\b\f";
+
static void
getremcap(host)
char *host;
@@ -175,9 +178,9 @@
if (cgetflag("dc"))
DC = 1;
if (RE == NULL)
- RE = strdup("tip.record");
+ RE = tiprecord;
if (EX == NULL)
- EX = strdup("\t\n\b\f");
+ EX = wspace;
if (ES != NULL)
vstring("es", ES);
if (FO != NULL)
diff -r 58dfea4ffac2 -r 868d2ae93bd8 usr.bin/tip/tip.c
--- a/usr.bin/tip/tip.c Fri Apr 23 22:14:57 2004 +0000
+++ b/usr.bin/tip/tip.c Fri Apr 23 22:24:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tip.c,v 1.25 2004/04/23 22:11:44 christos Exp $ */
+/* $NetBSD: tip.c,v 1.26 2004/04/23 22:24:34 christos Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: tip.c,v 1.25 2004/04/23 22:11:44 christos Exp $");
+__RCSID("$NetBSD: tip.c,v 1.26 2004/04/23 22:24:34 christos Exp $");
#endif /* not lint */
/*
@@ -66,6 +66,8 @@
char PNbuf[256]; /* This limits the size of a number */
+static char path_phones[] = _PATH_PHONES;
+
int
main(argc, argv)
int argc;
@@ -171,7 +173,7 @@
* in the right order, so force it here
*/
if ((PH = getenv("PHONES")) == NULL)
- PH = strdup(_PATH_PHONES);
+ PH = path_phones;
vinit(); /* init variables */
setparity("even"); /* set the parity table */
if ((i = speed(number(value(BAUDRATE)))) == 0) {
@@ -601,9 +603,13 @@
{
int i, flip, clr, set;
const char *parity;
+ static char *curpar;
- if (value(PARITY) == NULL || (value(PARITY))[0] == '\0')
- value(PARITY) = strdup(defparity);
+ if (value(PARITY) == NULL || (value(PARITY))[0] == '\0') {
+ if (curpar != NULL)
+ free(curpar);
+ value(PARITY) = curpar = strdup(defparity);
+ }
parity = value(PARITY);
if (equal(parity, "none")) {
bits8 = 1;
Home |
Main Index |
Thread Index |
Old Index