Changeset 3285
- Timestamp:
- May 2, 2007, 1:44:40 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/essentials/app-shells/bash/variables.c
r3238 r3285 206 206 static SHELL_VAR *get_funcname __P((SHELL_VAR *)); 207 207 static SHELL_VAR *init_funcname_var __P((void)); 208 209 #if defined(__OS2__) 210 static SHELL_VAR *os2_libpath_assign __P((SHELL_VAR *, char *, arrayind_t)); 211 static SHELL_VAR *os2_libpath_refresh_value __P((SHELL_VAR *)); 212 #endif 208 213 209 214 static void initialize_dynamic_variables __P((void)); … … 1367 1372 #endif /* PUSHD AND POPD && ARRAY_VARS */ 1368 1373 1374 #ifdef __OS2__ 1375 /* LIBPATH stuff */ 1376 # define INCL_BASE 1377 # include <assert.h> 1378 # include <os2.h> 1379 extern APIRET APIENTRY DosQueryHeaderInfo (HMODULE hmod, ULONG ulIndex, PVOID pvBuffer, ULONG cbBuffer, ULONG ulSubFunction); 1380 # define QHINF_LIBPATHLENGTH 4 /* Gets the libpath length. */ 1381 # define QHINF_LIBPATH 5 /* Gets the entire libpath. */ 1382 1383 static SHELL_VAR *os2_libpath_assign (self, value, ind) 1384 SHELL_VAR *self; 1385 char *value; 1386 arrayind_t ind; 1387 { 1388 /* set */ 1389 ULONG flags; 1390 char ch = self->name[0]; 1391 if (ch == 'B' || ch == 'b') 1392 flags = BEGIN_LIBPATH; 1393 else if (ch == 'E' || ch == 'e') 1394 flags = END_LIBPATH; 1395 else if ((ch == 'L' || ch == 'l') && strcmp (self->name, "LIBPATH")) 1396 flags = LIBPATHSTRICT; 1397 else 1398 { 1399 assert (0); 1400 return (self); 1401 } 1402 DosSetExtLIBPATH (value, flags); 1403 1404 /* refresh the value. */ 1405 return os2_libpath_refresh_value (self); 1406 } 1407 1408 static SHELL_VAR *os2_libpath_refresh_value (self) 1409 SHELL_VAR *self; 1410 { 1411 VUNSETATTR (self, att_exported); 1412 1413 /* allocate 2 KB once and assume nobody messes with it. 1414 (2KB is a bit too much for LIBPATHSTRICT, but so what.) */ 1415 if (var_isnull (self)) 1416 { 1417 char *newval = xmalloc (2048); 1418 var_setvalue (self, newval); 1419 } 1420 1421 if (!strcmp (self->name, "LIBPATH")) 1422 { 1423 if (DosQueryHeaderInfo (NULLHANDLE, 0, self->value, 2048, QHINF_LIBPATH)) 1424 { 1425 assert (0); 1426 self->value[0] = '\0'; 1427 } 1428 } 1429 else 1430 { 1431 ULONG flags; 1432 char ch = self->name[0]; 1433 if (ch == 'B' || ch == 'b') 1434 flags = BEGIN_LIBPATH; 1435 else if (ch == 'E' || ch == 'e') 1436 flags = END_LIBPATH; 1437 else if (ch == 'L' || ch == 'l') 1438 { 1439 /* The API writes a single value, add '\0'. */ 1440 memset (self->value, 0, 32); 1441 flags = LIBPATHSTRICT; 1442 } 1443 else 1444 assert (0); 1445 if (DosQueryExtLIBPATH (self->value, flags)) 1446 { 1447 assert (0); 1448 self->value[0] = '\0'; 1449 } 1450 } 1451 return self; 1452 } 1453 #endif /* __OS2__ */ 1454 1369 1455 #if defined (ARRAY_VARS) 1370 1456 /* We don't want to initialize the group set with a call to getgroups() … … 1479 1565 v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign|att_nounset); 1480 1566 #endif 1567 1568 #ifdef __OS2__ 1569 INIT_DYNAMIC_VAR ("BEGINLIBPATH", (char *)NULL, NULL, os2_libpath_assign); 1570 os2_libpath_refresh_value (v); 1571 VSETATTR (v, att_special | att_nounset | att_exported); 1572 INIT_DYNAMIC_VAR ("ENDLIBPATH", (char *)NULL, NULL, os2_libpath_assign); 1573 os2_libpath_refresh_value (v); 1574 VSETATTR (v, att_special | att_nounset | att_exported); 1575 INIT_DYNAMIC_VAR ("LIBPATHSTRICT", (char *)NULL, NULL, os2_libpath_assign); 1576 os2_libpath_refresh_value (v); 1577 VSETATTR (v, att_special | att_nounset | att_exported); 1578 INIT_DYNAMIC_VAR ("LIBPATH", (char *)NULL, NULL, (sh_var_assign_func_t *)NULL); 1579 VSETATTR (v, att_special | att_nounset | att_exported | att_readonly | att_noassign); 1580 os2_libpath_refresh_value (v); 1581 #endif 1481 1582 1482 1583 v = init_funcname_var (); … … 2779 2880 SHELL_VAR *var; 2780 2881 { 2882 #ifdef __OS2__ 2883 /* Keep the *LIBPATH* variables out of the exported environment variables. */ 2884 if (invisible_p (var) == 0 2885 && exported_p (var) 2886 && !function_p (var) 2887 && specialvar_p (var) /* abusing this for speed */ 2888 && strstr(var->name, "LIBPATH")) 2889 return 0; 2890 #endif 2781 2891 return (invisible_p (var) == 0 && exported_p (var)); 2782 2892 }
Note:
See TracChangeset
for help on using the changeset viewer.