File: ac_as_dirname.html

package info (click to toggle)
autoconf-archive 20060312-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,180 kB
  • ctags: 13
  • sloc: sh: 455; makefile: 44
file content (129 lines) | stat: -rw-r--r-- 3,277 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
 <head>
  <title>
   Autoconf Macro: ac_as_dirname
  </title>
  <link rel="stylesheet" type="text/css" href="ac-archive.css">
 </head>
 <body>
  <table summary="web navigation" style="width:100%;">
   <tbody>
    <tr>
     <td style="width:50%;" align="center">
      <a href="http://autoconf-archive.cryp.to/ac_as_dirname.m4">Download M4
      Source</a>
     </td>
     <td style="width:50%;" align="center">
      <a href="macros-by-category.html">Macro Index Page</a>
     </td>
    </tr>
   </tbody>
  </table>
  <hr>
  <h1>
   ac_as_dirname
  </h1>
  <h2>
   Obsolete Macro
  </h2>
  <p class="indent">
   Autoconf 2.5x makes this unnecessary.
  </p>
  <h2>
   Synopsis
  </h2>
  <p class="indent" style="white-space:nowrap;">
   <code>AC_AS_DIRNAME (PATH)</code>
  </p>
  <h2>
   Description
  </h2>
  <div class="indent">
   <p>
    this is the macro AS_DIRNAME from autoconf 2.4x defined here for use in
    autoconf 2.1x, remove the AC_ when you use 2.4x
   </p>
  </div>
  <h2>
   Author
  </h2>
  <p class="indent">
   Guido Draheim &lt;guidod@gmx.de&gt;
  </p>
  <h2>
   Last Modified
  </h2>
  <p class="indent">
   2005-01-25
  </p>
  <h2>
   M4 Source Code
  </h2>
  <div class="indent">
   <pre class="m4source">
AC_DEFUN([AC_ECHO_MKFILE],
[dnl
  case $2 in
    */*) P=` AC_AS_DIRNAME($2) ` ; AC_AS_MKDIR_P($P) ;;
  esac
  echo "$1" &gt;$2
])

AC_DEFUN([AC_AS_DIRNAME],
[AC_AS_DIRNAME_EXPR([$1]) 2&gt;/dev/null ||
AC_AS_DIRNAME_SED([$1])
])


# _AC_AS_EXPR_PREPARE
# ----------------
# Some expr work properly (i.e. compute and issue the right result),
# but exit with failure.  When a fall back to expr (as in AS_DIRNAME)
# is provided, you get twice the result.  Prevent this.
AC_DEFUN([_AC_AS_EXPR_PREPARE],
[if expr a : '\(a\)' &gt;/dev/null 2&gt;&amp;1; then
  as_expr=expr
else
  as_expr=false
fi
])# _AC_AS_EXPR_PREPARE


# AS_DIRNAME(PATHNAME)
# --------------------
# Simulate running `dirname(1)' on PATHNAME, not all systems have it.
# This macro must be usable from inside ` `.
#
# Prefer expr to echo|sed, since expr is usually faster and it handles
# backslashes and newlines correctly.  However, older expr
# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
# a silly length limit that causes expr to fail if the matched
# substring is longer than 120 bytes.  So fall back on echo|sed if
# expr fails.
#
# FIXME: Please note the following m4_require is quite wrong: if the first
# occurrence of AS_DIRNAME_EXPR is in a backquoted expression, the
# shell will be lost.  We might have to introduce diversions for
# setting up an M4sh script: required macros will then be expanded there.

AC_DEFUN([AC_AS_DIRNAME_EXPR],
[AC_REQUIRE([_AC_AS_EXPR_PREPARE])dnl
$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
         X[]$1 : 'X\(//\)[[^/]]' \| \
         X[]$1 : 'X\(//\)$' \| \
         X[]$1 : 'X\(/\)' \| \
         .     : '\(.\)'])

AC_DEFUN([AC_AS_DIRNAME_SED],
[echo X[]$1 |
    sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
          /^X\(\/\/\)[^/].*/{ s//\1/; q; }
          /^X\(\/\/\)$/{ s//\1/; q; }
          /^X\(\/\).*/{ s//\1/; q; }
          s/.*/./; q']])
</pre>
  </div>
 </body>
</html>