                                Source Listing                  24-APR-1996 13:22:49    DEC C T4.1-FT2                      Page   1
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]STR.C;1

	      1 
	      2 /******************************************************************************
	      3  *
	      4  * Str.C
	      5  *
	      6  ******************************************************************************/
	      7 
	      8 /******************************************************************************
	      9  *
	     10  * Headers
	     11  *
	     12  ******************************************************************************/
	     13 
	     14 #include <stdio.h>
	    396 #include <ctype.h>
	    627 
	    628 #ifdef VMS
	    629 #include <descrip.h>
	   1127 #endif
	   1128 
	   1129 #include "intrinsic.h"
	   1160 #include "mem.h"
	   1175 #include "str.h"
	   1196 
	   1197 /******************************************************************************
	   1198  *
	   1199  * Local Constants and Macros
	   1200  *
	   1201  ******************************************************************************/
	   1202 
	   1203 /******************************************************************************
	   1204  *
	   1205  * Local Declarations
	   1206  *
	   1207  ******************************************************************************/
	   1208 
	   1209 /******************************************************************************
	   1210  *
	   1211  * Local Prototypes
	   1212  *
	   1213  ******************************************************************************/
	   1214 
	   1215 /******************************************************************************
	   1216  *
	   1217  * StringCopy
	   1218  *
	   1219  ******************************************************************************/
	   1220 
	   1221 #ifdef VMS
	   1222 extern String StringCopy (String src)
	   1223 #else
       X   1224 extern String StringCopy (src)
       X   1225 
       X   1226   String src;
       X   1227 #endif
	   1228 
	   1229 {

                                Source Listing                  24-APR-1996 13:22:49    DEC C T4.1-FT2                      Page   2
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]STR.C;1

	   1230   String x;
	   1231 
	   1232   /* allocate */
	   1233   x = (String) MemAlloc (strlen(src) + 1, NoInitialize);
	   1234 
	   1235   /* copy */
	   1236   strcpy (x, src);
	   1237 
	   1238   /* return it */
	   1239   return (x);
	   1240 }
	   1241 
	   1242 /******************************************************************************
	   1243  *
	   1244  * StringLeft
	   1245  *
	   1246  ******************************************************************************/
	   1247 
	   1248 #ifdef VMS
	   1249 extern void StringLeft (String src, int pos)
	   1250 #else
       X   1251 extern void StringLeft (src, pos)
       X   1252 
       X   1253   String src;
       X   1254   int    pos;
       X   1255 #endif
	   1256 
	   1257 {
	   1258   /* validate */
	   1259   if ((pos < 0) || (pos > strlen(src))) return;
	   1260 
	   1261   /* truncate string */
	   1262   src[pos] = '\0';
	   1263 
	   1264   /* done */
	   1265   return;
	   1266 }
	   1267 
	   1268 /******************************************************************************
	   1269  *
	   1270  * StringRight
	   1271  *
	   1272  ******************************************************************************/
	   1273 
	   1274 #ifdef VMS
	   1275 extern void StringRight (String str, int pos)
	   1276 #else
       X   1277 extern void StringRight (str, pos)
       X   1278 
       X   1279   String str;
       X   1280   int    pos;
       X   1281 #endif
	   1282 
	   1283 {
	   1284   Buffer temp;
	   1285 
	   1286   /* validate */

                                Source Listing                  24-APR-1996 13:22:49    DEC C T4.1-FT2                      Page   3
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]STR.C;1

	   1287   if ((pos < 0) || (pos > strlen(str))) return;
	   1288 
	   1289   /* extract */
	   1290   strcpy (temp, &(str[pos]));
	   1291 
	   1292   /* copy back */
	   1293   strcpy (str, temp);
	   1294 
	   1295   /* done */
	   1296   return;
	   1297 }
	   1298 
	   1299 /******************************************************************************
	   1300  *
	   1301  * StringSubstr
	   1302  *
	   1303  ******************************************************************************/
	   1304 
	   1305 #ifdef VMS
	   1306 extern void StringSubstr (String str, int pos, int count)
	   1307 #else
       X   1308 extern void StringSubstr (str, pos, count)
       X   1309 
       X   1310   String str;
       X   1311   int    pos;
       X   1312   int    count;
       X   1313 #endif
	   1314 
	   1315 {
	   1316   Buffer temp;
	   1317 
	   1318   /* validate */
	   1319   if ((pos < 0) || (pos > strlen(str))) return;
	   1320   if ((pos + count) > strlen(str)) return;
	   1321 
	   1322   /* extract */
	   1323   strcpy (temp, &(str[pos]));
	   1324 
	   1325   /* truncate */
	   1326   temp[count] = '\0';
	   1327 
	   1328   /* copy back */
	   1329   strcpy (str, temp);
	   1330 
	   1331   /* done */
	   1332   return;
	   1333 }
	   1334 
	   1335 /******************************************************************************
	   1336  *
	   1337  * StringUppercase
	   1338  *
	   1339  ******************************************************************************/
	   1340 
	   1341 #ifdef VMS
	   1342 extern void StringUppercase (String str)
	   1343 #else

                                Source Listing                  24-APR-1996 13:22:49    DEC C T4.1-FT2                      Page   4
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]STR.C;1

       X   1344 extern void StringUppercase (str)
       X   1345 
       X   1346   String str;
       X   1347 #endif
	   1348 
	   1349 {
	   1350   /* process */
	   1351   while (*str) {
	   1352 
	   1353     /* if lowercase, then uppercase it */
	   1354     if (islower(*str)) *str = toupper(*str);
	   1355 
	   1356     /* go to next character */
	   1357     str += 1;
	   1358   }
	   1359 
	   1360   /* done */
	   1361   return;
	   1362 }
	   1363 
	   1364 /******************************************************************************
	   1365  *
	   1366  * StringLowercase
	   1367  *
	   1368  ******************************************************************************/
	   1369 
	   1370 #ifdef VMS
	   1371 extern void StringLowercase (String str)
	   1372 #else
       X   1373 extern void StringLowercase (str)
       X   1374 
       X   1375   String str;
       X   1376 #endif
	   1377 
	   1378 {
	   1379   /* process */
	   1380   while (*str) {
	   1381 
	   1382     /* if uppercase, then lowercase it */
	   1383     if (isupper(*str)) *str = tolower(*str);
	   1384 
	   1385     /* go to next character */
	   1386     str += 1;
	   1387   }
	   1388 
	   1389   /* done */
	   1390   return;
	   1391 }
	   1392 
	   1393 /******************************************************************************
	   1394  *
	   1395  * StringDesc
	   1396  *
	   1397  ******************************************************************************/
	   1398 
	   1399 #ifdef VMS
	   1400 Pointer StringDesc (String src)

                                Source Listing                  24-APR-1996 13:22:49    DEC C T4.1-FT2                      Page   5
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]STR.C;1

	   1401 
	   1402 {
	   1403   static Buffer      temp;
	   1404   static $DESCRIPTOR (desc, temp);
	   1405 
	   1406   /* fill in descriptor */
	   1407   strcpy (temp, src);
	   1408   desc.dsc$w_length = strlen(src);
	   1409 
	   1410   /* return */
	   1411   return ((Pointer) (&desc));
	   1412 }
	   1413 #endif
	   1414 
	   1415 /******************************************************************************
	   1416  *
	   1417  * StringAllocDesc
	   1418  *
	   1419  ******************************************************************************/
	   1420 
	   1421 #ifdef VMS
	   1422 Pointer StringAllocDesc (String str)
	   1423 
	   1424 {
	   1425   Pointer     x;
	   1426   $DESCRIPTOR (desc, str);
	   1427 
	   1428   /* revise */
	   1429   desc.dsc$w_length = strlen(str);
	   1430 
	   1431   /* copy */
	   1432   x = (Pointer) MemAlloc (sizeof(desc), NoInitialize);
	   1433   MemCopy (x, &desc, sizeof(desc));
	   1434 
	   1435   /* done */
	   1436   return (x);
	   1437 }
	   1438 #endif
	   1439 
	   1440 /******************************************************************************
	   1441  *
	   1442  * StringDeallocDesc
	   1443  *
	   1444  ******************************************************************************/
	   1445 
	   1446 #ifdef VMS
	   1447 extern void StringDeallocDesc (Pointer desc)
	   1448 
	   1449 {
	   1450   /* free */
	   1451   MemDealloc (desc);
	   1452 
	   1453   /* done */
	   1454   return;
	   1455 }
	   1456 #endif
	   1457 

                                Source Listing                  24-APR-1996 13:22:49    DEC C T4.1-FT2                      Page   6
                                                                 6-DEC-1995 09:57:26    WORK$:[DAVENPORT.RTL]STR.C;1

	   1458 /******************************************************************************
	   1459  *
	   1460  * StringReplace
	   1461  *
	   1462  ******************************************************************************/
	   1463 
	   1464 #ifdef VMS
	   1465 extern void StringReplace (String str, int pos, int count, String replace)
	   1466 #else
       X   1467 extern void StringReplace (str, pos, count, replace)
       X   1468 
       X   1469   String str;
       X   1470   int    pos;
       X   1471   int    count;
       X   1472   String replace;
       X   1473 #endif
	   1474 
	   1475 {
	   1476   Buffer temp;
	   1477 
	   1478   /* validate */
	   1479   if ((pos < 0) || (pos > strlen(str))) return;
	   1480   if ((pos + count) > strlen(str)) return;
	   1481 
	   1482   /* copy original */
	   1483   strcpy (temp, str);
	   1484 
	   1485   /* copy replacement */
	   1486   strcpy (&temp[pos], replace);
	   1487 
	   1488   /* put back remainder */
	   1489   strcpy (&temp[strlen(temp)], &str[pos + count]);
	   1490 
	   1491   /* copy back */
	   1492   strcpy (str, temp);
	   1493 
	   1494   /* done */
	   1495   return;
	   1496 }


Command Line
------- ----

CC /NOANSI_ALIAS/ASSUME=(ACCURACY_SENSITIVE,ALIGNED_OBJECTS,WRITABLE_STRING_LITERALS)
/DEBUG=(SYMBOLS,TRACEBACK)/ENDIAN=LITTLE/EXTERN_MODEL=RELAXED_REFDEF/FLOAT=(
G_FLOAT)/GRANULARITY=QUADWORD/INSTRUCTION_SET=FLOATING_POINT/L_DOUBLE_SIZE=128
/LIST/NOMACHINE_CODE/MEMBER_ALIGNMENT/NAMES=UPPERCASE/NESTED_INCLUDE_DIRECTORY=INCLUDE_FILE
/OBJECT/NOOPTIMIZE/PREFIX=(ALL_ENTRIES)/PSECT_MODEL=NOMULTILANGUAGE/ROUNDING_MODE=NEAREST
/SHOW=(HEADER,SOURCE)/SIGNED_CHAR/STANDARD=VAXC/REENTRANCY=TOLERANT/WARNINGS
