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
SQL_REGCASE(3)								 1							    SQL_REGCASE(3)

sql_regcase - Make regular expression for case insensitive match

SYNOPSIS
string sql_regcase (string $string) DESCRIPTION
Creates a regular expression for a case insensitive match. Warning This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. PARAMETERS
o $string - The input string. RETURN VALUES
Returns a valid regular expression which will match $string, ignoring case. This expression is $string with each alphabetic character con- verted to a bracket expression; this bracket expression contains that character's uppercase and lowercase form. Other characters remain unchanged. EXAMPLES
Example #1 sql_regcase(3) example <?php echo sql_regcase("Foo - bar."); ?> The above example will output: [Ff][Oo][Oo] - [Bb][Aa][Rr]. This can be used to achieve case insensitive pattern matching in products which support only case sensitive regular expressions. NOTES
Note As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE. PHP Documentation Group SQL_REGCASE(3)
All times are GMT -4. The time now is 08:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy