From d5a4e534aeed0c9c37e45a7e6cc0feba9721ea58 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 13 May 2020 22:21:17 +0900 Subject: [PATCH] [ROSAPPS][MAN] Don't hardcode C: drive (#2780) CORE-13235 --- .../rosapps/applications/sysutils/man/man.c | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/modules/rosapps/applications/sysutils/man/man.c b/modules/rosapps/applications/sysutils/man/man.c index e382972b08d..825b7954396 100644 --- a/modules/rosapps/applications/sysutils/man/man.c +++ b/modules/rosapps/applications/sysutils/man/man.c @@ -15,6 +15,7 @@ */ +#include #include #include #include @@ -37,7 +38,7 @@ int AnalyzeFile(); /*====[Globals]====*/ FILE* manfile; char OpenFlag=0; -char manpath[MAXLINE]="c:\\man\\"; +char manpath[MAX_PATH]; /*=================*/ void @@ -49,21 +50,34 @@ SetCl(WORD cl) int OpenF(char* name) { - int retval=0; - char *manpath_local=(char*)malloc(sizeof(char)*MAXLINE); + int ret = 0; + char *cp; - strcpy(manpath_local, manpath); //save mandir value - - if((manfile=fopen((strcat(manpath_local,name)),"r"))!=NULL) - { - OpenFlag=1; - AnalyzeFile(); - } + /* C:\man\\... */ + cp = getenv("SystemDrive"); + if (cp && *cp) + { + strcpy(manpath, cp); + strcat(manpath, "\\man\\"); + } else - retval=-1; + { + strcpy(manpath, "C:\\man\\"); + } + strcat(manpath, name); - free(manpath_local); - return retval; + manfile = fopen(manpath, "r"); + if (manfile != NULL) + { + OpenFlag = 1; + AnalyzeFile(); + } + else + { + ret = -1; + } + + return ret; } int