[fyba] 29/77: char or wchar_t, not both

Ruben Undheim rubund-guest at moszumanska.debian.org
Mon Sep 22 15:11:25 UTC 2014


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch master
in repository fyba.

commit b1b9fb37964d1fc15cf7338a3de13542ea4af05e
Author: Anders Einar Hilden <hildenae at gmail.com>
Date:   Tue Oct 22 19:03:41 2013 +0200

    char or wchar_t, not both
---
 Lib/.keep           |  0
 src/UT/FULLPATH.cpp | 16 ++++++++--------
 src/UT/SPLITPTH.cpp | 23 +++++++++++------------
 src/UT/stdafx.h     |  3 +++
 4 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/Lib/.keep b/Lib/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/src/UT/FULLPATH.cpp b/src/UT/FULLPATH.cpp
index 679bcf3..4092a93 100644
--- a/src/UT/FULLPATH.cpp
+++ b/src/UT/FULLPATH.cpp
@@ -182,19 +182,19 @@ CD
 CD Bruk:  sStatus = UT_FullPath(szBuffer,szPath,maxlen);
 	==================================================================
 */
-SK_EntPnt_UT short  UT_FullPath(wchar_t *pszBuffer, const wchar_t *pszPath, size_t maxlen)
+SK_EntPnt_UT short  UT_FullPath(char *pszBuffer, const char *pszPath, size_t maxlen)
 {
-	wchar_t szFilnavn[_MAX_PATH];
-	wchar_t *pszStart,*pszSlutt;
-	wchar_t *env;
+	char szFilnavn[_MAX_PATH];
+	char *pszStart,*pszSlutt;
+	char *env;
 #ifdef BORLAND
 	wchar_t  *pszOrgPath;
 #endif
 
 	/* S�k start- og sluttparantes */
 	UT_StrCopy(szFilnavn,pszPath,_MAX_PATH);
-	pszStart = wcschr(szFilnavn,'(');
-	pszSlutt = wcschr(szFilnavn,')');
+	pszStart = strchr(szFilnavn,'(');
+	pszSlutt = strchr(szFilnavn,')');
 
 	/* B�de start- og sluttparantes er funnet,
       og starten er f�rst i strengen */
@@ -205,7 +205,7 @@ SK_EntPnt_UT short  UT_FullPath(wchar_t *pszBuffer, const wchar_t *pszPath, size
       env = getenv( UT_StrUpper(pszStart));
 #else      
       size_t len;
-      _wdupenv_s(&env, &len, UT_StrUpper(pszStart));
+      _dupenv_s(&env, &len, UT_StrUpper(pszStart));
 #endif
 
       /* Navnet er ikke funnet */
@@ -233,7 +233,7 @@ SK_EntPnt_UT short  UT_FullPath(wchar_t *pszBuffer, const wchar_t *pszPath, size
 #endif
 
 #ifdef WIN32
-   return  (short)(_wfullpath(pszBuffer,szFilnavn,maxlen) != NULL)?  0 : 1;
+   return  (short)(_fullpath(pszBuffer,szFilnavn,maxlen) != NULL)?  0 : 1;
 #endif
 
 #ifdef BORLAND
diff --git a/src/UT/SPLITPTH.cpp b/src/UT/SPLITPTH.cpp
index 60b99e2..d6b76f8 100644
--- a/src/UT/SPLITPTH.cpp
+++ b/src/UT/SPLITPTH.cpp
@@ -4,8 +4,7 @@
 //        UT_splitpath - split a full path name
 //
 
-#include <cstring>
-#include <fyut.h>
+#include "stdafx.h"
 
 void UT_splitFN(char *filename, char* name, char* ext) {
 	char* lastDot = strrchr(filename, '.');
@@ -43,13 +42,13 @@ CD char       *extP              o  extension
 CD  ==============================================================
 */
 SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char *nameP, char *extP) {
-	char local_path[PATH_MAX]; /* Copy of pathP i case we modify it */
-	char tmp[PATH_MAX]; /* Copy of pathP i case we modify it */
-	char filename[PATH_MAX];
+	char local_path[_MAX_PATH]; /* Copy of pathP i case we modify it */
+	char tmp[_MAX_PATH]; /* Copy of pathP i case we modify it */
+	//char filename[_MAX_PATH];
 	(*driveP) = (*dirP) = (*nameP) = (*extP) = '\0';
 
-	strcpy(local_path, pathP);
-	strcpy(tmp, local_path);
+	UT_StrCopy(local_path, pathP, _MAX_PATH);
+	UT_StrCopy(tmp, local_path, _MAX_PATH);
 	/* Under linux, driveP is always \0 */
 	#ifdef WIN32
 		/* Afaik, there is only ONE : in windows filenames */
@@ -57,7 +56,7 @@ SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char
 		if(theColon != NULL) {
 			/* We overwrite local_path here, because after this the code
 			is equal for win/lin if the drive-part is removed */
-			UT_StrCopy(local_path, theColon+1, PATH_MAX);
+			UT_StrCopy(local_path, theColon+1, _MAX_PATH);
 			(*(theColon + 1)) = '\0'; // set a \0 after the color (inside tmp!)
 			UT_StrCopy(driveP, tmp, _MAX_DRIVE);
 			if (strlen(tmp) > _MAX_DRIVE) { // how would this even happen?
@@ -66,15 +65,15 @@ SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char
 		}
 	#endif
 
-	strcpy(tmp, local_path);
+	UT_StrCopy(tmp, local_path, _MAX_PATH);
 	
 	char* lastSlash = strrchr(tmp, UT_SLASH);
 	
 	/* Set dirP */
 	if(lastSlash != NULL) {
 		/* +1 because we don't want the / in the filename */
-		char filename[PATH_MAX]; /* UT_splitFN might modify filename */
-		strcpy(filename,lastSlash+1);
+		char filename[_MAX_PATH]; /* UT_splitFN might modify filename */
+		UT_StrCopy(filename,lastSlash+1, _MAX_PATH);
 		if (strcmp(filename, ".") != 0) {
 			UT_splitFN(filename, nameP, extP);
 		    (*(tmp + (lastSlash - tmp + 1))) = '\0';	
@@ -86,7 +85,7 @@ SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char
 		}
 	} else {
 		if (strcmp(".", local_path) == 0) { /* Hard-coded to mimic old behaviour */
-		 	strcpy(dirP, ".");
+			UT_StrCopy(dirP, ".", _MAX_DIR);
 		} else {
 			UT_splitFN(tmp, nameP, extP);
 		}
diff --git a/src/UT/stdafx.h b/src/UT/stdafx.h
index f1ffb54..69f29d4 100644
--- a/src/UT/stdafx.h
+++ b/src/UT/stdafx.h
@@ -5,5 +5,8 @@
 
 #pragma once
 
+#include <cstring>
+#include "fyut.h"
+
 
 // TODO: reference additional headers your program requires here

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/fyba.git



More information about the Pkg-grass-devel mailing list