Sponsored Content
Top Forums Programming A C program required for portability Post 28593 by mbb on Friday 20th of September 2002 12:34:55 PM
Old 09-20-2002
Ok. To answer the second part first. To strip out carriage returns from your input file do:

awk '{printf("%s"), $0}' filename > newfile

The awk command should be standard across most Unix O/S.


In HP-UX use the functions: regcomp, regexec. These functions allow you to process regular expressions. In other words you may search a string for a pattern (like the ones you have described).

Sorry I don't have time to explain these functions in depth or write you a little test program, but regexec will point you to where it finds the first match in your line (in a pointer). If you called the function again it will return a pointer to the next pattern in your string. To work out the number of characters between each expression found you would subtract the first pointer value from the second pointer value and so on ...

I do know that you may have portability issues with the regexec and regcomp functions. When my trainee wrote a program and ported it to windows he found that a different library with different function names was required. To make matters worse the windows functions had different rules for regular expressions.
I would not be surprised if you encountered similiar issues between different flavours of Unix.

If portability is an issue you may have to write your own parsing algorithms ...

Sorry I can't be more help but I have run out of time ...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Very Urgent help required in Shell Program

How do I Ftp, and rename multiple files in one unix script. I have to send it with .tmp extension , then rename it to .txt after FTP is done . I need to do a Mass rename of more than 1 file in a shell script , Urgent help required. (1 Reply)
Discussion started by: Suppandi
1 Replies

2. UNIX for Dummies Questions & Answers

Shell program:Help required on file formating

I have two files file1 and file2 as shown below: file1: name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 I have pasted one file on the other with the delimiter "|" and the resulttant file is: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 (6 Replies)
Discussion started by: udiptya
6 Replies

3. UNIX for Dummies Questions & Answers

Script portability

Hello, May I the right place if I need competencies to migrate DOS script into Unix platforme? Thanks in advance Thierry (9 Replies)
Discussion started by: tsconetti
9 Replies

4. Shell Programming and Scripting

portability issue linux(2.6) solaris10

the following simple scripts work fine on linux but fail on solaris: #!/bin/bash eval /usr/bin/time -f \'bt=\"%U + %S\"\' ./JUNK >> ./LOG 2>&1 cp ./LOG ./LOG_joe LC_joe=`cat ./LOG | wc -l` LC_joe=`echo $LC_joe-1|bc` tail -1 ./LOG > ./tmp head -$LC_joe ./LOG_joe > ./LOG rm ./LOG_joe ... (1 Reply)
Discussion started by: joepareti
1 Replies

5. Shell Programming and Scripting

Script Portability

Hi, I am writing a BASH shell script for a client. I am using BASH on a Macintosh Powerbook G4 running Leopard. My client will be using BASH on a PC running Ubuntu. My questions all revolve around making my script portable so that it will run on his machine. - Do I need to get any other... (2 Replies)
Discussion started by: msb65
2 Replies

6. UNIX for Dummies Questions & Answers

portability of int arrays from 32 to 64 bit systems

Dear All, I'm porting my scientific program from 32 to 64 bit system (use gcc, CentOS) and feel myself absolutely confused after reading general internet advices for that. Could you help me, please. The question is: can I use "old style" on 64 bit: -------- int * myIntArray; ... (3 Replies)
Discussion started by: German1234
3 Replies

7. Shell Programming and Scripting

simple program help required

The circumfrence of a circle is #!/usr/bin/perl print 2 * 3.141592654 * 12.50 \n"; # pi= 3.141592654 # r= 12.50 I need a simple program showing me all the steps..to modify the above to prompt for and accept a radius from the person running the... (3 Replies)
Discussion started by: Q2wert
3 Replies

8. Programming

Why is required to leave an empty line at the end of a C program?

I know it looks like a stupid question, but i really wanna know the reason. Actually, i think it's because the c compiler will detect it as the end of file "EOF" of the program, but, am i wrong? because it compiles it anyway, but keep showing warnings like "no new line at the end of file". I... (8 Replies)
Discussion started by: semash!
8 Replies

9. Shell Programming and Scripting

help required in program

I have below code, i need to modify it, to search for files (*.php,*.css,*.html) in those directores which have 777 permission, how to modify this code. Because it is moving all files. while true do sleep 60 DATE=$(date +%Y-%m-%d) # Creates dir only if it... (21 Replies)
Discussion started by: learnbash
21 Replies
regcmp(1)                                                          User Commands                                                         regcmp(1)

NAME
regcmp - regular expression compile SYNOPSIS
regcmp [-] filename... DESCRIPTION
The regcmp command performs a function similar to regcmp and, in most cases, precludes the need for calling regcmp from C programs. Bypass- ing regcmp saves on both execution time and program size. The command regcmp compiles the regular expressions in filename and places the output in filename.i. OPTIONS
- If the - option is used, the output is placed in filename.c. The format of entries in filename is a name (C variable) followed by one or more blanks followed by one or more regular expressions enclosed in double quotes. The output of regcmp is C source code. Compiled regular expressions are represented as extern char vectors. filename.i files may thus be #included in C programs, or filename.c files may be compiled and later loaded. In the C program that uses the regcmp output, regex(abc,line) applies the regu- lar expression named abc to line. Diagnostics are self-explanatory. EXAMPLES
Example 1: Examples of the regcmp command. name "([A-Za-z][A-Za-z0-9_]*)$0" telno "({0,1}([2-9][01][1-9])$0){0,1} *" "([2-9][0-9]{2})$1[ -]{0,1}" "([0-9]{4})$2" The three arguments to telno shown above must all be entered on one line. In the C program that uses the regcmp output, regex(telno, line, area, exch, rest) applies the regular expression named telno to line. ENVIRONMENT VARIABLES
A general description of the usage of the LC_* environmental variables can be found in environ(5). LC_CTYPE Determines how regcmp handles characters. When LC_CTYPE is set to a valid value, regcmp can display and handle text and filenames containing valid characters for that locale. LC_MESSAGES Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses. In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWtoo | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
regcmp(3C), attributes(5), environ(5) SunOS 5.10 Dec 20 1996 regcmp(1)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy