From: tecodev Date: Mon, 3 Mar 2008 01:27:36 +0000 (+0000) Subject: * src/pic/device.c (find_device): search user-specified paths first X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=fb45748c88838d6c6ef57308b441e41ab8f018de;p=fw%2Fsdcc * src/pic/device.c (find_device): search user-specified paths first for pic14devices.txt, fixes #1900827 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5063 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 75b55f2b..b33c1ca3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-03 Raphael Neider + + * src/pic/device.c (find_device): search user-specified paths first + for pic14devices.txt, fixes #1900827 + 2008-03-02 Borut Razem * support/scripts/sdcc.nsi: fixed bug in IsNT, LogicLib-isation of diff --git a/src/pic/device.c b/src/pic/device.c index 528cde27..442292ef 100644 --- a/src/pic/device.c +++ b/src/pic/device.c @@ -193,8 +193,8 @@ extern set *userIncDirsSet; extern set *libDirsSet; extern set *libPathsSet; -/* read the file with all the pic14 definitions and pick out the definition for a processor - * if specified. if pic_name is NULL reads everything */ +/* read the file with all the pic14 definitions and pick out the definition + * for a processor if specified. if pic_name is NULL reads everything */ static PIC_device *find_device(char *pic_name) { FILE *pic_file; @@ -224,56 +224,66 @@ static PIC_device *find_device(char *pic_name) /* first scan all include directories */ pic_file = NULL; //fprintf( stderr, "%s: searching %s\n", __FUNCTION__, DEVICE_FILE_NAME ); - for (dir = setFirstItem(includeDirsSet); + for (dir = setFirstItem(userIncDirsSet); !pic_file && dir; - dir = setNextItem(includeDirsSet)) + dir = setNextItem(userIncDirsSet)) { //fprintf( stderr, "searching1 %s\n", dir ); - SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME); + SNPRINTF(&filename[0], len, "%s%s", dir, + DIR_SEPARATOR_STRING DEVICE_FILE_NAME); pic_file = fopen( filename, "rt" ); if (pic_file) break; } // for - for (dir = setFirstItem(userIncDirsSet); + + for (dir = setFirstItem(includeDirsSet); !pic_file && dir; - dir = setNextItem(userIncDirsSet)) + dir = setNextItem(includeDirsSet)) { //fprintf( stderr, "searching2 %s\n", dir ); - SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME); + SNPRINTF(&filename[0], len, "%s%s", dir, + DIR_SEPARATOR_STRING DEVICE_FILE_NAME); pic_file = fopen( filename, "rt" ); if (pic_file) break; } // for + for (dir = setFirstItem(libDirsSet); !pic_file && dir; dir = setNextItem(libDirsSet)) { //fprintf( stderr, "searching3 %s\n", dir ); - SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME); + SNPRINTF(&filename[0], len, "%s%s", dir, + DIR_SEPARATOR_STRING DEVICE_FILE_NAME); pic_file = fopen( filename, "rt" ); if (pic_file) break; } // for + for (dir = setFirstItem(libPathsSet); !pic_file && dir; dir = setNextItem(libPathsSet)) { //fprintf( stderr, "searching4 %s\n", dir ); - SNPRINTF(&filename[0], len, "%s%s%s", dir, DIR_SEPARATOR_STRING, DEVICE_FILE_NAME); + SNPRINTF(&filename[0], len, "%s%s", dir, + DIR_SEPARATOR_STRING DEVICE_FILE_NAME); pic_file = fopen( filename, "rt" ); if (pic_file) break; } // for + if (!pic_file) { - pic_file = fopen(DATADIR LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "pic" DIR_SEPARATOR_STRING DEVICE_FILE_NAME, "rt"); - } - if (pic_file == NULL) { - /* this second attempt is used when initially building the libraries */ - pic_file = fopen(".." DIR_SEPARATOR_STRING ".." DIR_SEPARATOR_STRING ".." DIR_SEPARATOR_STRING ".." - DIR_SEPARATOR_STRING "src" DIR_SEPARATOR_STRING "pic" DIR_SEPARATOR_STRING - DEVICE_FILE_NAME, "rt"); - if (pic_file == NULL) { - fprintf(stderr, "can't find %s\n", DATADIR LIB_DIR_SUFFIX DIR_SEPARATOR_STRING "pic" - DIR_SEPARATOR_STRING DEVICE_FILE_NAME); - return NULL; - } - } + SNPRINTF(&filename[0], len, "%s", + DATADIR LIB_DIR_SUFFIX + DIR_SEPARATOR_STRING "pic" + DIR_SEPARATOR_STRING DEVICE_FILE_NAME); + pic_file = fopen( filename, "rt" ); + } // if + + if (pic_file == NULL) { + fprintf(stderr, "can't find %s\n", DEVICE_FILE_NAME); + return NULL; + } // if + + if (options.verbose) { + printf ("Using devices from %s.\n", filename); + } // if /* read line by line */ pic_buf[sizeof(pic_buf)-1] = '\0';