• Aucun résultat trouvé

programmer's UNIX*

N/A
N/A
Protected

Academic year: 2022

Partager "programmer's UNIX*"

Copied!
641
0
0

Texte intégral

(1)
(2)

* Trademark of AT&T.

LANGUAGES AND SUPPORT TOOLS

UNIX*

programmer's manual

CBS COLLEGE PUBLISHING'S UNIX SYSTEM LIBRARY

(3)

ATs.T

VOLUME 5

LANGUAGES AND SUPPORT TOOLS

UNIX*

programmer's manual

CBS COLLEGE PUBLISHING'S UNIX SYSTEM LIBRARY

Steven V. Earhart: Editor

HOLT, RINEHART AND WINSTON New York Chicago San Francisco Philadelphia

Montreal Toronto London Sldney Tokyo Mexico City Rio de Janeiro Madrid

* Trademark of AT&T.

(4)

no liability to any party for any loss or damage caused by errors or omissions or statements of any kind in the UNIX* Programmer's Manual, its updates, supplements, or special editions, whether such errors are omissions or statements resulting from negligence, accident, or any other cause. AT&T further assumes no liability arising out of the application or use of any product or system described herein; nor any liability for incidental or consequential damages arising from the use of this document. AT&T disclaims all warranties regarding the information contained herein, whether expressed, implied or statutory, including implied warranties or merchantability or fitness for a particular purpose.

AT&T reserves the right to make changes without further notice to any products herein to improve reliability, function or design.

This document was set on an AUTOLOGIC, Inc. APS-5 phototypesetter driven by the TROFF formatter operating under the UNIX system on an AT&T 3B20 computer.

* Trademark of AT&T.

Copyright© 1986 AT&T All rights reserved.

Address correspondence to:

383 Madison A venue New York, NY 10017

No part of this publication may be reproduced, transmitted or used in any form or by any means-graphic, electronic, mechanical or chemical, including photocopying, recording in any medium, taping, by any computer or information storage and retrieval systems, etc. without prior permission in writing from AT&T.

Library of Congress Cataloging-in-Publication Data UNIX programmer's manual.

At head of title: AT&T Inclues index.

Contents: v. 1. Commands and utilities-v. 2.

System calls and library routines-v. 3. System

administration facilities.-v. 4. Document Preparation. -v. 5. Languages and support tools.

1. UNIX (Computer operating system) I. Earhart, Steven V. II. American Telephone and Telegraph Company.

QA76.76.063U548 1986 005.4'3 86-311

Select Code 320-035 ISBN 0-03-011204-4

Printed in the United States of America Published simultaneously in Canada 67809098765432

CBS COLLEGE PUBLISHING Holt, Rinehart and Winston The Dryden Press Saunders College Publishing

(5)

PREFACE

The UNIX Programmer's Manual describes most of the features of the UNIX System V. It does not provide a general overview of the UNIX system nor details of the implementation of the system.

Not all commands, features, or facilities described in this series are available in every UNIX system implementation. For specific questions on a machine implementation of the UNIX system, consult your system administrator.

The UNIX Programmer's Manual is available in several volumes.

• Volume 1 contains the Commands and Utilities (sections 1 and 6)

• Volume 2 contains the System Calls and Library Routines (sections 2,3,4, and 5).

• Volume 3 contains the System Administration Facilities (sections 1M, 7, and 8).

• Volume 4 contains the Document Preparation Facilities (mm, tbl, etc.).

• Volume 5 contains the Languages and Support Tools (C language, lex, make, etc.).

UNIX Programmer's Manual Languages and Support Tools-i

(6)
(7)

INTRODUCTION

This volume of the UNIX. Programmer's Manual describes the languages and support tools that are available on most UNIX operation system implementations. These facilities are not available on all implemntations, for specific information as to availability consult your system administrator.

Two main programming languages are supported on the UNIX system. The languages include:

• C Language - A medium-level programming language which was used to write most of the UNIX operating system. Discussion includes the following:

C LANGUAGE- provides a summary of the grammar and rules of the C programming language. The. C language as it is implemented on most computers including the AT&T 3B computers, the PDP:f:-ll computer, and the VAX:f:-1l/780 computer. Where differences exist, these chapters try to point out implementation-dependent details. With few exceptions, such dependencies follow directly from the properties of the hardware.

The various compilers are generally quite compatible. Computers not listed in the examples, probably follow the same rules and guidelines. Consult your system support group for information.

LIBRARIES- describe functions and declarations that support the C Language and how to use these functions. Both the C Library and the Object File and Math Libraries are discussed.

THE "cc" COMMAND- describes the command used to compile C language programs, produce assembly language programs, and produce executable programs.

A C PROGRAM CHECKER - "lint" - describes a program that attempts to detect compile-time bugs and non-portable features in C programs.

* Trademark of AT&T.

:j: Trademarks of Digital Equipment Corporation

UNIX Programmer's Manual Languages and Support Tools-iii

(8)

programs.

• Fortran - Fortran 77, and rational Fortran preprocessor (Ratfor) are described as follows:

UNIX SYSTEM COMMANDS FOR FORTRAN- describes the various commands that may be used with Fortran on most UNIX system.

FORTRAN 77- describes the implementation of Fortran 77 on the UNIX system in terms of the variations from the American National Standard.

RATFOR- describes the Ratfor preprocessor. This preprocessor provides a means for writing Fortran in a fashion similar to the C language. This preprocessor provides '(among other things) simplified control-flow statements.

EFL- descibes a general purpose computer language intended to encourage portable programming. It has a uniform and readable syntax and good data and control flow structuring. EFL programs can be translated into efficient Fortran code, so the EFL programmer can take advantage of the ubiquity of Fortran, the valuable libraries of software written in that language, and the portability that comes with the use of a standardized language.

The following paragraphs contain a brief description of the support tools that aid in program development.

• A PROGRAM FOR MAINTAINING COMPUTER PROGRAMS {make} - describes a software tool for maintaining, updating, and regenerating groups of computer programs. The many activities of program development and maintenance are made simpler by the make program.

• AUGMENTED VERSION OF "make" - is now combined with A PROGRAM FOR MAINTAINING COMPUTER PROGRAMS

(make).

(9)

• SOURCE CODE CONTROL SYSTEM (SCCS) USER'S GUIDE- describes the collection of

sees

programs under the UNIX operating system. The

sees

programs act as a "custodian" over the UNIX system files.

• M4 MACRO PROCESSOR- describes a general purpose macro processor that may be used as a front end for rational Fortran,

e,

and other programming languages.

• "awk" PROGRAMMING LANGUAGE- describes a software tool designed to make many common information retrieval and text manipulation tasks easy to state and to perform.

• LINK EDITOR- describes a software tool (Jd) that creates load files by combining object files, performing relocation, and resolving internal references.

• COMMON OBJECT FILE FORMAT (COFF) - describes the output file produced on some UNIX systems by the assembler and the link editor.

• ARBITRARY PRECISION DESK CALCULATOR LANGUAGE (BC) - describes a compiler for doing arbitrary precision arithmetic on the UNIX operating system.

• INTERACTIVE DESK CALCULATOR (DC) - describes a program implemented on the UNIX operating system to do arbitrary-precision integer arithmetic.

• LEXICAL ANALYZER GENERATOR (Lex) - describes a software tool that lexically processes character input streams.

• YET ANOTHER COMPILER-COMPILER (yacc) - describes the yacc program. The yacc program provides a general tool for imposing structure on the input to a computer program.

• UNIX SYSTEM TO UNIX SYSTEM COpy (UUCP) - describes a network that provides information exchange (between UNIX systems) over the direct distance dialing network.

The support tools provide an added dimension to the basic UNIX software commands. The "tools" described enable the user to fully utilize the UNIX operating system.

It is assumed that the user of this document has at least two years of specialized training in computer-related fields. The user is also expected to use the UNIX system for software development.

Throughout this document, each reference of the form name (1 M), name (7); or name(S) refers to entries in the UNIX Programmer's Manual-Volume 3:

System Administration Facilities. Each reference of the form name (1) and UNIX Programmer's Manual Languages and Support Tools-v

(10)

where possibly followed by a letter, refer to entry name in section N of the UNIX Programmer's manual- Volume 2: System Calls and Library Routines.

(11)

TABLE OF CONTENTS LANGUAGES

C LANGUAGE • • • • • • • • LEXICAL CONVENTIONS

Comments • • • • • . Identifiers (Names) Keywords • • • • Constants • • • • • Strings . • • • . Hardware Characteristics

DEC PDP-II HARDWARE CHARACTERISTICS DEC VAX-II HARDWARE CHARACTERISTICS AT&T 3B HARDWARE CHARACTERISTICS.

SYNTAX NOTATION . . • . •

NAMES . . • • •

Storage Class Type . . . •

OBJECTS AND LVALUES . CONVERSIONS • . • . .

Characters and Integers Float and Double • • . Floating and Integral • . Pointers and Integers . • Unsigned . • . • . • . Arithmetic Conversions • Void . . . . • . . EXPRESSIONS. • .

Primary Expressions Unary Operators. .

Multiplicative Operators . . • . • Additive Operators. •

Shift Operators • • . • Relational Operators • . Equality Operators . . • Bitwise AND Operator Bitwise Exclusive OR Operator Bitwise Inclusive OR Operator . Logical AND Operator

Logical OR Operator . • Conditional Operator • . Assignment Operators Comma Operator . . . DECLARATIONS

Storage Class Specifiers . Type Specifiers . . . .

• . • 1

• • • • • • • • • 1

• • 1

• • 1

• 1

• • 2 .3 .4

· .4

· .5 .5

· • 6 . 6

· .6

· .7

• • 8

· .8

• • 8

· .9

• • 9

• • • • • • • • 9

· .9 . . . . • • • • 10 . 10

• • 11

• • 11

• •• 14

• . . . • . . • • 16

· • . 16

• • • • • 17

· • • . • . • • . 18

• •• 18

· • . . • . • • . 18

· •• 19

· . 19

• •• 19

· .20

· .20

• • • • • • • • • 20

• • 21

· • . 22

· .22

• • • • • • • • • 23

· .24

• • • • • • • • • 25

· .27

• •• 30 Declara tors . • • . . •

Meaning of Declarators . Structure and Union Declarations Enumeration Declarations . • Initialization • . . . . Type Names

• • • • 32

• • • • • • • • • • • • • 34

Typedef • . • •• 35

STATEMENTS . . • . • • . • • • • • • • • • • • 36

Expression Statement. . • •• 36

UNIX Programmer's Manual Languages and Support Tools-vii

(12)

While Statement Do Statement • • For Statement. . . Switch Statement Break Statement •

Continue Statement • • . • • Return Statement . •

Goto Statement • . • Labeled Statement . . Null Statement • • .

EXTERNAL DEFINITIONS . • External Function Definitions External Data Definitions SCOPE RULES. . • .

Lexical Scope . . . • • . . Scope of Externals . • • COMPILER CONTROL LINES

Token Replacement . • . • • . • • File Inclusion. . . • • . •

Conditional Compilation . . • • . Line Control • • • • •

IMPLICIT DECLARATIONS TYPES REVISITED. . •

Structures and Unions • . • • Functions • • • • . • • . . •

Arrays, Pointers, and Subscripting • • • • . Explicit Pointer Conversions • • •

CONSTANT EXPRESSIONS ••

PORTABILITY CONSIDERATIONS.

SYNTAX SUMMARY Expressions • • • • • Declarations

Statements • • . • • External definitions Preprocessor

C LIBRARIES . • • • • GENERAL • • • . • •

Including Functions Including Declarations THE C LIBRARY

Input/Output Control File Access Functions File Status Functions • Input Functions • • • • Output Functions • • • Miscellaneous Functions String Manipulation Functions.

Character Manipulation Character Testing Functions Character Translation Functions •

• .37 . • • • 37

· .38

• • 38

· .39

· .40

· .40

· .40

• • 41

• • 41

· • 41

· .42

· .43

· .43

· .44 .45

• .45

· .46

· .47

· .47

• .49

• .49

• .49

· .50

· . 51

• • • • 51

• .52

• • 53

• .54

· .55

· .55

· .57

· .60

• • 61

· .62

· .63

· .63

· .64

· .64

· .65

· .65

• .66

· .67

· .67

• • 68

• .69

· .70

· .71

· .72

· .73

(13)

Time Functions • • • . • • . • • • Miscellaneous Functions

Numerical Conversion • . • . • • • DES Algorithm Access .

Group File Access . . • Password File Access • Parameter Access . . . Hash Table Management . Binary Tree Management • • Table Management

Memory Allocation

Pseudorandom Number Generation • . Signal Handling Functions

Miscellaneous • • . • • • • • . . •

THE OBJECT AND MATH LIBRARIES • • . • GENERAL . • . • . . . • • • . • • • • • • THE OBJECT FILE LIBRARY • • • • • • . . Common Object File Interface Macros (ldfcn.h)

• .73 .74

• • 74

• • 75

• . • • • 76 .77 . • . • • . • • • 77 .78

• .79 .79 .80

• •• 81

· •• 82 .82

• • 85

• • 85

• 85

• 88

THE MATH LIBRARY. . • . • • . • .89

.90 Trigonometric Functions

Bessel Functions . . . . Hyperbolic Functions. . • Miscellaneous Functions

COMPILER AND C LANGUAGE USE OF THE COMPILER. . COMPILER OPTIONS . • • • •

A C PROGRAM CHECKER-"lint"

GENERAL • • • • • .

Usage . . . • • . • . • . TYPES OF MESSAGES . • . • •

Unused Variables and Functions Set/Used Information . Flow of Control Function Values Type Checking . Type Casts

Nonportable Character Use Assignments of "longs" to "ints"

Strange Constructions • • • • . Old Syntax • • • • . • • . • Pointer Alignment . • • . . Multiple Uses and Side Effects •

.90

• • 91

• 91

• .93

· .93

• •• 94

97 97 97 99 99

· .100

• • 101

• .102

• .103 .104

• • 105

• 105

• •• 105

• 107

• • 108

• • 108

SYMBOLIC DEBUGGING PROGRAM-"sdb" • . • • . • • • • • . • • . 111

UNIX Programmer's Manual Languages and Support Tools-ix

(14)

• 113 Examining Variables •• • • • • •

SOURCE FILE DISPLAY AND MANIPULATION • • Displaying the Source File • • . • • • • • • • • . Changing the Current Source File or Function • • • Changing the Current Line in the Source File

• • 113

• • 117 .117

· • 118 A CONTROLLED ENVIRONMENT FOR PROGRAM TESTING

• • 118 . • • • 119 Setting and Deleting Breakpoints • • • . • • • •

Running the Program • • • • • • • • • • Calling Functions . • • • • • • • . . • . MACHINE LANGUAGE DEBUGGING • .

Displaying Machine Language Statements Manipulating Registers • . • . • . . • . • . OTHER COMMANDS • . . • . • • • • •

• .119

· .120 .122 . . • • 122 . • • . • . • 122

• 123

• . 123

FORTRAN UNIX SYSTEM COMMANDS • • • • • • . • . . . • • • • 127

FORTRAN 77 • • • . . • . • • USAGE • . • • • . • . • . . LANGUAGE EXTENSIONS

Double Complex Data Type Internal Files. • . • . • • . Implicit Undefined Statement Recursion • • • . . • • . • Automatic Storage • . . . . Variable Length Input Lines . Include Statement . • • • • Binary Initialization Constants Character Strings. . . • Hollerith • • • . • . Equivalence Statements One-Trip DO Loops . . • Commas in Formatted Input . Short Integers . . • . • • . Additional Intrinsic Functions VIOLATIONS OF THE STANDARD

Double Precision Alignment • • . Dummy Procedure Arguments . . T and TL Formats • . . . INTERPROCEDUREINTERFACE

Procedure Names . . Data Representations Return Values • Argument Lists. . . FILE FORMATS

Structure of Fortran Files . . • . . Preconnected Files and File Positions

• 129

· 129

• . 129

· .130 .130

• 130

• • 130

· • 131

• 131

· 131

· • 132

· • 132

• 133

· 133

• • 133

· • 134

· .134 .135 .138

• .138

· • 138

· .139

· .139

• 139 .139 . . . • . 140

· 141

· 142

· . 142 . • . • • . . 143

(15)

RATFOR • . • • . . • • • . • GENERAL • • . • • . • • • USAGE . . . . • • • • • . • STATEMENT GROUPING ••

THE "if-else" CONSTRUCTION Nested "if' Statements • . • • • . THE "switch" STATEMENT • • • • THE "do" STATEMENT • • • . . THE "break" AND "next" STATEMENTS THE "while" STATEMENT . • • • THE "for" STATEMENT • • • . THE "repeat-until" STATEMENT THE "return" STATEMENT THE "define" STATEMENT THE "include" STATEMENT • FREE-FORM INPUT

TRANSLATIONS • . • • . WARNINGS • . • . . . •

EXAMPLE OF RAT FOR CONVERSION

THE PROGRAMMING LANGUAGE EFL . INTRODUCTION •

LEXICAL FORM . . • . • Character Set

Lines . . • • . • Tokens . . • . • Macros . . • . • PROGRAM FORM

Files • . . . Procedures . •

Blocks . • . • . • . • • • Statements . • . • . • • • Labels

DATA TYPES AND VARIABLES. . Basic Types

Constants Variables • . Arrays Structures . EXPRESSIONS

Primaries • .

Parentheses • • • . • • • Unary Operators

Binary Operators Dynamic Structures . • Repetition Operator . • Constant Expressions DECLARATIONS •

Syntax • • • . • . • Attributes • • • • • • Variable List . • • . • The Initial Statement

EXECUTABLE STATEMENTS.

UNIX Programmer's Manual

• • 145

• 145

• • • • • • • 145

• • • • • • • 146

• • 147

• • • • • • 148

• 149

• • 150

• • 150

• • 151

· • 152

• • • • • • • 153

• • 154

• • • • • 155

• • 155

• • 156

• • • • 156

• • • • • • • 158

• • • • • • • •• 158

• • 161

· • • • 161

· • • • 162

• • • • • • . • • • • • • 162

· • • . 162

• •• 164

• • • • • • • 166

• 167

· • • • 167

• •• 167

• 167

· • • • 168

· • • • 169

• 169

• •• 169

• •• 170

· • • • 171

• •• 171

• 172

• •• 172

• 173

• 176

• 176

• •• 177

• 180

• •• 180

• 181

• 181

• •• 181

• 182

• •• 184 . • • • . • • • 184

• 185

Languages and Support Tools-xi

(16)

Loops . . . • • For Statement • Branch Statements ' • . Input/Output Statements PROCEDURES • . • •

Procedures Statement . • . • • • • . • . • . . End Statement • • • •

Argument Association. • • . • • • • Execution and Return Values. .

Known Functions • ATAVISMS . • •

Escape Lines ••

Call Statement • Obsolete Keywords Numeric Labels Implicit Declarations Computed Goto Goto Statement Dot Names

Complex Constants . . . . • . • Function Values . . • . • . . Equivalence . • • • . . . . • . Minimum and Maximum Functions

COMPILER OPTIONS • • Default Options . . . • • • Input Language Options • • • Input/Output Error Handling Continuation Conventions

Default Formats • • • . • . . . • . • . • . . Alignments and Sizes . . . •

Default Input/Output Units • • • • . • . • Miscellaneous Output Control Options . . . . EXAMPLES . • • • • . • • • • •

File Copying . . • • . • . • • • • . • . • Matrix Multiplication •

Searching a Linked List • . • • • • • • Walking a Tree . • • . • • • • . • . • . • PORTABILITY . • • • .

Primitives • . • • . • •

DIFFERENCES BETWEEN RATFOR AND EFL •

COMPILER. • . . . • . .

Current Version • • • . • . • Diagnostics • • • • • • •

Quality of Fortran Produced • • • • • • CONSTRAINTS ON EFL • • • • • • •

External Names Procedure Interface • Pointers . • . • • • Recursion • • • . Storage Allocation

• .186

• . 188

• • 188

• • 191

• • 193

· 196

• •• 196

· 197

• . 197

• 197

• • 197

· 199

• • 199

• 199

• • 199

· • . 200 .200 .200 .201

• •• 201 .201 .202 .202 .202

· •• 203 .203 .203 .203 .204 .204 .204

• 205 .205 .205 .205 .206 . • • • • 206

• •• 207

• • • • • • • 210 .210

• •• 211 .211

• • 211

• 211

• •• 212

• 214 .214

• 214

• 215

• • • • • 215 .215

(17)

SUPPORT TOOLS

A PROGRAM FOR MAINTAINING COMPUTER PROGRAMS (make) •• 217 GENERAL " • . • . . • • . • • . • • • • . . .

BASIC FEATURES • • • . • • • • • • • • • • DESCRIPTION FILES AND SUBSTITUTIONS COMMAND USAGE . • . . . • . • . . • . . SUFFIXES AND TRANSFORMATION RULES IMPLICIT RULES • • • • . . . • •

SUGGESTIONS AND WARNINGS • • • • • . •

AUGMENTED VERSION OF make ••

GENERAL • • • • • • • • • • • • • . THE ENVIRONMENT VARIABLES

RECURSIVE MAKEFILES . • . • • • . • . . . • • FORMAT OF SHELL COMMANDS WITHIN make ARCHIVE LIBRARIES • . • • • • • . • . . . • •

• 217

• 221 .224 .226 .228 .229

• • . . • • . 231

.233

• • • • 233 .234

· • • • 240 .240 SOURCE CODE CONTROL SYSTEM FILE NAMES: THE TILDE

THE NULL SUFFIX. • • • • .'. • • . • • •

.240 .245 .247 .247 .248 INCLUDE FILES • • . . . • • • • . • . •

INVISIBLE SCCS MAKEFILES • • • . • • • DYNAMIC DEPENDENCY PARAMETERS . EXTENSIONS OF $*, $@, AND $<

OUTPUT TRANSLATIONS • • • • . . • •

. . . . • . . 248 .249 .250

SOURCE CODE CONTROL SYSTEM USER GUIDE. • .251

.251 .252 .253 .253 .254 GENERAL • • • . • . • . • . . • • .

SCCS FOR BEGINNERS • • . • • • • A. Terminology • • • . . • • • . • . • B. Creating an SCCS File via "admin"

C. Retrieving a File via "get" • • • • • D. Recording Changes via "delta" • • • • E. Additional Information About "get"

F. The "help" Command • • . . • DELTA NUMBERING • . . . • • • . SCCS COMMAND CONVENTIONS SCCS COMMANDS • • . . • • • • . .

A. The "get" Command • .

B. The "delta" Command . • • • • • . • • • • C. The "admin" Command ••

D. The "prs" Command . • . • • . . E. The "help" Command . • • • • . .

F. The "rmdel" Command • . • • • • . • • . • G. The "cdc" Command . • .

H. The "what" Command • . • • • • • I. The "sccsdiff" Command

• . . • 255 .256

· • • • . • . • . • • 258

· . • 259 .261

· . . 263 .264

· •• 277

· •• 281

· . . • • . • • . • • 284

· •• 286

· •• 287

· •• 288

• • . • • 289

· . • 290 .290 J. The "comb" Command

K. The "val" Command • • . • • • • • . • . • • 291 SCCS FILES • . •

A. Protection. .

B. Formatting • • • • • •

C. Auditing . . • • • . • • • • • •

UNIX Programmer's Manual

· . . . . • . . • 292

· •• 292

• .293

• • . • • 294

Languages and Support Tools-xiii

(18)

C. Basic Program • . . D. Linking and Use •

THE M4 MACRO PROCESSOR GENERAL . • . . • . • . DEFINING MACROS . • . ARGUMENTS • • • . . . • ARITHMETIC BUILT-INS.

FILE MANIPULATION . . SYSTEM COMMAND . . . CONDITIONALS • • • • . STRING MANIPULATION PRINTING . . . .

THE awk PROGRAMMING LANGUAGE GENERAL . . . . • . .

PROGRAM STRUCTURE

LEXICAL CONVENTION . • • • • • Numeric Constants

String Constants Keywords . • . • Identifiers • . . • • Operators • . • •

Record and Field Tokens • • • • • • Record Separators . . •

Field Separator. . . . . Multiline Records . • . .

Output Record and Field Separators . . Comments • . • • . . . . •

Separators and Brackets • . • PRIMARY EXPRESSIONS. • Numeric Constants . • • • • String Constants . . • • • Vars • . . . • . . . • • . Function

TERMS . . . . • Binary Terms Unary Term.

Incremented Vars . Parenthesized Terms EXPRESSIONS . • .

Concatenation of Terms . Assignment Expressions USING awk • • • • • • • INPUT: RECORDS AND FIELDS.

INPUT: FROM THE COMMAND LINE . OUTPUT: PRINTING . . . •

OUTPUT: TO DIFFERENT FILES • . . •

• .296

• .297

• . 297

• .299

· .299

• .306 .308 .309

• .310

• • • • 311

· . 312

• 313

· . . . 314

· . 317

· 317 . • • • • • . 317

· . 319

· . 319

· .319 .320 .320 .320 .323

· .324

· .324 .324

· .325

· .325 .325 .325 .326 .326 .326 .328

• • • . 330 .330 .330

· • • . 331

· 331

· 331

· 331

· .\ • . 332

· 333

· .334

· .336 .338

· .343

(19)

OUTPUT: TO PIPES • COMMENTS . • • PATTERNS • • • • • •

BEGIN and END Relational Expressions. • Regular Expressions. • • Combinations of Patterns Pattern Ranges . . . . • • ACTIONS . • • • • • • •

Variables, Expressions, and Assignments . Initialization of Variables

Field Variables • • • . • • • • • String Concatenation • • • • .

Special Variables • • . • • • . • . Type • • • • • • •

Arrays . . • • • • BUILT IN FUNCTIONS ••

FLOW OF CONTROL . . REPORT GENERATION ••

COOPERATION WITH THE SHELL MISCELLANEOUS HINTS

THE LINK EDITOR • . • • GENERAL • • • • • . •

Memory Configuration Section .

Addresses ••

Binding • • • • Object File

USING THE LINK EDITOR

LINK EDITOR COMMAND LANGUAGE.

Assignment Statements • • . • • . • . • Specifying a Memory Configuration . . .

• . 344

· .345 .345

• .346

• .347

• • . • • • • • 349

• • . • • • • • 352

· .353

• • • • • • • • • • • • 354 .354

• .356 .356

• • . • • • • . 357

• • . • • • • . 358

· . . • • • • . 359

• • • • • • • • • • 360 .362

· • . • . • . . 365

• .369

· • 371

· .372

.373 .373

· .374

· .374

· .375 .375 .375

• .376 .380

• • . • • • . • • • • . 381 .383 Section Definition Directives • • • • • • • • • . • • • · .385 NOTES AND SPECIAL CONSIDERATIONS

Changing the Entry Point • • • . • • .' Use of Archive Libraries • • • • • • • • • Dealing With Holes in Physical Memory • . Allocation Algorithm . • • • . . • • • • Incremental Link Editing • • . • . • .

· .397

· .397

• .397

• . • • • • • . • • • 401 .401 DSECT, COPY, and NOLOAD Sections • • • . • • •

Output File Blocking • .

.402 .403 .404 Nonrelocatable Input Files •

ERROR MESSAGES • Corrupt Input Files ••

Errors During Output .

Internal Errors • • • . • • • . • • Allocation Errors • • . . • • • • • Misuse of Link Editor Directives

Misuse of Expressions . . . . • • . • . Misuse of Options

Space Restraints • • • • Miscellaneous Errors • • • • •

UNIX Programmer's Manual

.405

· .406 .406 .407 .407 .408

· .409

· .411 .412

• .413 .413

Languages and Support Tools-xv

(20)

DEFINITIONS AND CONVENTIONS 0 0 0 0 0 Sections 0 0 0 0 0 0 0 0 0 0

Physical and Virtual Addresses

FILE HEADER 0 0 0 0 0 0 0 0 0 0 0 0 Magic Numbers 0 0 0 0 0 0 0 0 0 0 0 0 Flags 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 OPTIONAL HEADER INFORMATION 0 0

Standard UNIX system a.out Header Optional Header Declaration 0

SECTION HEADERS 0 0 0 0 0 0 0 0 0 Flags 0 0 0 0 0 0 0 0 0 0 0

Section Header Declaration .bss Section Header 0 0 0 0 0 SECTIONS 0 0 0 0 0 0 0 0 0 RELOCATION INFORMATION

Relocation Entry Declaration 0 LINE NUMBERS 0 0 0 0

Line Number Declaration 0 0 0 0 0 0 SYMBOL TABLE 0 0 0 0 0 0 0 0 0 0

o 0423

o 0423 0424

o 0 0 0 0 0 0 0 0 0 0425

o 0 0 0 0 0 0 0 0 0 0426

o 0 0 0429

o 0429

o 0 0432

o 0 0 0 0 0 0 0 0 0 0 0 0 433

o 0 0 0 0 0 0435

o 0 0436

o 0 0 0 0 0 0 0 0 0 0437

o 0 0 0 0 0 0 0 0 0 0438

o 0 0438

o 0443

o 0443

o 0444

o 0446 Special Symbols 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 o 0447 Symbols and Functions 0 0 0 0 0 0 0 0 0 0 0 0 • 0 0 0 0 0 0 o 0451 Symbol Table Entries . . 0 0 0 0 0 0 0 • • • 0 • • •

Auxiliary Table Entries

STRING TABLE 0 • • • • • 0

ACCESS ROUTINES • . . • • • • . 0

o .452

o 0 0 0 0 0468

o 0 0 0479

o 0 0 0 0480

ARBITRARY PRECISION DESK CALCULATOR LANGUAGE (BC) . . . 481 GENERAL . . . 0 • • • 0 • • • • 0 • 0 481 BASES • • • • • 0 • • • 0 • • • 0 • • • • • • • ..483 SCALING •• 0 0 • • • 0 • • • 0 • • • 0485 FUNCTIONS • • • . . . 0 • • • • • 0 0 • 486

SUBSCRIPTED VARIABLES . 0 • 0 • 488

CONTROL STATEMENTS. • • . • • 0 0 0 • • • 489

ADDITIONAL FEATURES 0 • 0 0 • 492

BC APPENDIX 0 0 • 0 • 0 • • • • • • • 494 NOTATION 0 0 • • • • • • • 0 • 0 • 0 • • 0 494

TOKENS . • 0 • • • • • • • 0 .494

EXPRESSIONS . . • . • . . 0 • • • 0 • • 495 RELATIONAL OPERATORS 0 • • • • 0 0 • • • • • 0499 STORAGE CLASSES . . 0 • 0 • • • • • 0 • 499 STATEMENTS • . . . • . 0 • 0 0 0 • 500

INTERACTIVE DESK CALCULATOR (DC) GENERAL 0 • 0 •• 0 • 0 • 0 • • • • • DC COMMANDS 0 0

INTERNAL REPRESENTATION OF NUMBERS . • 0 0 THE ALLOCATOR • 0 • • • • • •

INTERNAL ARITHMETIC 0 • • • 0 •• 0

ADDITION AND SUBTRACTION • • • . 0 0

• • • • 503

• •• 503

• 0 .503

• 0507

• • 0507

• 0 508

• 0 .509

(21)

MULTIPLICATION . • • • . • .509

DIVISION • • • • • • • • • • • .510

REMAINDER. • • • • • • • • • • • . • • . • . • • • • • • 510 SQUARE ROOT • • • • • • • • • • • •

EXPONENTIATION. .

INPUT CONVERSION AND BASE • • OUTPUT COMMANDS • • • • • OUTPUT FORMAT AND BASE • . INTERNAL REGISTERS • • . • . •

STACK COMMANDS . • • • . • . • . • . • . • • • SUBROUTINE DEFINITIONS AND CALLS • . • • • INTERNAL REGISTERS-PROGRAMMING DC PUSHDOWN REGISTERS AND ARRAYS MISCELLANEOUS COMMANDS

DESIGN CHOICES . . • • • . • • • . • • • . .

LEXICAL ANALYZER GENERATOR (LEX) GENERAL . • • . • . • • • . • . • • • • .

• • 511

• .511

• .511

• . 512

• . 512

• • 512

• .513

• .513

• • 513

• .513

• • 514

• • 514

• • 517

• . 517

• . • . • • 519 LEX SOURCE . • • • • • . • • • . • • • • .

LEX REGULAR EXPRESSIONS . • . • . • • • .520 Operators . • • . . •

Character Classes. . • Arbitrary Character. • • Optional Expressions ••

Repeated Expressions • • • Alternation and Grouping

Context Sensitivity • • • . . • • . • Repetitions and Definitions. • • • • . • • . LEX ACTIONS . • • • • . • • • • • • • . • . AMBIGUOUS SOURCE RULES • • • • • . • . LEX SOURCE DEFINITIONS • • • • • • . • • .

. . . • • . • . • • 521 . • . • • . • . . • 522

• • 523

• .523

• • 523

• • 524

· • • . • • • • 524

• • 525

· • • . • . • • 526

• .530 .533 USAGE. • • . • • • . • • • . • • • . • • • .535 LEX AND Y ACC • • • • • • • •

EXAMPLES • • . • . . • • • • • • .536

• .537 LEFT CONTEXT SENSITIVITY

CHARACTER SET • • • • • . • SUMMARY OF SOURCE FORMAT

. • • . . . • • • • • . 538

• . • . • • • . 541 CA VEATS AND BUGS • • • . • .

YET ANOTHER COMPILER-COMPILER (yacc) • • . • • • • GENERAL • • • • • • • • • • • • • • • . • • . • • • • BASIC SPECIFICATIONS • • • .

ACTIONS • • • • • • • • • • • •

LEXICAL ANALYSIS • • • • • • • • • • • • • PARSER OPERATION • • • • • •

AMBIGUITY AND CONFLICTS PRECEDENCE • • • • • . • • • ERROR HANDLING • • • • • •

THE "yacc" ENVIRONMENT • • • • • • • • HINTS FOR PREPARING SPECIFICATIONS •

Input Style • • • • • • • • • • • • • • . • • . • • • •

• . 541

• • 543

• • 545

• • 545

• .548

• • 551

• • • • 555

• • 557

• .563

• .569

• .572

• .575 .577

• • • • • . 577

UNIX Programmer's Manual Languages and Support Tools-xvii

(22)

Reserved Words ADVANCED TOPICS

Simulating Error and Accept in Actions . • • . . Accessing Values in Enclosing Rules . . . • • • • . Support for Arbitrary Value Types • • . • • . • • • • • EXAMPLES. . . • . . • • • . •

A Simple Example . • . • .0 • • . • • • •

Y ACC Input Syntax • . . • • • • . • • • . An Advanced Example . • • • • . • . • • . Old Features Supported But Not Encouraged • •

UNIX SYSTEM TO UNIX SYSTEM COPY (UUCP) INTRODUCTION • • • . . . • . . THE UUCP NETWORK

Network Hardware Network Topology Forwarding

Security . . • • • . Software Structure Rules of the Road

Special Places: The Public Area Permissions

NETWORK USAGE . Name Space . . • Forwarding Syntax Types of Transfers Remote Executions Spooling . . • • • . Notification . • • Tracking and Status

Job Status. . . . . . . . Network Status. • . • . . • • • . Job Control . . . . . . . . • . . • . UTILITIES THAT USE UUCP

The Stockroom • Mail . . Netnews . • . . Uuto • . . • Other Applications

• • • • • • • 581

• •• 581

• • • • • • • 581

• • • • • • • 581

• .583

• •• 585

• .585

• • • • • • • 588

• .591

• •• 600

• • • • 603

• •• 603

• . • • • • • 603

• • • • • • • 604

• • • • • • • 604

• • • • 605

• .605

• • • • • • • 606

• .606

• • • • • • • 608

• • • • • • • 608

• • • • • • • 609

• • • • • • • 609

• • • • • • • 611

• • • • • • • 611

• • • • • • • 613

• • • • 613

• • • • • • • 613

• • • • • • • 614

· • . • 615

• . • • • • • 615

· . • • • • • 616

• • • • 617

· • • • • • • 617

• • 617

· • 617

• • • • • • . 617

· • 618

(23)

C LANGUAGE

LEXICAL CONVENTIONS

There are six classes of tokens - identifiers, keywords, constants, strings, operators, and other separators. Blanks, tabs, new-lines, and comments (collectively, "white space") as described below are ignored except as they serve to separate tokens. Some white space is required to separate otherwise adjacent identifiers, keywords, and constants.

If the input stream has been parsed into tokens up to a given character, the next token is taken to include the longest string of characters which could possibly constitute a token.

Comments

