Archive for May, 2007

Web servers - Comparing and Merging Source Files CHAPTER 6 91

Tuesday, May 8th, 2007

Comparing and Merging Source Files CHAPTER 6 91 *************** *** file1_line_range **** file1 line file1 line… — file2_line_range file2 line file2 line… COMPARING AND MERGING SOURCE FILES The first three lines identify the files compared and separate this information from the rest of the output, which is one or more hunks of differences. Each hunk shows one area where the files differ, surrounded (by default) by two line of context (where the files are the same). Context lines begin with two spaces and differing lines begin with a !, +, or -, followed by one space, illustrating the difference between the files. A + indicates a line in the file2 that does not exist in file1, so in a sense, a + line was added to file1 to create file2. A -marks a line in file1 that does not appear in file2, suggesting a subtraction operation. A ! indicates a line that was changed between file1 and file2; for each line or group of lines from file1 marked with !, a corresponding line or group of lines from file2 is also marked with a !. To generate a context diff, execute a command similar to the following: $ diff -C 1 sigrot.1 sigrot.2 The hunks look like the following: *** sigrot.1 Sun Mar 14 22:41:34 1999 —sigrot.2 Mon Mar 15 00:17:40 1999 **** 2,4 **** # sigrot.sh ! # Version 1.0 # Rotate signatures —2,4 — # sigrot.sh ! # Version 2.0 # Rotate signatures *************** *** 8,19 **** sigfile=signature ! old=$(cat num) let new=$(expr $old+1) ! if [ -f $sigfile.$new ]; then ! cp $sigfile.$new .$sigfile ! echo $new > num else ! cp $sigfile.1 .$sigfile ! echo 1 > num
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services

Web site design and hosting - The Linux Programming Toolkit PART I 90 LISTING

Tuesday, May 8th, 2007

The Linux Programming Toolkit PART I 90 LISTING 6.3 sigrot.1 #!/usr/local/bin/bash # sigrot.sh # Version 1.0 # Rotate signatures # Suitable to be run via cron ############################# sigfile=signature old=$(cat num) let new=$(expr $old+1) if [ -f $sigfile.$new ]; then cp $sigfile.$new .$sigfile echo $new > num else cp $sigfile.1 .$sigfile echo 1 > num fi LISTING 6.4 sigrot.2 #!/usr/local/bin/bash # sigrot.sh # Version 2.0 # Rotate signatures # Suitable to be run via cron ############################# sigfile=signature srcdir=$HOME/doc/signatures srcfile=$srcdir/$sigfile old=$(cat $srcdir/num) let new=$(expr $old+1) if [ -f $srcfile.$new ]; then cp $srcfile.$new $HOME/.$sigfile echo $new > $srcdir/num else cp $srcfile.1 $HOME/.$sigfile echo 1 > $srcdir/num fi Context hunk format takes the following form: *** file1 file1_timestamp — file2 file2_timestamp
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

Web hosting isp - Comparing and Merging Source Files CHAPTER 6 89

Tuesday, May 8th, 2007

Comparing and Merging Source Files CHAPTER 6 89 < Trust in the Lord with all your heart, < And do not rely on your own understanding. < In all your ways acknowledge Him, < And He will make your paths smooth. > Trust in the Lord with all your heart > and lean not on your own understanding; > in all your ways acknowledge him, > and he will make your paths straight. The output is in normal format, showing only the lines that differ, uncluttered by context. This output is the default in order to comply with Posix standards. Normal format is rarely used for distributing software patches; nevertheless, here is a brief description of the output, or hunk format. The general normal hunk format is as follows: change_command < file1 line < file1 line... > file2 line > file2 line… change_command takes the form of a line number or a comma- separated range of lines from file1, a one character command, and a line number or comma-separated range of lines from file2. The character will be one of the following: a add d delete c change The change command is actually the ed command to execute to transform file1 into file2. Looking at the hunk above, to convert jps to niv, we would have to change lines 1 4 of jps to lines 1 4 of niv. The Context Output Format As noted in the preceding section, normal hunk format is rarely used to distribute software patches. Rather, the context or unified hunk formats diff produces are the preferred formats to patches. To generate context diffs, use the -c, context=[NUM], or -C NUM options to diff. So-called context diffs show differing lines surrounded by NUM lines of context, so you can more clearly understand the changes between files. Listings 6.3 and 6.4 illustrate the context diff format using a simple bash shell script that changes the signature files appended to the bottom of email and Usenet posts. (No line numbers were inserted into these listings in order to prevent confusion with the line numbers that diff produces.) COMPARING AND MERGING SOURCE FILES
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

The Linux Programming Toolkit PART I 43 40

Monday, May 7th, 2007

The Linux Programming Toolkit PART I 43 40 154 l … 148 157 o 164 t 149 164 t 56 . 150 150 h 12 ^J 151 56 . 12 ^J cmp: EOF on niv Using -cl results in more immediately readable output, in that you can see both the encoded characters and their human-readable translations for each character that differs. Understanding the diff Command The diff command shows the differences between two files, or between two identically named files in separate directories. You can direct diff, using command line options, to format its output in any of several formats. The patch program, discussed in the section Preparing Source Code Patches later in this chapter, reads this output and uses it to recreate one of the files used to create the diff. As the authors of the diff manual say, If you think of diff as subtracting one file from another to produce their difference, you can think of patch as adding the difference to one file to reproduce the other. Because this book attempts to be practical, I will focus on diff s usage from a programmer s perspective, ignoring many of its options and capabilities. While comparing files may seem an uninteresting subject, the technical literature devoted to the subject is extensive. For a complete listing of diff s options and some of the theory behind file comparisons, see the diff info page (info diff). The general syntax of the diff command is diff [options] file1 file2 diff operates by attempting to find large sequences of lines common to file1 and file2, interrupted by groups of differing lines, called hunks. Two identical files, therefore, will have no hunks and two complete different files result in one hunk consisting of all the lines from both files. Also bear in mind that diff performs a line-by-line comparison of two files, as opposed to cmp, which performs a character-by-character comparison. diff produces several different output formats. I will discuss each them in the following sections. The Normal Output Format If we diff Listings 6.1 and 6.2 (jps and niv, respectively, on the CD-ROM), the output is as follows: $ diff jps niv 1,4c1,4
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services

Bulletproof web design - Comparing and Merging Source Files CHAPTER 6 87

Monday, May 7th, 2007

Comparing and Merging Source Files CHAPTER 6 87 LISTING 6.2 NIV VERSION OF PROVERBS 3:5-6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make your paths straight. COMPARING AND MERGING SOURCE FILES A bare cmp produces the following: $ cmp jps niv jps niv differ: char 38, line 1 Helpful, yes? We see that the first difference occurs at byte 38 one line 1. Adding the -c option, cmp reports: $ cmp -c jps niv jps niv differ: char 38, line 1 is 54 , 12 ^J Now we know that the differing character is decimal 52, a control character, in this case. Replacing -c with -l produces the following: $ cmp -l jps niv 38 54 12 39 12 141 40 101 156 41 156 144 42 144 40 43 40 154 … 148 157 164 149 164 56 150 150 12 151 56 12 cmp: EOF on niv The first column of the preceding listing shows the character number where cmp finds a difference, the second column lists the character from the first file, and the third column the character from the second file. Note that the second to last line of the output ( 151 56 12) may not appear on some Red Hat systems. Character 38, for example, is octal 54, a comma (,) in the file jps, while it is octal 12, a newline, in the file niv. Only part of the output is shown to save space. Finally, combining -c and -l yields the following: $ cmp -cl jps niv 38 54 , 12 ^J 39 12 ^J 141 a 40 101 A 156 n 41 156 n 144 d 42 144 d 40
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

Cheap web hosting - The Linux Programming Toolkit PART I Programmers often

Monday, May 7th, 2007

