# python 3.2 autoconf awk problem



## gmele (Oct 26, 2011)

Hi,

I'm having a problem on FreeBSD8.2 when installing pycrypto-2.4 that was downloaded from github as a .gz. This is a python application with c libraries. My problem is with awk in the build_configuration step.  I've tried gawk, but the result is identical. It installs on other systems, but not FreeBSD 8.2. Hope this is the right place and there's not too much detail here.

The build_configuration step runs a configuration file that was created by autoconf and checks for standard c includes before attempting any compiles. In the final step it creates a file named defines.awk then uses it to run awk on the default config.h.in to create the actual config.h. The defines.awk file looks good (all the include files are found), but running awk produces a config.h file that is identical to config.h.in. I ran some tests.  The problem is that the pattern used in defines.awk doesn't match any lines in config.h.in.

defines.h (a piece)

```
/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ {
```

config.h.in (a piece)

```
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
```

The part of the pattern that does not match is ([\t (]|$) -- It DOES match if I add a space after HAVE_STDINT_H

Anyone have any ideas?

Gary


----------



## Carpetsmoker (Oct 26, 2011)

Who don't you install the port?
security/py-pycrypto


----------



## gmele (Oct 26, 2011)

Thanks for the suggestion.

security/py-pycrypto doesn't build with python3.2.

I'm trying to learn python3.2 by converting an existing program that uses pycrypto.

Gary


----------



## geodni (Oct 26, 2011)

Your pattern seems OK, i tried with several possibilities.
Maybe it's inside the braces that i does not do what it is supposed to do after matching. Try add a single command at the begining inside the braces t below.
I tried using a textfile /tmp/zz showed in vi with option":set list" that show end of line as "$" and tabulations as "^I" like that

```
/* Define to 1 if you have the <stdint.h> header file. */$
#undef HAVE_STDINT_H$
#undef HAVE_STDINT_H $
#define HAVE_STDINT_H(zz)$
#define HAVE_STDINT_H 23$
$
#undef^IHAVE_STDINT_H$
#undef HAVE_STDINT_H^I$
#define HAVE_STDINT_H(zz)$
#define HAVE_STDINT_H^I23$
$
```

awk script file is /tmp/zz.awk

```
/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGH
IJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ { print "line "NR" matching" }
```
[cmd=]awk -f /tmp/zz.awk /tmp/zz[/cmd] produces this output

```
line 2 matching
line 3 matching
line 4 matching
line 5 matching
line 7 matching
line 8 matching
line 9 matching
line 10 matching
```
Line 1 and 6 does not match, it's normal.


----------



## gmele (Oct 26, 2011)

Thanks for reminding me to simplify everything.

I took out everything except the part that fails and put in the print.
The pattern is still not matching what it should.

defines.awk (the entire file)

```
/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ {
print "line" NR
}
```

config.h.in (the entire file)

```
/* src/config.h.in.  Generated from configure.ac by autoheader.  */

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
   #define below would cause a syntax error. */
#undef _UINT32_T
```

Running the command
`# awk -f defines.awk config.h.in`
gives:

```
line8
```

The pattern only matches a comment line that happens to have the right word.
It looks like $ cannot be used inside of  (), as in ([\t ]|$)

My awk version is  - 20091126 (FreeBSD)
Is this the latest?  What version do you have?

Gary


----------



## geodni (Oct 26, 2011)

I use the same version as you, but my output is different :

```
line4
line8
line9
```
Can you edit your file config.h.in with vi and set the option ":set list", then copy paste the output inside code tags.


----------



## gmele (Oct 26, 2011)

That's it! :e

config.h.in has \r\n at the end of each line.  Taking out the \r fixes the problem.

Thanks a bunch.

Gary


----------



## geodni (Oct 26, 2011)

You're welcome!
We just have to wait for a moderator to mark this thread as SOLVED.


----------

