[Pinfo-devel] r39 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Fri Aug 26 08:09:29 UTC 2005
Author: neroden-guest
Date: 2005-08-26 08:09:27 +0000 (Fri, 26 Aug 2005)
New Revision: 39
Modified:
pinfo/branches/cxx/src/filehandling_functions.cxx
pinfo/branches/cxx/src/printinfo.cxx
pinfo/branches/cxx/src/utils.cxx
Log:
Fix copyright in printinfo.cxx.
Fix comment in utils.cxx.
Convert some of the low-hanging fruit in filehandling_functions.cxx to use
std::string. (This one has a lot of tricky stuff in it.)
Modified: pinfo/branches/cxx/src/filehandling_functions.cxx
===================================================================
--- pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-26 07:37:16 UTC (rev 38)
+++ pinfo/branches/cxx/src/filehandling_functions.cxx 2005-08-26 08:09:27 UTC (rev 39)
@@ -21,7 +21,8 @@
***************************************************************************/
#include "common_includes.h"
-
+#include <string>
+using std::string;
RCSID("$Id$")
typedef struct
@@ -278,32 +279,25 @@
void
load_indirect(char **message, long lines)
{
- long i;
- char *wsk;
int cut = 0; /* number of invalid entries */
indirect = (Indirect*)xmalloc((lines + 1) * sizeof(Indirect));
- for (i = 1; i < lines; i++)
- {
- char *check;
- wsk = message[i];
- check = wsk + strlen(wsk);
- while (*(++wsk) != ':') /* check if this line keeps a real entry */
- {
- if (wsk == check) /*
- * make sure wsk won't go out of range
- * in case the wsk would be corrupted.
- */
- break;
+ for (long i = 1; i < lines; i++) {
+ string wsk_string = message[i];
+ unsigned int n = 0;
+ /* Find the first colon, but not in position 0 */
+ n = wsk_string.find(':', 1);
+ if (n == string::npos) {
+ /* No colon. Invalid entry. */
+ cut++; /* if the entry was invalid, make indirect count shorter */
+ } else {
+ string filename;
+ filename = wsk_string.substr(0, n);
+ strncpy(indirect[i - cut].filename, filename.c_str(), 200);
+
+ string remainder;
+ remainder = wsk_string.substr(n + 2, string::npos);
+ indirect[i - cut].offset = atoi(remainder.c_str());
}
- if (*wsk) /* if the entry holds some data... */
- {
- (*wsk) = 0;
- strncpy(indirect[i - cut].filename, message[i], 200);
- (*wsk) = ':';
- indirect[i - cut].offset = atoi(wsk + 2);
- }
- else
- cut++; /* if the entry was invalid, make inirect count shorter */
}
IndirectEntries = lines - 1 - cut;
}
Modified: pinfo/branches/cxx/src/printinfo.cxx
===================================================================
--- pinfo/branches/cxx/src/printinfo.cxx 2005-08-26 07:37:16 UTC (rev 38)
+++ pinfo/branches/cxx/src/printinfo.cxx 2005-08-26 08:09:27 UTC (rev 39)
@@ -3,6 +3,7 @@
*
* Copyright (C) 1999 Przemek Borys <pborys at dione.ids.pl>
* Copyright (C) 2005 Bas Zoetekouw <bas at debian.org>
+ * Copyright 2005 Nathanael Nerode <neroden at gcc.gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
Modified: pinfo/branches/cxx/src/utils.cxx
===================================================================
--- pinfo/branches/cxx/src/utils.cxx 2005-08-26 07:37:16 UTC (rev 38)
+++ pinfo/branches/cxx/src/utils.cxx 2005-08-26 08:09:27 UTC (rev 39)
@@ -49,7 +49,7 @@
/*
- * the bellow define enables malloc/realloc/free logging to stderr.
+ * the below define enables malloc/realloc/free logging to stderr.
* They start to log their argument values.
*
* #define ___DEBUG___
More information about the Pinfo-devel
mailing list