The Linux Programming Toolkit PART I Programmers often need to quickly identify differences between two files, or to merge two files together. The GNU project s diff and patch programs provide these facilities. The first part of this chapter shows you how to create diffs, files that express the differences between two source code files. The second part illustrates using diffs to create source code patches in an automatic fashion. Comparing Files The diff command is one of a suite of commands that compares files. It is the one on which we will focus, but first we briefly introduce the cmp command. Then, we cover the other two commands, diff3 and sdiff, in the following sections. Understanding the cmp Command The cmp command compares two files, showing the offset and line numbers where they differ. Optionally, cmp displays differing characters side-by-side. Invoke cmp as follows: $ cmp [options] file1 [file2] A hyphen (-) may be substituted for file1 or file2, so cmp may be used in a pipeline. If one filename is omitted, cmp assumes standard input. The options include the following: -c|–print-chars Print the first characters encountered that differ -I N|–ignore-initial=N Ignore any difference encountered in the first N bytes -l|–verbose Print the offsets of differing characters in decimal format and the their values in octal format -s|–silent|–quiet Suppress all output, returning only an exit code. 0 means no difference, 1 means one or more differences, 2 means an error occurred. -v|–version Print cmp s version information From a programmer s perspective, cmp is not terribly useful. Listings 6.1 and 6.2 show two versions of Proverbs 3, verses 5 and 6. The acronyms JPS and NIV stand for Jewish Publication Society and New International Version, respectively. LISTING 6.1 JPS VERSION OF PROVERBS 3:5-6 Trust in the Lord with all your heart, And do not rely on your own understanding. In all your ways acknowledge Him, And He will make your paths smooth.
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

Web hosting asp - CHAPTER 6 Comparing and Merging Source Files by

Monday, May 7th, 2007

CHAPTER 6 Comparing and Merging Source Files by Kurt Wall IN THIS CHAPTER Comparing Files 86 Preparing Source Code Patches 98
Note: If you are looking for high quality webhost to host and run your jsp application check Vision florida web design services

84 (Web hosting company)

Sunday, May 6th, 2007

84
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services

Creating Self-Configuring Software with (Business web site) autoconf CHAPTER 5 83

Sunday, May 6th, 2007

Creating Self-Configuring Software with autoconf CHAPTER 5 83 You can see that linker, ld, failed because it could not find the socket library, libsocket. The line numbers in the snippet refer to the configure script line numbers being executed. Although it is a bit involved and tedious to set up, using autoconf provides many advantages for software developers, particularly in terms of code portability among different operating systems and hardware platforms and in allowing users to customize software to the idiosyncrasies of their local systems. You only have to perform autoconf s set up steps once thereafter, minor tweaks are all you need to create and maintain self-configuring software. Summary This chapter took a detailed look at autoconf. After a high level overview of autoconf s use, you learned about many built-in macros that autoconf uses to configure software to a target platform. In passing, you also learned a bit about the wide variety of systems that, while all basically the same, vary just enough to make programming for them a potential nightmare. Finally, you walked step-by-step through creating a template file, generating a configure script, and using it to generate a makefile, the ultimate goal of autoconf. CREATING SELF CONFIGURING SOFTWARE WITH autoconf
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services

The Linux Programming Toolkit PART I 82 With

Sunday, May 6th, 2007

The Linux Programming Toolkit PART I 82 With the template created, type autoconf in the directory where you created configure.in, which should be the root of your source tree. You will see two warnings (on lines 48 and 63), and wind up with a shell script named configure in your current working directory. To test it, type ./configure. Figure 5.1 shows configure while it is executing. FIGURE 5.1 configure while running. If all went as designed, configure creates Makefile, config.h, and logs all of its activity to config.log. You can test the generated Makefile by typing make. The log file is especially useful if configure does not behave as expected, because you can see exactly what configure was trying to do at a given point. For example, the log file snippet below shows the steps configure took while looking for the socket() function (see line 24 of configure.in). configure:979: checking for socket in -lsocket configure:998: gcc -o conftest -g -O2 -I/usr/include conftest.c -lsocket 1>&5 /usr/bin/ld: cannot open -lsocket: No such file or directory collect2: ld returned 1 exit status configure: failed program was: #line 987 configure #include confdefs.h /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char socket(); int main() { socket() ; return 0; }
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services