[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[open-cobol-list] dd_ with file names - Minor patch to "cob_open"
From: |
Ehud Karni |
Subject: |
[open-cobol-list] dd_ with file names - Minor patch to "cob_open" |
Date: |
Mon, 30 Mar 2009 16:36:38 +0300 |
Hello all,
In MF Cobol, a file name like dir/file.ext will try ${dd_dir}/file.ext.
From the MF online manual: "it isolates the first element of that name,
that is, all the text before the first slash character (/), or all the
text if the name does not include such a character".
The open-cobol-1.1 `cob_open' function (in libcob/fileio) did not account
for a name with a / case. The patch bellow fix this.
Ehud.
cd /f-s/gnu/src/open-cobol-1.1/libcob/
diff -c /f-s/gnu/src/open-cobol-1.1/libcob/fileio.c-sv
/f-s/gnu/src/open-cobol-1.1/libcob/fileio.c
*** /f-s/gnu/src/open-cobol-1.1/libcob/fileio.c-sv Sat Jan 24 15:31:30 2009
--- /f-s/gnu/src/open-cobol-1.1/libcob/fileio.c Tue Mar 17 02:01:58 2009
***************
*** 3826,3832 ****
/* ex. "$TMPDIR/foo" -> "/tmp/foo" */
while (*src) {
if (!isalnum (*src) && *src != '_' && *src != '-') {
! simple = 0;
}
if (*src == '$') {
for (i = 1; ; i++) {
--- 3826,3834 ----
/* ex. "$TMPDIR/foo" -> "/tmp/foo" */
while (*src) {
if (!isalnum (*src) && *src != '_' && *src != '-') {
! if ( *src == '/' )
! simple ++ ; /* 0==>1 1==>2
2==>3 */
! simple &= 2; /* 0,1==>0
2,3==>2 */
}
if (*src == '$') {
for (i = 1; ; i++) {
***************
*** 3851,3861 ****
--- 3853,3873 ----
/* resolve by environment variables */
! /* ex. "TMPFILE" -> DD_TMPFILE, dd_TMPFILE, or TMPFILE
! "DIR/FILE" -> DD_DIR/FILE, dd_DIR/FILE, or DIR/FILE */
if (simple) {
+ char * slsh ;
for (i = 0; i < NUM_PREFIX; i++) {
snprintf (file_open_buff, COB_SMALL_MAX, "%s%s",
prefix[i], file_open_name);
+ if (( slsh = strchr (file_open_buff,'/')) !=
NULL )
+ *slsh = 0 ;
if ((p = getenv (file_open_buff)) != NULL) {
strncpy (file_open_name, p,
COB_SMALL_MAX);
+ if ( slsh != NULL )
+ {
+ int used = strlen ( file_open_name
) ;
+ int left = COB_SMALL_MAX - used ;
+ *slsh = '/' ;
+ strncpy (file_open_name + used ,
slsh , left ) ;
+ }
break;
}
}
--
@@@@@@ @@@ @@@@@@ @ @ Ehud Karni אהוד קרני
@ @ @ @@ @ Senior System Support תמיכה במערכות מחשב
@ @ @ @ @ @@ Mivtach - Simon מבטח - סימון
@ @ @ @ @ @ Insurance agencies סוכנויות לבטוח
Better Safe Than Sorry Tel: 03-7966-561 :טל Fax: 03-7966-667 :פקס
http://www.mvs.co.il mailto:address@hidden :דו"אל
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [open-cobol-list] dd_ with file names - Minor patch to "cob_open",
Ehud Karni <=