Skip to content

Commit b1b9fb3

Browse files
committed
char or wchar_t, not both
1 parent a88b885 commit b1b9fb3

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

Lib/.keep

Whitespace-only changes.

src/UT/FULLPATH.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,19 @@ CD
182182
CD Bruk: sStatus = UT_FullPath(szBuffer,szPath,maxlen);
183183
==================================================================
184184
*/
185-
SK_EntPnt_UT short UT_FullPath(wchar_t *pszBuffer, const wchar_t *pszPath, size_t maxlen)
185+
SK_EntPnt_UT short UT_FullPath(char *pszBuffer, const char *pszPath, size_t maxlen)
186186
{
187-
wchar_t szFilnavn[_MAX_PATH];
188-
wchar_t *pszStart,*pszSlutt;
189-
wchar_t *env;
187+
char szFilnavn[_MAX_PATH];
188+
char *pszStart,*pszSlutt;
189+
char *env;
190190
#ifdef BORLAND
191191
wchar_t *pszOrgPath;
192192
#endif
193193

194194
/* Søk start- og sluttparantes */
195195
UT_StrCopy(szFilnavn,pszPath,_MAX_PATH);
196-
pszStart = wcschr(szFilnavn,'(');
197-
pszSlutt = wcschr(szFilnavn,')');
196+
pszStart = strchr(szFilnavn,'(');
197+
pszSlutt = strchr(szFilnavn,')');
198198

199199
/* Både start- og sluttparantes er funnet,
200200
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
205205
env = getenv( UT_StrUpper(pszStart));
206206
#else
207207
size_t len;
208-
_wdupenv_s(&env, &len, UT_StrUpper(pszStart));
208+
_dupenv_s(&env, &len, UT_StrUpper(pszStart));
209209
#endif
210210

211211
/* Navnet er ikke funnet */
@@ -233,7 +233,7 @@ SK_EntPnt_UT short UT_FullPath(wchar_t *pszBuffer, const wchar_t *pszPath, size
233233
#endif
234234

235235
#ifdef WIN32
236-
return (short)(_wfullpath(pszBuffer,szFilnavn,maxlen) != NULL)? 0 : 1;
236+
return (short)(_fullpath(pszBuffer,szFilnavn,maxlen) != NULL)? 0 : 1;
237237
#endif
238238

239239
#ifdef BORLAND

src/UT/SPLITPTH.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
// UT_splitpath - split a full path name
55
//
66

7-
#include <cstring>
8-
#include <fyut.h>
7+
#include "stdafx.h"
98

109
void UT_splitFN(char *filename, char* name, char* ext) {
1110
char* lastDot = strrchr(filename, '.');
@@ -43,21 +42,21 @@ CD char *extP o extension
4342
CD ==============================================================
4443
*/
4544
SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char *nameP, char *extP) {
46-
char local_path[PATH_MAX]; /* Copy of pathP i case we modify it */
47-
char tmp[PATH_MAX]; /* Copy of pathP i case we modify it */
48-
char filename[PATH_MAX];
45+
char local_path[_MAX_PATH]; /* Copy of pathP i case we modify it */
46+
char tmp[_MAX_PATH]; /* Copy of pathP i case we modify it */
47+
//char filename[_MAX_PATH];
4948
(*driveP) = (*dirP) = (*nameP) = (*extP) = '\0';
5049

51-
strcpy(local_path, pathP);
52-
strcpy(tmp, local_path);
50+
UT_StrCopy(local_path, pathP, _MAX_PATH);
51+
UT_StrCopy(tmp, local_path, _MAX_PATH);
5352
/* Under linux, driveP is always \0 */
5453
#ifdef WIN32
5554
/* Afaik, there is only ONE : in windows filenames */
5655
char* theColon = strrchr(tmp, ':');
5756
if(theColon != NULL) {
5857
/* We overwrite local_path here, because after this the code
5958
is equal for win/lin if the drive-part is removed */
60-
UT_StrCopy(local_path, theColon+1, PATH_MAX);
59+
UT_StrCopy(local_path, theColon+1, _MAX_PATH);
6160
(*(theColon + 1)) = '\0'; // set a \0 after the color (inside tmp!)
6261
UT_StrCopy(driveP, tmp, _MAX_DRIVE);
6362
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
6665
}
6766
#endif
6867

69-
strcpy(tmp, local_path);
68+
UT_StrCopy(tmp, local_path, _MAX_PATH);
7069

7170
char* lastSlash = strrchr(tmp, UT_SLASH);
7271

7372
/* Set dirP */
7473
if(lastSlash != NULL) {
7574
/* +1 because we don't want the / in the filename */
76-
char filename[PATH_MAX]; /* UT_splitFN might modify filename */
77-
strcpy(filename,lastSlash+1);
75+
char filename[_MAX_PATH]; /* UT_splitFN might modify filename */
76+
UT_StrCopy(filename,lastSlash+1, _MAX_PATH);
7877
if (strcmp(filename, ".") != 0) {
7978
UT_splitFN(filename, nameP, extP);
8079
(*(tmp + (lastSlash - tmp + 1))) = '\0';
@@ -86,7 +85,7 @@ SK_EntPnt_UT void UT_splitpath(const char *pathP, char *driveP, char *dirP, char
8685
}
8786
} else {
8887
if (strcmp(".", local_path) == 0) { /* Hard-coded to mimic old behaviour */
89-
strcpy(dirP, ".");
88+
UT_StrCopy(dirP, ".", _MAX_DIR);
9089
} else {
9190
UT_splitFN(tmp, nameP, extP);
9291
}

src/UT/stdafx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55

66
#pragma once
77

8+
#include <cstring>
9+
#include "fyut.h"
10+
811

912
// TODO: reference additional headers your program requires here

0 commit comments

Comments
 (0)