The characters /* introduce a comment which terminates with the characters

* /.

Comments do not nest.

Identifiers (Names)

An identifier is a sequence of letters and digits. The first character must be a letter. The underscore () counts as a letter. Uppercase and lowercase letters are different. Although there is no limit on the length of a name, only initial characters are significant: at least eight characters of a non-external name, and perhaps fewer for external names. Moreover, some implementations may collapse case distinctions for external names. The external name sizes include:

PDP-II VAX-ll AT&T 3B20

7 characters, 2 cases

>

100 characters, 2 cases

>

100 characters, 2 cases

Keywords

The following identifiers are reserved for use as keywords and may not be used otherwise:

UNIX Programmer's Manual Languages and Support Tools-I

(24)

auto do for return typedef

break double goto short union

case else if sizeof unsigned

char enum int static void

continue external long struct while

default float register switch

Some implementations also reserve the words fortran and asm.

Constants

There are several kinds of constants. Each has a type; an introduction to types is given in "NAMES." Hardware characteristics that affect sizes are summarized in "Hardware Characteristics" under "LEXICAL CONVENTIONS."

Integer Constants

An integer constant consisting of a sequence of digits is taken to be octal if it begins with 0 (digit zero). An octal constant consists of the digits 0 through 7 only. A sequence of digits preceded by Ox or OX (digit zero) is taken to be a hexadecimal integer. The hexadecimal digits include a or A through f or F with values 10 through 15. Otherwise, the integer constant is taken to be decimal. A decimal constant whose value exceeds the largest signed machine integer is taken to be long; an octal or hex constant which exceeds the largest unsigned machine integer is likewise taken to be long. Otherwise, integer constants are into

Explicit Long Constants

A decimal, octal, or hexadecimal integer constant immediately followed by I (letter ell) or L is a long constant. As discussed below, on some machines integer and long values may be considered identical.

Character Constants

A character constant is a character enclosed in single quotes, as in 'x'. The value of a character constant is the numerical value of the character in the machine's character set.

(25)

Certain nongraphic characters, the single quote (') and the backslash (\), may be represented according to the following table of escape sequences:

new-line NL (LF) \n

horizontal tab HT \t

vertical tab VT \v

backspace BS \b

carriage return CR \r

form feed FF \f

backslash

\ \\

single quote

\'

bit pattern ddd \ddd

The escape \ddd consists of the backslash followed by 1, 2, or 3 octal digits which are taken to specify the value of the desired character. A special case of this construction is \0 (not followed by a digit), which indicates the character NUL. If the character following a backslash is not one of those specified, the behavior is undefined. A new-line character is illegal in a character constant.

The type of a character constant is int.

Floating Constants

A floating constant consists of an integer part, a decimal point, a fraction part, an e or E, and an optionally signed integer exponent. The integer and fraction parts both consist of a sequence of digits. Either the integer part or the fraction part (not both) may be missing. Either the decimal point or the e and the exponent (not both) may be missing. Every floating constant has type double.

Enumeration Constants

Names declared as enumerators (see "Structure, Union, and Enumeration Declarations" under "DECLARATIONS") have type into

Strings

A string is a sequence of characters surrounded by double quotes, as in " .•• ". A string has type "array of char" and storage class static (see "NAMES") and is initialized with the given characters. The compiler places a null byte (\0) ,at the end of each string so that programs which scan the string can find its end.

In a string, the double quote character (") must be preceded by a \; in addition, the same escapes as described for character constants may be used.

UNIX Programmer's Manual Languages and Support Tools-3

(26)

A \ and the immediately following new-line are ignored. All strings, even when written identically, are distinct.

Hardware Characteristics

The following figures summarize certain hardware properties that vary from machine to machine.

DEC PDP-II (ASCII)

char 8 bits

int 16

short 16

long 32

float 32

double 64

float range ±10 ±38 double range ±10 ±38

DEC PDP-II HARDWARE CHARACTERISTICS

(27)

DEC VAX-II (ASCII)

char 8 bits

int 32

short 16

long 32

float 32

double 64

float range ±10 ±38 double range ±10 ±38

DEC VAX-II HARDWARE CHARACfERISTICS

AT&T 3D (ASCII)

char 8 bits

int 32

short 16

long 32

float 32

double 64

float range ± 10 ±38

double range ± 10 ±308

AT&T 3D HARDWARE CHARACTERISTICS

UNIX Programmer's Manual Languages and Support Tools-5

(28)

SYNTAX NOTATION

Syntactic categories are indicated by italic type and literal words and characters in bold type. Alternative categories are listed on separate lines. An optional terminal or nonterminal symbol is indicated by the subscript "opt," so that

{expression t}

op

indicates an optional expression enclosed in braces. The syntax is summarized in "SYNTAX SUMMARY".

NAMES

The C language bases the interpretation of an identifier upon two attributes of the identifier - its storage class and its type. The storage class determines the location and lifetime of the storage associated with an identifier; the type determines the meaning of the values found in the identifier's storage.

Storage Class There are four declarable storage classes:

• Automatic

• Static

• External

• Register.

Automatic variables are local to each invocation of a block (see "Compound Statement or Block" in "STATEMENTS") and are discarded upon exit from the block. Static variables are local to a block but retain their values upon reentry to a block even after control has left the block. External variables exist and retain their values throughout the execution of the entire program and may be used for communication between functions, even separately compiled functions. Register variables are (if possible) stored in the fast registers of the machine; like automatic variables, they are local to each block and disappear on exit from the block.

Références

Documents relatifs

Using these datasets of protein groups and our protein- lncRNA interaction predictions, we identified lncRNAs that may scaffold complexes or modules by assessing first, for each

Le Glossaire du parler français au Canada publié en 1930, propose la définition suivante : « Regarder avec curiosité, chercher à voir ce qui se passe chez les voisins.. »

We have also an obvious sign rule: symmetric or antisymmetric func- tions on ¡ E d ¢ behave with respect to multiplication like the elements of the multiplicative group {±1}

In this paper, extending past works of Del Popolo, we show how a high precision mass function (MF) can be obtained using the excursion set approach and an improved barrier

We give a very simple algorithm to compute the error and complemen- tary error functions of complex argument to any given

PARTIE 2: DONNEES TECHNIQUES Le rapport technique annuel RTA a pour objectif de présenter les observations effectuées en 2004 dans le cadre de l’exploitation et de la surveillance de

Une attention particulière doit être portée aux patients sous chimiothérapie car quelques GR résistant à l’hémolyse peuvent induire une fausse normalisation