pax_global_header00006660000000000000000000000064127327726410014525gustar00rootroot0000000000000052 comment=8c349c5531d3bc90b00df875b6cd3c64110f59f1 ocp-indent-1.5.3/000077500000000000000000000000001273277264100135735ustar00rootroot00000000000000ocp-indent-1.5.3/.gitignore000066400000000000000000000004331273277264100155630ustar00rootroot00000000000000.hgignore.in Makefile.config jbuild jbuild-ignore ocp-build.root* _obuild config.log config.status ocp-indent src/indentVersion.ml *~ version.ocp autom4te.cache aclocal.m4 man/man1/ src/.hgignore.in src/jbuild src/Makefile.extracted-from-jenga src/buildable_targets.list **/.fe.sexp ocp-indent-1.5.3/.ocp-indent000066400000000000000000000077501273277264100156450ustar00rootroot00000000000000# -*- conf -*- # This is an example configuration file for ocp-indent # # Copy to the root of your project with name ".ocp-indent", customise, and # transparently get consistent indentation on all your ocaml source files. # Starting the configuration file with a preset ensures you won't fallback to # definitions from "~/.ocp/ocp-indent.conf". # These are `normal`, `apprentice` and `JaneStreet` and set different defaults. normal # # INDENTATION VALUES # # Number of spaces used in all base cases, for example: # let foo = # ^^bar base = 2 # Indent for type definitions: # type t = # ^^int type = 2 # Indent after `let in` (unless followed by another `let`): # let foo = () in # ^^bar in = 0 # Indent after `match/try with` or `function`: # match foo with # ^^| _ -> bar with = 0 # Indent for clauses inside a pattern-match (after the arrow): # match foo with # | _ -> # ^^^^bar # the default is 2, which aligns the pattern and the expression match_clause = 4 # this is non-default # Indentation for items inside extension nodes: # [%% id.id # ^^^^contents ] # [@@id # ^^^^foo # ] ppx_stritem_ext = 2 # When nesting expressions on the same line, their indentation are in # some cases stacked, so that it remains correct if you close them one # at a line. This may lead to large indents in complex code though, so # this parameter can be used to set a maximum value. Note that it only # affects indentation after function arrows and opening parens at end # of line. # # for example (left: `none`; right: `4`) # let f = g (h (i (fun x -> # let f = g (h (i (fun x -> # x) # x) # ) # ) # ) # ) max_indent = 4 # # INDENTATION TOGGLES # # Wether the `with` parameter should be applied even when in a sub-block. # Can be `always`, `never` or `auto`. # if `always`, there are no exceptions # if `auto`, the `with` parameter is superseded when seen fit (most of the time, # but not after `begin match` for example) # if `never`, `with` is only applied if the match block starts a line. # # For example, the following is not indented if set to `always`: # let f = function # ^^| Foo -> bar strict_with = never # Controls indentation after the `else` keyword. `always` indents after the # `else` keyword normally, like after `then`. # If set to `never', the `else` keyword won't indent when followed by a newline. # `auto` indents after `else` unless in a few "unclosable" cases (`let in`, # `match`...). # # For example, with `strict_else=never`: # if cond then # foo # else # bar; # baz # `never` is discouraged if you may encounter code like this example, # because it hides the scoping error (`baz` is always executed) strict_else = always # Ocp-indent will normally try to preserve your in-comment indentation, as long # as it respects the left-margin or starts with `(*\n`. Setting this to `true` # forces alignment within comments. strict_comments = false # Toggles preference of column-alignment over line indentation for most # of the common operators and after mid-line opening parentheses. # # for example (left: `false'; right: `true') # let f x = x # let f x = x # + y # + y align_ops = true # Function parameters are normally indented one level from the line containing # the function. This option can be used to have them align relative to the # column of the function body instead. # if set to `always`, always align below the function # if `auto`, only do that when seen fit (mainly, after arrows) # if `never`, no alignment whatsoever # # for example (left: `never`; right: `always or `auto) # match foo with # match foo with # | _ -> some_fun # | _ -> some_fun # ^^parameter # ^^parameter align_params = auto # # SYNTAX EXTENSIONS # # You can also add syntax extensions (as per the --syntax command-line option): # syntax = mll lwt ocp-indent-1.5.3/CHANGELOG000066400000000000000000000073231273277264100150120ustar00rootroot00000000000000## 1.5.3 * fixes on nested try-with and some cases of comments * better alignment of stand-alone semicolons in records * improved emacs and vim scripts * better indentation within extension blocks ## 1.5.2 * small emacs binding fix * compatibility with cmdliner 0.9.8 ## 1.5.1 * generic handling of ppx keywords * much improved vim binding * changed installation location of vim bindings (to share/ocp-indent/vim/indent) for easier autoload * don't increase indentation level for sequences of try..with * support for '[@' * restore back-alignment of '&&', '||' after 'if' and 'when' * support for extensible variant types ## 1.5 * new vim binding * support for ppx lwt keywords * fixed indentation at BOF and EOF in some cases * back-alignment of '&&' and '||' disabled * tweaks to functor, struct and module indentation * support for ppx attributes * lots of fixes and tweaks ## 1.4.1 * OCaml 4.01.0 warnings fix * fixed indent of lwt try/finally * sort Jane Street tests by priority * added support for BENCH syntax * added support for the new {xx| |xx} quotation syntax * emacs mode: cleaner loading * emacs mode: fixed the 'syntax' option * emacs mode: workaround an auto-complete.el display bug * emacs and vim modes: install in editor-specific directories * refactored build system. Install through opam-installer, register libs as ocamlfind sub-packages ## 1.4.0 * license change: lessening the GPL to make ocp-indent easier to use as a library * removed indent by default after most common operators (when align_ops is set) * removed extra-indent in some pattern-matching cases * fixed a few bugs related to records, lazy as pattern, "module with" * added support for the cstruct syntax extension * fixed Makefile to properly install all cmi files, working around an ocp-build bug ## 1.3.2 * bug-fix release: object types, module type of, first line, etc. ## 1.3.1 * optimised functional operators on OCaml 4.00 * fixed a bug in phrase boundary detection ## 1.3.0 * Large API rewrite, offering much more flexibility and functionality * Still some bug fixes (comments at end, nested ocamldoc tags, etc.) * Man-page fixes (thanks to Kaustuv Chaudhuri) * Temporarily disabled the non-functional state-marshalling function * Emacs mode: auto-disabling indent-tabs-mode by default, it's not compatible anyways. ## 1.2.2 * Fixed critical bug with the parsing of the --syntax option * a few indent fixes (functor sigs, comments in expressions) ## 1.2.1 * Fixed bugs with GADTs, comments at end of modules * Fixed compilation with OCaml trunk (warnings as errors) * New vim script, contributed by Jonathan Derque * New option "strict_else" to allow unindenting after else ## 1.2.0 * Lots of fixes * Switched most operators and constructs with parentheses to column aligned by default (can be disabled with option align_ops) * Better handling of records * Some code cleanup (record fields with meaningful names) * Documentation and manpage (now relying on cmdliner) * Added an option (max_indent) to limit over-indent in the most annoying cases * Syntax extensions can now be enabled from the configuration files ## 1.1.0 * Small fixes, stabilised ocamldoc indentation * Support for configuration files, either user or project-wide ## 1.0.2 * Supporting indentation of ocamldoc. In particular, code within ocamldoc blocks {[...]} should be automatically indented * Fixed the emacs mode not to set the mark * A few new configuration options (strict_with, strict_comments, align_params) * A few tweaks and improvements (better empty line indent, etc.) * Bugfixes (#43, #47) ## 1.0.1 * Indentation of comments now follows ocamldoc conventions properly * Partial indent adapts more closely to manual indentation * Various small fixes (indent on empty lines, freeform comments...) ocp-indent-1.5.3/LICENSE000066400000000000000000001253061273277264100146070ustar00rootroot00000000000000As a special exception to the GNU Lesser General Public License, you may link, statically or dynamically, a "work that uses the Library" with a publicly distributed version of the Library to produce an executable file containing portions of the Library, and distribute that executable file under terms of your choice, without any of the additional requirements listed in clause 6 of the GNU Library General Public License. By "a publicly distributed version of the Library", we mean either the unmodified Library as distributed by the copyright holder, or a modified version of the Library that is distributed under the conditions defined in clause 3 of the GNU Library General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Lesser General Public License. GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ------------------------------------------------------------------------ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ocp-indent-1.5.3/META000066400000000000000000000012351273277264100142450ustar00rootroot00000000000000package "lib" ( version = "1.5.3" directory = "lib" archive(byte) = "ocp-indent.lib.cma" archive(native) = "ocp-indent.lib.cmxa" requires = "ocp-indent.lexer ocp-indent.utils" ) package "utils" ( version = "1.5.3" directory = "utils" archive(byte) = "ocp-indent.utils.cma" archive(native) = "ocp-indent.utils.cmxa" requires = "ocp-indent.lexer" ) package "lexer" ( version = "1.5.3" directory = "lexer" archive(byte) = "ocp-indent.lexer.cma" archive(native) = "ocp-indent.lexer.cmxa" ) package "dynlink" ( version = "1.5.3" directory = "dynlink" archive(byte) = "ocp-indent.dynlink.cma" archive(native) = "ocp-indent.dynlink.cmxa" ) ocp-indent-1.5.3/Makefile000066400000000000000000000040611273277264100152340ustar00rootroot00000000000000-include Makefile.config byte = _obuild/ocp-indent/ocp-indent.byte native = _obuild/ocp-indent/ocp-indent.asm manpage = man/man1/ocp-indent.1 OCPBUILD_ARGS = .PHONY: $(native) $(byte) all: ocp-indent $(manpage) @ ocp-indent: $(native) cp $^ ocp-indent ALWAYS: $(byte) byte: ocp-build.root ALWAYS ocp-build $(OCPBUILD_ARGS) $(native) native asm: ocp-build.root ALWAYS ocp-build $(OCPBUILD_ARGS) .PHONY: man man: $(manpage) $(manpage): $(byte) mkdir -p $(@D) $(byte) --help=groff >$@ bootstrap: ocp-indent ./ocp-indent -c match_clause=4 --inplace src/*.mli src/*.ml sanitize: ocp-build -sanitize $(OCPBUILD_ARGS) .PHONY: clean clean: ocp-build -clean $(OCPBUILD_ARGS) .PHONY: distclean distclean: ocp-build -clean $(OCPBUILD_ARGS) rm -rf _build _obuild rm -f configure Makefile.config config.* ocp-build.root* version.ocp install.sh: ocp-indent.install opam-installer --prefix '$$1' $^ --script >$@ chmod a+x $@ uninstall.sh: ocp-indent.install opam-installer --prefix '$$1' $^ --script --uninstall >$@ chmod a+x $@ .PHONY: install install: $(manpage) install.sh uninstall.sh ./install.sh $(prefix) @echo @echo @echo "=== ocp-indent installed ===" @echo @echo "To setup tuareg-mode to use ocp-indent, please add the following" @echo "to your .emacs :" @echo @if [ "$(prefix)" != "/usr" ]; then \ echo " (add-to-list 'load-path \"$(datarootdir)/emacs/site-lisp\")"; \ fi @echo " (require 'ocp-indent)" @echo @echo "Vim users are welcome to add the following to their .vimrc :" @echo @echo ' set rtp^="$(prefix)/share/ocp-indent/vim"' @echo .PHONY: uninstall uninstall: uninstall.sh ./uninstall.sh $(prefix) .PHONY: test test: ocp-indent ./tests/test.sh configure: configure.ac aclocal -I m4 autoconf version.ocp: configure.ac @echo "version.ocp not up-to-date, please rerun ./configure" @exit 1 ocp-build.root: version.ocp @if (ocp-build -version 2>/dev/null |\ awk -F'.' '{ exit $$1 > 1 || ($$1 == 1 && $$2 >= 99) }'); then \ echo "Error: you need ocp-build >= 1.99." >&2;\ exit 1;\ fi ocp-build -init $(OCPBUILD_ARGS) ocp-indent-1.5.3/Makefile.config.in000066400000000000000000000002341273277264100171030ustar00rootroot00000000000000datarootdir = @datarootdir@ prefix=@prefix@ mandir = $(shell if test -d @mandir@; then echo @mandir@; else echo @prefix@/man; fi) version=@PACKAGE_VERSION@ ocp-indent-1.5.3/Makefile.simple000066400000000000000000000031421273277264100165230ustar00rootroot00000000000000# -*- makefile -*- GENERATED = src/indentVersion.ml src/compat.ml NAME = 'ocp-indent' VERSION != awk -F'[(,)]' '/AC_INIT/ { print $$3 }' configure.ac BEST != if ocamlopt 2>/dev/null; then echo native; else echo byte; fi OCAML_MAJOR != ocaml -vnum | sed 's/\..*//' COMPAT_DIR = src/ocaml_$(OCAML_MAJOR)/ OCAMLBUILD = ocamlbuild -I src -use-ocamlfind LIB = ocp-indent-lib PKGS = cmdliner,findlib,dynlink BINS = ocp-indent.byte LIBS = $(LIB).cma ifeq ($(BEST),native) LIBS += $(LIB).cmxa $(LIB).a $(LIB).cmxs BINS += ocp-indent.native endif .PHONY: all all: $(LIBS) $(BINS) ocp-indent.1 .PHONY: man man: ocp-indent.1 ocp-indent.1: ocp-indent.$(BEST) ./ocp-indent.$(BEST) --help=groff >$@ ocp-indent.byte: $(OCAMLBUILD) indentMain.byte -pkgs $(PKGS) ln -f _build/src/indentMain.byte $@ ocp-indent.native: $(OCAMLBUILD) indentMain.native -pkgs $(PKGS) ln -f _build/src/indentMain.native $@ src/compat.ml: cp $(COMPAT_DIR)/compat.ml src/ src/indentVersion.ml: echo 'let version = "'$(VERSION)'"' > $@ src/approx_common.ml: src/approx_common.mli cp $< $@ $(LIB).cma $(LIB).cmxa $(LIB).a $(LIB).cmxs: $(GENERATED) $(OCAMLBUILD) -use-ocamlfind $@ .PHONY: clean clean: rm -rf $(GENERATED) META _build rm -rf $(BINS) ocp-indent.1 META: mkdir -p _build/src echo 'name = "'$(NAME)'"' >$@ echo 'version = "'$(VERSION)'"' >> $@ echo 'archive(byte) = "'$(LIB)'.cma"' >> $@ echo 'archive(native) = "'$(LIB)'.cmxa"' >> $@ .PHONY: install install: META $(LIBS) $(BINS) ocamlfind remove $(NAME) || true ocamlfind install $(NAME) \ $(LIBS:%=_build/src/%) $(BINS) META \ _build/src/*.{mli,cmi,cmt,cmti,annot} ocp-indent-1.5.3/README.md000066400000000000000000000004341273277264100150530ustar00rootroot00000000000000ocp-indent is a simple tool and library to indent OCaml code. ocp-indent is part of TypeRex, developed and maintained by OCamlPro. Documentation to install and use this tool is available on http://www.typerex.org/ocp-indent.html It is released under LGPL v3 with linking exception. ocp-indent-1.5.3/configure000077500000000000000000004166011273277264100155120ustar00rootroot00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for ocp-indent 1.5.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # # Copyright 2013-2014 OcamlPro SAS ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ocp-indent' PACKAGE_TARNAME='ocp-indent' PACKAGE_VERSION='1.5.3' PACKAGE_STRING='ocp-indent 1.5.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_subst_vars='LTLIBOBJS LIBOBJS OCAMLBUILD OCAMLDOC OCAMLMKLIB OCAMLMKTOP OCAMLDEP OCAML OCAMLOPTDOTOPT OCAMLCDOTOPT OCAMLBEST OCAMLOPT OCAMLLIB OCAMLVERSION OCAMLC OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures ocp-indent 1.5.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/ocp-indent] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of ocp-indent 1.5.3:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ocp-indent configure 1.5.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Copyright 2013-2014 OcamlPro SAS _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ocp-indent $as_me 1.5.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # checking for ocamlc if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlc", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLC"; then ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLC="${ac_tool_prefix}ocamlc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLC=$ac_cv_prog_OCAMLC if test -n "$OCAMLC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLC" >&5 $as_echo "$OCAMLC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLC"; then ac_ct_OCAMLC=$OCAMLC # Extract the first word of "ocamlc", so it can be a program name with args. set dummy ocamlc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLC"; then ac_cv_prog_ac_ct_OCAMLC="$ac_ct_OCAMLC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLC="ocamlc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLC=$ac_cv_prog_ac_ct_OCAMLC if test -n "$ac_ct_OCAMLC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLC" >&5 $as_echo "$ac_ct_OCAMLC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLC" = x; then OCAMLC="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLC=$ac_ct_OCAMLC fi else OCAMLC="$ac_cv_prog_OCAMLC" fi if test "$OCAMLC" != "no"; then OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml version is $OCAMLVERSION" >&5 $as_echo "OCaml version is $OCAMLVERSION" >&6; } # If OCAMLLIB is set, use it if test "$OCAMLLIB" = ""; then OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` else { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCAMLLIB previously set; preserving it." >&5 $as_echo "OCAMLLIB previously set; preserving it." >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml library path is $OCAMLLIB" >&5 $as_echo "OCaml library path is $OCAMLLIB" >&6; } # checking for ocamlopt if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlopt", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlopt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLOPT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLOPT"; then ac_cv_prog_OCAMLOPT="$OCAMLOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLOPT="${ac_tool_prefix}ocamlopt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLOPT=$ac_cv_prog_OCAMLOPT if test -n "$OCAMLOPT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPT" >&5 $as_echo "$OCAMLOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLOPT"; then ac_ct_OCAMLOPT=$OCAMLOPT # Extract the first word of "ocamlopt", so it can be a program name with args. set dummy ocamlopt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLOPT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLOPT"; then ac_cv_prog_ac_ct_OCAMLOPT="$ac_ct_OCAMLOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLOPT="ocamlopt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLOPT=$ac_cv_prog_ac_ct_OCAMLOPT if test -n "$ac_ct_OCAMLOPT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPT" >&5 $as_echo "$ac_ct_OCAMLOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLOPT" = x; then OCAMLOPT="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLOPT=$ac_ct_OCAMLOPT fi else OCAMLOPT="$ac_cv_prog_OCAMLOPT" fi OCAMLBEST=byte if test "$OCAMLOPT" = "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find ocamlopt; bytecode compilation only." >&5 $as_echo "$as_me: WARNING: Cannot find ocamlopt; bytecode compilation only." >&2;} else TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlopt discarded." >&5 $as_echo "versions differs from ocamlc; ocamlopt discarded." >&6; } OCAMLOPT=no else OCAMLBEST=opt fi fi # checking for ocamlc.opt if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlc.opt", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlc.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLCDOTOPT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLCDOTOPT"; then ac_cv_prog_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLCDOTOPT="${ac_tool_prefix}ocamlc.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLCDOTOPT=$ac_cv_prog_OCAMLCDOTOPT if test -n "$OCAMLCDOTOPT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLCDOTOPT" >&5 $as_echo "$OCAMLCDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLCDOTOPT"; then ac_ct_OCAMLCDOTOPT=$OCAMLCDOTOPT # Extract the first word of "ocamlc.opt", so it can be a program name with args. set dummy ocamlc.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLCDOTOPT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLCDOTOPT"; then ac_cv_prog_ac_ct_OCAMLCDOTOPT="$ac_ct_OCAMLCDOTOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLCDOTOPT="ocamlc.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLCDOTOPT=$ac_cv_prog_ac_ct_OCAMLCDOTOPT if test -n "$ac_ct_OCAMLCDOTOPT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLCDOTOPT" >&5 $as_echo "$ac_ct_OCAMLCDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLCDOTOPT" = x; then OCAMLCDOTOPT="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLCDOTOPT=$ac_ct_OCAMLCDOTOPT fi else OCAMLCDOTOPT="$ac_cv_prog_OCAMLCDOTOPT" fi if test "$OCAMLCDOTOPT" != "no"; then TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlc.opt discarded." >&5 $as_echo "versions differs from ocamlc; ocamlc.opt discarded." >&6; } else OCAMLC=$OCAMLCDOTOPT fi fi # checking for ocamlopt.opt if test "$OCAMLOPT" != "no" ; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlopt.opt", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlopt.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLOPTDOTOPT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLOPTDOTOPT"; then ac_cv_prog_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLOPTDOTOPT="${ac_tool_prefix}ocamlopt.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLOPTDOTOPT=$ac_cv_prog_OCAMLOPTDOTOPT if test -n "$OCAMLOPTDOTOPT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPTDOTOPT" >&5 $as_echo "$OCAMLOPTDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLOPTDOTOPT"; then ac_ct_OCAMLOPTDOTOPT=$OCAMLOPTDOTOPT # Extract the first word of "ocamlopt.opt", so it can be a program name with args. set dummy ocamlopt.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLOPTDOTOPT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLOPTDOTOPT"; then ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="$ac_ct_OCAMLOPTDOTOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="ocamlopt.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLOPTDOTOPT=$ac_cv_prog_ac_ct_OCAMLOPTDOTOPT if test -n "$ac_ct_OCAMLOPTDOTOPT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPTDOTOPT" >&5 $as_echo "$ac_ct_OCAMLOPTDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLOPTDOTOPT" = x; then OCAMLOPTDOTOPT="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLOPTDOTOPT=$ac_ct_OCAMLOPTDOTOPT fi else OCAMLOPTDOTOPT="$ac_cv_prog_OCAMLOPTDOTOPT" fi if test "$OCAMLOPTDOTOPT" != "no"; then TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamlopt.opt discarded." >&5 $as_echo "version differs from ocamlc; ocamlopt.opt discarded." >&6; } else OCAMLOPT=$OCAMLOPTDOTOPT fi fi fi fi # checking for ocaml toplevel if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocaml", so it can be a program name with args. set dummy ${ac_tool_prefix}ocaml; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAML+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAML"; then ac_cv_prog_OCAML="$OCAML" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAML="${ac_tool_prefix}ocaml" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAML=$ac_cv_prog_OCAML if test -n "$OCAML"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAML" >&5 $as_echo "$OCAML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAML"; then ac_ct_OCAML=$OCAML # Extract the first word of "ocaml", so it can be a program name with args. set dummy ocaml; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAML+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAML"; then ac_cv_prog_ac_ct_OCAML="$ac_ct_OCAML" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAML="ocaml" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAML=$ac_cv_prog_ac_ct_OCAML if test -n "$ac_ct_OCAML"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAML" >&5 $as_echo "$ac_ct_OCAML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAML" = x; then OCAML="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAML=$ac_ct_OCAML fi else OCAML="$ac_cv_prog_OCAML" fi # checking for ocamldep if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamldep", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamldep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLDEP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLDEP"; then ac_cv_prog_OCAMLDEP="$OCAMLDEP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLDEP="${ac_tool_prefix}ocamldep" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLDEP=$ac_cv_prog_OCAMLDEP if test -n "$OCAMLDEP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDEP" >&5 $as_echo "$OCAMLDEP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLDEP"; then ac_ct_OCAMLDEP=$OCAMLDEP # Extract the first word of "ocamldep", so it can be a program name with args. set dummy ocamldep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLDEP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLDEP"; then ac_cv_prog_ac_ct_OCAMLDEP="$ac_ct_OCAMLDEP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLDEP="ocamldep" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLDEP=$ac_cv_prog_ac_ct_OCAMLDEP if test -n "$ac_ct_OCAMLDEP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDEP" >&5 $as_echo "$ac_ct_OCAMLDEP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLDEP" = x; then OCAMLDEP="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLDEP=$ac_ct_OCAMLDEP fi else OCAMLDEP="$ac_cv_prog_OCAMLDEP" fi # checking for ocamlmktop if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlmktop", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlmktop; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLMKTOP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLMKTOP"; then ac_cv_prog_OCAMLMKTOP="$OCAMLMKTOP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLMKTOP="${ac_tool_prefix}ocamlmktop" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLMKTOP=$ac_cv_prog_OCAMLMKTOP if test -n "$OCAMLMKTOP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKTOP" >&5 $as_echo "$OCAMLMKTOP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLMKTOP"; then ac_ct_OCAMLMKTOP=$OCAMLMKTOP # Extract the first word of "ocamlmktop", so it can be a program name with args. set dummy ocamlmktop; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLMKTOP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLMKTOP"; then ac_cv_prog_ac_ct_OCAMLMKTOP="$ac_ct_OCAMLMKTOP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLMKTOP="ocamlmktop" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLMKTOP=$ac_cv_prog_ac_ct_OCAMLMKTOP if test -n "$ac_ct_OCAMLMKTOP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKTOP" >&5 $as_echo "$ac_ct_OCAMLMKTOP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLMKTOP" = x; then OCAMLMKTOP="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLMKTOP=$ac_ct_OCAMLMKTOP fi else OCAMLMKTOP="$ac_cv_prog_OCAMLMKTOP" fi # checking for ocamlmklib if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlmklib", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlmklib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLMKLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLMKLIB"; then ac_cv_prog_OCAMLMKLIB="$OCAMLMKLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLMKLIB="${ac_tool_prefix}ocamlmklib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLMKLIB=$ac_cv_prog_OCAMLMKLIB if test -n "$OCAMLMKLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKLIB" >&5 $as_echo "$OCAMLMKLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLMKLIB"; then ac_ct_OCAMLMKLIB=$OCAMLMKLIB # Extract the first word of "ocamlmklib", so it can be a program name with args. set dummy ocamlmklib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLMKLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLMKLIB"; then ac_cv_prog_ac_ct_OCAMLMKLIB="$ac_ct_OCAMLMKLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLMKLIB="ocamlmklib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLMKLIB=$ac_cv_prog_ac_ct_OCAMLMKLIB if test -n "$ac_ct_OCAMLMKLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKLIB" >&5 $as_echo "$ac_ct_OCAMLMKLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLMKLIB" = x; then OCAMLMKLIB="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLMKLIB=$ac_ct_OCAMLMKLIB fi else OCAMLMKLIB="$ac_cv_prog_OCAMLMKLIB" fi # checking for ocamldoc if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamldoc", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamldoc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLDOC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLDOC"; then ac_cv_prog_OCAMLDOC="$OCAMLDOC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLDOC="${ac_tool_prefix}ocamldoc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLDOC=$ac_cv_prog_OCAMLDOC if test -n "$OCAMLDOC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDOC" >&5 $as_echo "$OCAMLDOC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLDOC"; then ac_ct_OCAMLDOC=$OCAMLDOC # Extract the first word of "ocamldoc", so it can be a program name with args. set dummy ocamldoc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLDOC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLDOC"; then ac_cv_prog_ac_ct_OCAMLDOC="$ac_ct_OCAMLDOC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLDOC="ocamldoc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLDOC=$ac_cv_prog_ac_ct_OCAMLDOC if test -n "$ac_ct_OCAMLDOC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDOC" >&5 $as_echo "$ac_ct_OCAMLDOC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLDOC" = x; then OCAMLDOC="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLDOC=$ac_ct_OCAMLDOC fi else OCAMLDOC="$ac_cv_prog_OCAMLDOC" fi # checking for ocamlbuild if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ocamlbuild", so it can be a program name with args. set dummy ${ac_tool_prefix}ocamlbuild; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCAMLBUILD+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCAMLBUILD"; then ac_cv_prog_OCAMLBUILD="$OCAMLBUILD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCAMLBUILD="${ac_tool_prefix}ocamlbuild" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCAMLBUILD=$ac_cv_prog_OCAMLBUILD if test -n "$OCAMLBUILD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLBUILD" >&5 $as_echo "$OCAMLBUILD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OCAMLBUILD"; then ac_ct_OCAMLBUILD=$OCAMLBUILD # Extract the first word of "ocamlbuild", so it can be a program name with args. set dummy ocamlbuild; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OCAMLBUILD+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OCAMLBUILD"; then ac_cv_prog_ac_ct_OCAMLBUILD="$ac_ct_OCAMLBUILD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OCAMLBUILD="ocamlbuild" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OCAMLBUILD=$ac_cv_prog_ac_ct_OCAMLBUILD if test -n "$ac_ct_OCAMLBUILD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLBUILD" >&5 $as_echo "$ac_ct_OCAMLBUILD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OCAMLBUILD" = x; then OCAMLBUILD="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OCAMLBUILD=$ac_ct_OCAMLBUILD fi else OCAMLBUILD="$ac_cv_prog_OCAMLBUILD" fi if test "$OCAMLC" = "no"; then as_fn_error $? "You must install the OCaml compiler" "$LINENO" 5 fi ac_config_files="$ac_config_files Makefile.config version.ocp" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by ocp-indent $as_me 1.5.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ ocp-indent config.status 1.5.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; "version.ocp") CONFIG_FILES="$CONFIG_FILES version.ocp" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi if test "$prefix" = "NONE"; then prefix=$ac_default_prefix fi bindir="`eval echo ${bindir}`" bindir="`eval echo ${bindir}`" echo echo Executables will be installed in ${bindir} ocp-indent-1.5.3/configure.ac000066400000000000000000000007131273277264100160620ustar00rootroot00000000000000AC_INIT(ocp-indent,1.5.3) AC_COPYRIGHT(Copyright 2013-2014 OcamlPro SAS) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AC_PROG_OCAML if test "$OCAMLC" = "no"; then AC_MSG_ERROR([You must install the OCaml compiler]) fi AC_CONFIG_FILES( Makefile.config version.ocp ) AC_OUTPUT if test "$prefix" = "NONE"; then prefix=$ac_default_prefix fi bindir="`eval echo ${bindir}`" bindir="`eval echo ${bindir}`" echo echo Executables will be installed in ${bindir} ocp-indent-1.5.3/doc/000077500000000000000000000000001273277264100143405ustar00rootroot00000000000000ocp-indent-1.5.3/doc/ocp-indent.md000066400000000000000000000120431273277264100167220ustar00rootroot00000000000000# ocp-indent A simple tool to indent OCaml programs Authors: Louis Gesbert (OCamlPro), Thomas Gazagnaire (OCamlPro), Jun Furuse License: LGPL v3 with linking exception ## Installation ### Using OPAM The simplest way to install `ocp-indent` is using [OPAM](http://opam.ocamlpro.com): ```bash opam install ocp-indent ``` ### By hand You can also compile and install `ocp-indent` from sources. You'll need `ocaml (>= 3.12.1)` and `ocp-build (>= 1.99.6-beta)`: ```bash ./configure make make install ``` If you use opam and want it installed alongside ocaml, you may want to use `./configure --prefix $(opam config var prefix)`. ## Usage The above installation step copies elisp scripts to `/share/emacs/site-lisp/` and vim scripts to `/share/ocp-indent/vim/`. You then need to load them in the editor of your choice to automatically use ocp-indent. Installing OPAM package [`user-setup`](https://opam.ocaml.org/packages/user-setup/user-setup.0.3/) will trigger automatic configuration for popular editors (emacs and vim currently, but more are in the works). If you prefer to handle your configuration manually, read on. ### Emacs Run the following command to setup tuareg-mode or caml-mode to use `ocp-indent` for indentation: ```bash echo '(load-file "'"$(opam config var share)"'/emacs/site-lisp/ocp-indent.el")' >>~/.emacs ``` The `tab` key should now reindent the current line using ocp-indent. ### Vim Use the following command to tell Vim to use `ocp-indent` to indent OCaml code: ```bash echo 'set rtp^="'"$(opam config var ocp-indent:share)"'/vim"' >>~/.vimrc ``` Automatic indentation as you type should take place, depending on your configuration. Use `==` to reindent the current line, and `=G` to reindent until the end of buffer. ### Other editors As `ocp-indent` is a command-line tool, you can easily integrate it with other editors. ```bash ocp-indent > ``` You can also tell it to indent only a subsets of lines, and to output only the indentation level: ```bash ocp-indent --lines - --numeric ``` ## Configuration options By default, `ocp-indent` comes with sensible default parameters. However, you can customize some of the indentation options using command-line arguments. For more details, see: ```bash ocp-indent --help ``` ### Configuration file The same parameters can be defined in a configuration file, allowing for user defaults and per-project parameters. The latter is particularly convenient to transparently ensure consistency in projects with many contributors, without requiring them to change their settings in any way (except that, obviously, they need to use ocp-indent !). If a `.ocp-indent` file is found in the current directory or its ancestors, it overrides definitions from `~/.ocp/ocp-indent.conf` and the built-in default. The command-line can of course still be used to override parameters defined in the files. Have a look at ocp-indent's own [`.ocp-indent`](.ocp-indent) file for an example. ### In-file configuration There is no built-in support for in-file configuration directives. Yet, some editors already provide that features, and with emacs, starting your file with a line like: ``` (* -*- ocp-indent-config: in=2 -*- *) ``` will enable you to have the indentation after `in` setup to 2 locally on this file. ## How does it compare to tuareg ? We've run some benchmarks on real code-bases and the result is quite conclusive. Keep in mind than most of existing source files are either indented manually or following tuareg standards. You can see the results [here](http://htmlpreview.github.com/?https://github.com/AltGr/ocp-indent-tests/blob/master/status.html). Moreover, as `ocp-indent` has a deep understanding of the OCaml syntax it shines on specific cases. See for instance the collection of unit-tests [here](https://github.com/OCamlPro/ocp-indent/tree/master/tests/passing). The currently failing tests can be seen [here](http://htmlpreview.github.com/?https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing.html). ## Testing It's hard to deliver a great indenter without tests. We've built `ocp-indent` based on a growing collection of unit-tests. If you find an indentation bug, feel free to send us a code snippet that we will incorporate into our test suite. The tests are organized as follows: * `tests/passing` contains tests that are properly indented and should be left unchanged by ocp-indent. * `tests/failing` contains tests for which ocp-indent currently returns the results in `tests/failing-output`, hence `meld tests/failing{,-output}` should give an overview of currently known bugs (also available online [here](http://htmlpreview.github.com/?https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing.html)). * `tests/test.sh` checks the current state against the reference state (checked into git). * `tests/test.sh --[git-]update` updates the current reference state. * See `tests/test.sh --help` for more Please make sure tu run `make && tests/test.sh --git-update` before any commit, so that the repo always reflects the state of the program. ocp-indent-1.5.3/install.sh000077500000000000000000000131001273277264100155730ustar00rootroot00000000000000#!/bin/bash mkdir -p "$1/bin" if [ -e "_obuild/ocp-indent/ocp-indent.asm" ] then install -m 0755 "_obuild/ocp-indent/ocp-indent.asm" "$1/bin/ocp-indent" else echo "Error: _obuild/ocp-indent/ocp-indent.asm doesn't exist" fi mkdir -p "$1/lib/ocp-indent" if [ -e "META" ] then install -m 0644 "META" "$1/lib/ocp-indent/META" else echo "Error: META doesn't exist" fi mkdir -p "$1/lib/ocp-indent/lib" if [ -e "_obuild/ocp-indent.lib/ocp-indent.lib.a" ] then install -m 0644 "_obuild/ocp-indent.lib/ocp-indent.lib.a" "$1/lib/ocp-indent/lib/ocp-indent.lib.a" else echo "Error: _obuild/ocp-indent.lib/ocp-indent.lib.a doesn't exist" fi if [ -e "_obuild/ocp-indent.lib/ocp-indent.lib.cma" ] then install -m 0644 "_obuild/ocp-indent.lib/ocp-indent.lib.cma" "$1/lib/ocp-indent/lib/ocp-indent.lib.cma" else echo "Error: _obuild/ocp-indent.lib/ocp-indent.lib.cma doesn't exist" fi if [ -e "_obuild/ocp-indent.lib/ocp-indent.lib.cmxa" ] then install -m 0644 "_obuild/ocp-indent.lib/ocp-indent.lib.cmxa" "$1/lib/ocp-indent/lib/ocp-indent.lib.cmxa" else echo "Error: _obuild/ocp-indent.lib/ocp-indent.lib.cmxa doesn't exist" fi if [ -e "_obuild/ocp-indent.lib/indentConfig.cmi" ] then install -m 0644 "_obuild/ocp-indent.lib/indentConfig.cmi" "$1/lib/ocp-indent/lib/indentConfig.cmi" else echo "Error: _obuild/ocp-indent.lib/indentConfig.cmi doesn't exist" fi if [ -e "_obuild/ocp-indent.lib/indentConfig.cmti" ] then install -m 0644 "_obuild/ocp-indent.lib/indentConfig.cmti" "$1/lib/ocp-indent/lib/indentConfig.cmti" fi if [ -e "_obuild/ocp-indent.lib/indentBlock.cmi" ] then install -m 0644 "_obuild/ocp-indent.lib/indentBlock.cmi" "$1/lib/ocp-indent/lib/indentBlock.cmi" else echo "Error: _obuild/ocp-indent.lib/indentBlock.cmi doesn't exist" fi if [ -e "_obuild/ocp-indent.lib/indentBlock.cmti" ] then install -m 0644 "_obuild/ocp-indent.lib/indentBlock.cmti" "$1/lib/ocp-indent/lib/indentBlock.cmti" fi if [ -e "_obuild/ocp-indent.lib/indentPrinter.cmi" ] then install -m 0644 "_obuild/ocp-indent.lib/indentPrinter.cmi" "$1/lib/ocp-indent/lib/indentPrinter.cmi" else echo "Error: _obuild/ocp-indent.lib/indentPrinter.cmi doesn't exist" fi if [ -e "_obuild/ocp-indent.lib/indentPrinter.cmti" ] then install -m 0644 "_obuild/ocp-indent.lib/indentPrinter.cmti" "$1/lib/ocp-indent/lib/indentPrinter.cmti" fi mkdir -p "$1/lib/ocp-indent/utils" if [ -e "_obuild/ocp-indent.utils/ocp-indent.utils.a" ] then install -m 0644 "_obuild/ocp-indent.utils/ocp-indent.utils.a" "$1/lib/ocp-indent/utils/ocp-indent.utils.a" else echo "Error: _obuild/ocp-indent.utils/ocp-indent.utils.a doesn't exist" fi if [ -e "_obuild/ocp-indent.utils/ocp-indent.utils.cma" ] then install -m 0644 "_obuild/ocp-indent.utils/ocp-indent.utils.cma" "$1/lib/ocp-indent/utils/ocp-indent.utils.cma" else echo "Error: _obuild/ocp-indent.utils/ocp-indent.utils.cma doesn't exist" fi if [ -e "_obuild/ocp-indent.utils/ocp-indent.utils.cmxa" ] then install -m 0644 "_obuild/ocp-indent.utils/ocp-indent.utils.cmxa" "$1/lib/ocp-indent/utils/ocp-indent.utils.cmxa" else echo "Error: _obuild/ocp-indent.utils/ocp-indent.utils.cmxa doesn't exist" fi if [ -e "_obuild/ocp-indent.utils/nstream.cmi" ] then install -m 0644 "_obuild/ocp-indent.utils/nstream.cmi" "$1/lib/ocp-indent/utils/nstream.cmi" else echo "Error: _obuild/ocp-indent.utils/nstream.cmi doesn't exist" fi if [ -e "_obuild/ocp-indent.utils/nstream.cmti" ] then install -m 0644 "_obuild/ocp-indent.utils/nstream.cmti" "$1/lib/ocp-indent/utils/nstream.cmti" fi mkdir -p "$1/lib/ocp-indent/lexer" if [ -e "_obuild/ocp-indent.lexer/ocp-indent.lexer.a" ] then install -m 0644 "_obuild/ocp-indent.lexer/ocp-indent.lexer.a" "$1/lib/ocp-indent/lexer/ocp-indent.lexer.a" else echo "Error: _obuild/ocp-indent.lexer/ocp-indent.lexer.a doesn't exist" fi if [ -e "_obuild/ocp-indent.lexer/ocp-indent.lexer.cma" ] then install -m 0644 "_obuild/ocp-indent.lexer/ocp-indent.lexer.cma" "$1/lib/ocp-indent/lexer/ocp-indent.lexer.cma" else echo "Error: _obuild/ocp-indent.lexer/ocp-indent.lexer.cma doesn't exist" fi if [ -e "_obuild/ocp-indent.lexer/ocp-indent.lexer.cmxa" ] then install -m 0644 "_obuild/ocp-indent.lexer/ocp-indent.lexer.cmxa" "$1/lib/ocp-indent/lexer/ocp-indent.lexer.cmxa" else echo "Error: _obuild/ocp-indent.lexer/ocp-indent.lexer.cmxa doesn't exist" fi if [ -e "_obuild/ocp-indent.lexer/approx_tokens.cmi" ] then install -m 0644 "_obuild/ocp-indent.lexer/approx_tokens.cmi" "$1/lib/ocp-indent/lexer/approx_tokens.cmi" else echo "Error: _obuild/ocp-indent.lexer/approx_tokens.cmi doesn't exist" fi if [ -e "_obuild/ocp-indent.lexer/approx_tokens.cmt" ] then install -m 0644 "_obuild/ocp-indent.lexer/approx_tokens.cmt" "$1/lib/ocp-indent/lexer/approx_tokens.cmt" fi if [ -e "_obuild/ocp-indent.lexer/approx_lexer.cmi" ] then install -m 0644 "_obuild/ocp-indent.lexer/approx_lexer.cmi" "$1/lib/ocp-indent/lexer/approx_lexer.cmi" else echo "Error: _obuild/ocp-indent.lexer/approx_lexer.cmi doesn't exist" fi if [ -e "_obuild/ocp-indent.lexer/approx_lexer.cmt" ] then install -m 0644 "_obuild/ocp-indent.lexer/approx_lexer.cmt" "$1/lib/ocp-indent/lexer/approx_lexer.cmt" fi mkdir -p "$1/man/man1" if [ -e "man/man1/ocp-indent.1" ] then install -m 0644 "man/man1/ocp-indent.1" "$1/man/man1/ocp-indent.1" else echo "Error: man/man1/ocp-indent.1 doesn't exist" fi mkdir -p "$1/share/ocp-indent/vim/indent" if [ -e "tools/ocp-indent.vim" ] then install -m 0644 "tools/ocp-indent.vim" "$1/share/ocp-indent/vim/indent/ocaml.vim" else echo "Error: tools/ocp-indent.vim doesn't exist" fi mkdir -p "$1/share/emacs/site-lisp" if [ -e "tools/ocp-indent.el" ] then install -m 0644 "tools/ocp-indent.el" "$1/share/emacs/site-lisp/ocp-indent.el" else echo "Error: tools/ocp-indent.el doesn't exist" fi ocp-indent-1.5.3/m4/000077500000000000000000000000001273277264100141135ustar00rootroot00000000000000ocp-indent-1.5.3/m4/ocaml.m4000066400000000000000000000134501273277264100154530ustar00rootroot00000000000000dnl autoconf macros for OCaml dnl dnl Copyright © 2009 Richard W.M. Jones dnl Copyright © 2009 Stefano Zacchiroli dnl Copyright © 2000-2005 Olivier Andrieu dnl Copyright © 2000-2005 Jean-Christophe Filliâtre dnl Copyright © 2000-2005 Georges Mariano dnl dnl For documentation, please read the ocaml.m4 man page. AC_DEFUN([AC_PROG_OCAML], [dnl # checking for ocamlc AC_CHECK_TOOL([OCAMLC],[ocamlc],[no]) if test "$OCAMLC" != "no"; then OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` AC_MSG_RESULT([OCaml version is $OCAMLVERSION]) # If OCAMLLIB is set, use it if test "$OCAMLLIB" = ""; then OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` else AC_MSG_RESULT([OCAMLLIB previously set; preserving it.]) fi AC_MSG_RESULT([OCaml library path is $OCAMLLIB]) AC_SUBST([OCAMLVERSION]) AC_SUBST([OCAMLLIB]) # checking for ocamlopt AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no]) OCAMLBEST=byte if test "$OCAMLOPT" = "no"; then AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.]) else TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.]) OCAMLOPT=no else OCAMLBEST=opt fi fi AC_SUBST([OCAMLBEST]) # checking for ocamlc.opt AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no]) if test "$OCAMLCDOTOPT" != "no"; then TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.]) else OCAMLC=$OCAMLCDOTOPT fi fi # checking for ocamlopt.opt if test "$OCAMLOPT" != "no" ; then AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no]) if test "$OCAMLOPTDOTOPT" != "no"; then TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.]) else OCAMLOPT=$OCAMLOPTDOTOPT fi fi fi AC_SUBST([OCAMLOPT]) fi AC_SUBST([OCAMLC]) # checking for ocaml toplevel AC_CHECK_TOOL([OCAML],[ocaml],[no]) # checking for ocamldep AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no]) # checking for ocamlmktop AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no]) # checking for ocamlmklib AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no]) # checking for ocamldoc AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no]) # checking for ocamlbuild AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no]) ]) AC_DEFUN([AC_PROG_OCAMLLEX], [dnl # checking for ocamllex AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no]) if test "$OCAMLLEX" != "no"; then AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no]) if test "$OCAMLLEXDOTOPT" != "no"; then OCAMLLEX=$OCAMLLEXDOTOPT fi fi AC_SUBST([OCAMLLEX]) ]) AC_DEFUN([AC_PROG_OCAMLYACC], [dnl AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no]) AC_SUBST([OCAMLYACC]) ]) AC_DEFUN([AC_PROG_CAMLP4], [dnl AC_REQUIRE([AC_PROG_OCAML])dnl # checking for camlp4 AC_CHECK_TOOL([CAMLP4],[camlp4],[no]) if test "$CAMLP4" != "no"; then TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'` if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT([versions differs from ocamlc]) CAMLP4=no fi fi AC_SUBST([CAMLP4]) # checking for companion tools AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no]) AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no]) AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no]) AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no]) AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no]) AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no]) AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no]) AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no]) AC_SUBST([CAMLP4BOOT]) AC_SUBST([CAMLP4O]) AC_SUBST([CAMLP4OF]) AC_SUBST([CAMLP4OOF]) AC_SUBST([CAMLP4ORF]) AC_SUBST([CAMLP4PROF]) AC_SUBST([CAMLP4R]) AC_SUBST([CAMLP4RF]) ]) AC_DEFUN([AC_PROG_FINDLIB], [dnl AC_REQUIRE([AC_PROG_OCAML])dnl # checking for ocamlfind AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no]) AC_SUBST([OCAMLFIND]) ]) dnl Thanks to Jim Meyering for working this next bit out for us. dnl XXX We should define AS_TR_SH if it's not defined already dnl (eg. for old autoconf). AC_DEFUN([AC_CHECK_OCAML_PKG], [dnl AC_REQUIRE([AC_PROG_FINDLIB])dnl AC_MSG_CHECKING([for OCaml findlib package $1]) unset found unset pkg found=no for pkg in $1 $2 ; do if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then AC_MSG_RESULT([found]) AS_TR_SH([OCAML_PKG_$1])=$pkg found=yes break fi done if test "$found" = "no" ; then AC_MSG_RESULT([not found]) AS_TR_SH([OCAML_PKG_$1])=no fi AC_SUBST(AS_TR_SH([OCAML_PKG_$1])) ]) AC_DEFUN([AC_CHECK_OCAML_MODULE], [dnl AC_MSG_CHECKING([for OCaml module $2]) cat > conftest.ml <&5 2>&5 ; then found=yes break fi done if test "$found" ; then AC_MSG_RESULT([$$1]) else AC_MSG_RESULT([not found]) $1=no fi AC_SUBST([$1]) ]) dnl XXX Cross-compiling AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE], [dnl AC_REQUIRE([AC_PROG_OCAML])dnl AC_MSG_CHECKING([for OCaml compiler word size]) cat > conftest.ml < conftest.ml <" "Thomas Gazagnaire " "Jun Furuse" ] homepage: "http://www.typerex.org/ocp-indent.html" bug-reports: "https://github.com/OCamlPro/ocp-indent/issues" license: "LGPL" tags: ["org:ocamlpro" "org:typerex"] dev-repo: "https://github.com/OCamlPro/ocp-indent.git" build: [ ["./configure" "--prefix" prefix] [make] ] depends: [ "ocp-build" {>= "1.99.6-beta"} "cmdliner" ] post-messages: [ "This package requires additional configuration for use in editors. Install package 'user-setup', or manually: * for Emacs, add these lines to ~/.emacs: (add-to-list 'load-path \"%{share}%/emacs/site-lisp\") (require 'ocp-indent) * for Vim, add this line to ~/.vimrc: set rtp^=\"%{share}%/ocp-indent/vim\" " {success & !user-setup:installed} ] ocp-indent-1.5.3/src/000077500000000000000000000000001273277264100143625ustar00rootroot00000000000000ocp-indent-1.5.3/src/approx_lexer.mll000066400000000000000000000522571273277264100176130ustar00rootroot00000000000000(**************************************************************************) (* *) (* TypeRex OCaml Studio *) (* Thomas Gazagnaire, Fabrice Le Fessant, Louis Gesbert *) (* *) (* OCaml *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 2011-2013 OCamlPro *) (* Copyright 1996-2011 INRIA. *) (* All rights reserved. This file is distributed under the terms of *) (* the Q Public License version 1.0. *) (* *) (**************************************************************************) { open Lexing include Approx_tokens let list_last l = List.hd (List.rev l) let lines_starts = ref [] (* The table of keywords *) let keywords = [ "and", AND; "as", AS; "assert", ASSERT; "begin", BEGIN; "class", CLASS; "constraint", CONSTRAINT; "do", DO; "done", DONE; "downto", DOWNTO; "else", ELSE; "end", END; "exception", EXCEPTION; "external", EXTERNAL; "false", FALSE; "for", FOR; "fun", FUN; "function", FUNCTION; "functor", FUNCTOR; "if", IF; "in", IN; "include", INCLUDE; "inherit", INHERIT; "initializer", INITIALIZER; "lazy", LAZY; "let", LET; "match", MATCH; "method", METHOD; "module", MODULE; "mutable", MUTABLE; "new", NEW; "object", OBJECT; "of", OF; "open", OPEN; "or", OR; "private", PRIVATE; "rec", REC; "sig", SIG; "struct", STRUCT; "then", THEN; "to", TO; "true", TRUE; "try", TRY; "type", TYPE; "val", VAL; "virtual", VIRTUAL; "when", WHEN; "while", WHILE; "with", WITH; "mod", INFIXOP3("mod"); "land", INFIXOP3("land"); "lor", INFIXOP3("lor"); "lxor", INFIXOP3("lxor"); "lsl", INFIXOP4("lsl"); "lsr", INFIXOP4("lsr"); "asr", INFIXOP4("asr"); ] let keyword_table = let t = Hashtbl.create 149 in List.iter (fun (x,y) -> Hashtbl.add t x y) keywords; t let lexer_extensions : (Lexing.lexbuf -> Approx_tokens.token) list ref = ref [] let enable_extension name = let t = IndentExtend.find name in List.iter (fun (x,y) -> Hashtbl.add keyword_table x y) t.IndentExtend.keywords; match t.IndentExtend.lexer with | None -> () | Some f -> lexer_extensions := f :: !lexer_extensions let disable_extensions () = Hashtbl.clear keyword_table; lexer_extensions := []; List.iter (fun (x,y) -> Hashtbl.add keyword_table x y) keywords (* To buffer string literals *) let initial_string_buffer = String.create 256 let string_buff = ref initial_string_buffer let string_index = ref 0 let reset_string_buffer () = string_buff := initial_string_buffer; string_index := 0 let store_string_char c = if !string_index >= String.length (!string_buff) then begin let new_buff = String.create (String.length (!string_buff) * 2) in String.blit (!string_buff) 0 new_buff 0 (String.length (!string_buff)); string_buff := new_buff end; String.unsafe_set (!string_buff) (!string_index) c; incr string_index let get_stored_string () = let s = String.sub (!string_buff) 0 (!string_index) in string_buff := initial_string_buffer; s (* To store the position of the beginning of a string and comment *) let string_start_loc = ref (-1);; let quotation_start_loc = ref (-1);; let quotation_kind = ref (`Camlp4 : [ `Camlp4 | `Ppx of string ]);; type in_comment = Comment | Code | Verbatim | CommentCont let comment_stack : in_comment list ref = ref [] ;; let entering_inline_code_block = ref false;; let rec close_comment () = match !comment_stack with | Comment :: r -> comment_stack := r; COMMENT | CommentCont :: r -> comment_stack := r; COMMENTCONT | (Code | Verbatim) :: r -> comment_stack := r; close_comment () | [] -> assert false ;; let in_comment () = match !comment_stack with | (Comment | CommentCont | Verbatim) :: _ -> true | Code :: _ | [] -> false ;; let in_verbatim () = List.mem Verbatim !comment_stack let init () = lines_starts := []; (* disable_extensions(); *) reset_string_buffer(); string_start_loc := -1; quotation_start_loc := -1; quotation_kind := `Camlp4; comment_stack := []; entering_inline_code_block := false ;; let rewind lexbuf n = lexbuf.lex_curr_pos <- lexbuf.lex_curr_pos - n; let curpos = lexbuf.lex_curr_p in lexbuf.lex_curr_p <- { curpos with pos_cnum = curpos.pos_cnum - n } ;; (* To translate escape sequences *) let char_for_backslash = function | 'n' -> '\010' | 'r' -> '\013' | 'b' -> '\008' | 't' -> '\009' | c -> c let can_overflow f lexbuf = let s = Lexing.lexeme lexbuf in try InRange (f s) with Failure _ -> Overflow s let char_for_decimal_code i s = let c = 100 * (Char.code(s.[i]) - 48) + 10 * (Char.code(s.[i+1]) - 48) + (Char.code(s.[i+2]) - 48) in if (c < 0 || c > 255) then failwith "Bad escaped decimal char" else Char.chr c let char_for_hexadecimal_code lexbuf i = let d1 = Char.code (Lexing.lexeme_char lexbuf i) in let val1 = if d1 >= 97 then d1 - 87 else if d1 >= 65 then d1 - 55 else d1 - 48 in let d2 = Char.code (Lexing.lexeme_char lexbuf (i+1)) in let val2 = if d2 >= 97 then d2 - 87 else if d2 >= 65 then d2 - 55 else d2 - 48 in Char.chr (val1 * 16 + val2) (* To convert integer literals, allowing max_int + 1 (PR#4210) *) let cvt_int_literal s = - int_of_string ("-" ^ s) let cvt_int32_literal s = Int32.neg (Int32.of_string ("-" ^ String.sub s 0 (String.length s - 1))) let cvt_int64_literal s = Int64.neg (Int64.of_string ("-" ^ String.sub s 0 (String.length s - 1))) let cvt_nativeint_literal s = Nativeint.neg (Nativeint.of_string ("-" ^ String.sub s 0 (String.length s - 1))) (* Remove underscores from float literals *) let remove_underscores s = let l = String.length s in let rec remove src dst = if src >= l then if dst >= l then s else String.sub s 0 dst else match s.[src] with '_' -> remove (src + 1) dst | c -> s.[dst] <- c; remove (src + 1) (dst + 1) in remove 0 0 (* Update the current location with file name and line number. *) let update_loc lexbuf file line absolute chars = let pos = lexbuf.lex_curr_p in let new_file = match file with | None -> pos.pos_fname | Some s -> s in lexbuf.lex_curr_p <- { pos with pos_fname = new_file; pos_lnum = if absolute then line else pos.pos_lnum + line; pos_bol = pos.pos_cnum - chars; }; lines_starts := (lexbuf.lex_curr_p.pos_lnum, lexbuf.lex_curr_p.pos_bol) :: !lines_starts; ;; } let newline = ('\010' | '\013' | "\013\010") let blank = [' ' '\009' '\012'] let lowercase = ['a'-'z' '\223'-'\246' '\248'-'\255' '_' '\''] let uppercase = ['A'-'Z' '\192'-'\214' '\216'-'\222' '`'] let identchar = ['A'-'Z' 'a'-'z' '_' '\192'-'\214' '\216'-'\246' '\248'-'\255' '\'' '0'-'9'] let symbolchar = ['!' '$' '%' '&' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '|' '~'] let decimal_literal = (['0'-'9'] ['0'-'9' '_']*) let hex_literal = ('0' ['x' 'X'] ['0'-'9' 'A'-'F' 'a'-'f']['0'-'9' 'A'-'F' 'a'-'f' '_']*) let oct_literal = ('0' ['o' 'O'] ['0'-'7'] ['0'-'7' '_']*) let bin_literal = ('0' ['b' 'B'] ['0'-'1'] ['0'-'1' '_']*) let int_literal = (decimal_literal | hex_literal | oct_literal | bin_literal) let float_literal = ['0'-'9'] ['0'-'9' '_']* ('.' ['0'-'9' '_']* )? (['e' 'E'] ['+' '-']? ['0'-'9'] ['0'-'9' '_']*)? rule parse_token = parse | newline { update_loc lexbuf None 1 false 0; EOL } | blank + { SPACES } | "_" { UNDERSCORE } | "~" { TILDE } | "~" lowercase identchar * ':' { let s = Lexing.lexeme lexbuf in let name = String.sub s 1 (String.length s - 2) in (* if Hashtbl.mem keyword_table name then raise (Error(Keyword_as_label name, Location.curr lexbuf)); *) LABEL name } | "?" { QUESTION } | "??" { QUESTIONQUESTION } | "?" lowercase identchar * ':' { let s = Lexing.lexeme lexbuf in let name = String.sub s 1 (String.length s - 2) in (* if Hashtbl.mem keyword_table name then raise (Error(Keyword_as_label name, Location.curr lexbuf)); *) OPTLABEL name } | lowercase identchar * ( '%' identchar + ('.' identchar +) * ) ? { let s = Lexing.lexeme lexbuf in try let i = String.index_from s 1 '%' in let kw = String.sub s 0 i in try Hashtbl.find keyword_table kw with Not_found -> rewind lexbuf (String.length s - i); LIDENT s with Not_found -> try Hashtbl.find keyword_table s with Not_found -> LIDENT s } | uppercase identchar * { UIDENT(Lexing.lexeme lexbuf) } (* No capitalized keywords *) | int_literal { INT (can_overflow cvt_int_literal lexbuf) } | float_literal { FLOAT (remove_underscores(Lexing.lexeme lexbuf)) } | int_literal "l" { INT32 (can_overflow cvt_int32_literal lexbuf) } | int_literal "L" { INT64 (can_overflow cvt_int64_literal lexbuf) } | int_literal "n" { NATIVEINT (can_overflow cvt_nativeint_literal lexbuf) } | "\"" { reset_string_buffer(); let string_start = lexbuf.lex_start_p in string_start_loc := Lexing.lexeme_start lexbuf; let token = string lexbuf in lexbuf.lex_start_p <- string_start; token } | "'" newline "'" { update_loc lexbuf None 1 false 1; CHAR (InRange (Lexing.lexeme_char lexbuf 1)) } | "'" [^ '\\' '\'' '\010' '\013'] "'" { CHAR( InRange (Lexing.lexeme_char lexbuf 1)) } | "'\\" ['\\' '\'' '"' 'n' 't' 'b' 'r' ' '] "'" { CHAR( InRange (char_for_backslash (Lexing.lexeme_char lexbuf 2))) } | "'\\" ['0'-'9'] ['0'-'9'] ['0'-'9'] "'" { CHAR(can_overflow (char_for_decimal_code 2) lexbuf) } | "'\\" 'x' ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] "'" { CHAR( InRange (char_for_hexadecimal_code lexbuf 3)) } | "'\\" _ { let l = Lexing.lexeme lexbuf in CHAR ( Overflow l ) } | "(*" { let comment_start = lexbuf.lex_start_p in comment_stack := Comment :: !comment_stack; let token = comment lexbuf in lexbuf.lex_start_p <- comment_start; token } | "*)" { match !comment_stack with | _ :: _ -> close_comment () | [] -> rewind lexbuf 1; STAR } | '{' [ '[' 'v' ] { if !entering_inline_code_block then begin entering_inline_code_block := false; match !comment_stack with | Code :: _ -> OCAMLDOC_CODE | Verbatim :: _ -> let verb_start = lexbuf.lex_start_p in let token = verbatim lexbuf in lexbuf.lex_start_p <- verb_start; token | _ -> assert false end else begin rewind lexbuf 1; LBRACE end } | [ ']' 'v' ] '}' { match !comment_stack with | (Code|Verbatim)::r -> comment_stack := r; let comment_start = lexbuf.lex_start_p in let token = comment lexbuf in lexbuf.lex_start_p <- comment_start; token | _ -> rewind lexbuf 1; match lexbuf.lex_buffer.[lexbuf.lex_curr_pos - 1] with | ']' -> RBRACKET | 'v' -> LIDENT "v" | _ -> assert false } | "<:" identchar * "<" { let start = lexbuf.lex_start_p in quotation_start_loc := Lexing.lexeme_start lexbuf; quotation_kind := `Camlp4; let token = quotation lexbuf in lexbuf.lex_start_p <- start; token } | "{" identchar * "|" { let start = lexbuf.lex_start_p in quotation_start_loc := Lexing.lexeme_start lexbuf; let s = Lexing.lexeme lexbuf in let delim = String.sub s 1 (String.length s - 2) in quotation_kind := `Ppx delim; let token = quotation lexbuf in lexbuf.lex_start_p <- start; token } | "#" [' ' '\t']* (['0'-'9']+ as _num) [' ' '\t']* ("\"" ([^ '\010' '\013' '"' ] * as _name) "\"")? [^ '\010' '\013'] * newline { update_loc lexbuf None 1 false 0; LINE_DIRECTIVE } | "#" { SHARP } | "&" { AMPERSAND } | "&&" { AMPERAMPER } | "`" { BACKQUOTE } | "'" { QUOTE } | "(" { LPAREN } | ")" { RPAREN } | "*" { STAR } | "," { COMMA } | "->" { MINUSGREATER } | "." { DOT } | ".." { DOTDOT } | ":" { COLON } | "::" { COLONCOLON } | ":=" { COLONEQUAL } | ":>" { COLONGREATER } | ";" { SEMI } | ";;" { SEMISEMI } | "<" { LESS } | "<-" { LESSMINUS } | "=" { EQUAL } | "[" { LBRACKET } | "[|" { LBRACKETBAR } | "[<" { LBRACKETLESS } | "[>" { LBRACKETGREATER } | "]" { RBRACKET } | "{" { LBRACE } | "{<" { LBRACELESS } | "|" { BAR } | "||" { BARBAR } | "|]" { BARRBRACKET } | ">" { GREATER } | ">]" { GREATERRBRACKET } | "}" { RBRACE } | ">}" { GREATERRBRACE } | "[%" { LBRACKETPERCENT } | "[%%" { LBRACKETPERCENTPERCENT } | "[@" { LBRACKETAT } | "[@@" { LBRACKETATAT } | "[@@@" { LBRACKETATATAT } | "!" { BANG } | "!=" { INFIXOP0 "!=" } | "+" { PLUS } | "+." { PLUSDOT } | "-" { MINUS } | "-." { MINUSDOT } | "!" symbolchar + { PREFIXOP(Lexing.lexeme lexbuf) } | ['~' '?'] symbolchar + { PREFIXOP(Lexing.lexeme lexbuf) } | ['=' '<' '>' '|' '&' '$'] symbolchar * { INFIXOP0(Lexing.lexeme lexbuf) } | ['@' '^'] symbolchar * { INFIXOP1(Lexing.lexeme lexbuf) } | ['+' '-'] symbolchar * { INFIXOP2(Lexing.lexeme lexbuf) } | "**" symbolchar * { INFIXOP4(Lexing.lexeme lexbuf) } | ['*' '/' '%'] symbolchar * { INFIXOP3(Lexing.lexeme lexbuf) } | eof { EOF } | _ { ILLEGAL_CHAR (Lexing.lexeme_char lexbuf 0) } and quotation = parse ">>" { if !quotation_kind = `Camlp4 then QUOTATION else quotation lexbuf } | "|" identchar * "}" { match !quotation_kind with | `Ppx delim -> let s = Lexing.lexeme lexbuf in let ndelim = String.sub s 1 (String.length s - 2) in if ndelim = delim then QUOTATION else quotation lexbuf | `Camlp4 -> quotation lexbuf } | newline { update_loc lexbuf None 1 false 0; quotation lexbuf } | eof { QUOTATION } | _ { quotation lexbuf } and comment = parse | "(*" { comment_stack := Comment :: !comment_stack; comment lexbuf } | "*)" | eof { let tok = close_comment () in if in_verbatim () then verbatim lexbuf else match !comment_stack with | (Comment | CommentCont) :: _ -> comment lexbuf | _ -> tok } | newline? blank* '{' [ '[' 'v' ] { if in_verbatim() then comment lexbuf else let tok = match !comment_stack with | CommentCont::_ -> COMMENTCONT | Comment::r -> comment_stack := CommentCont::r; COMMENT | _s -> assert false in let block = match lexbuf.lex_buffer.[lexbuf.lex_curr_pos - 1] with | '[' -> Code | 'v' -> Verbatim | _ -> assert false in comment_stack := block :: !comment_stack; entering_inline_code_block := true; (* unparse the token, to be parsed again as code *) lexbuf.Lexing.lex_curr_p <- lexbuf.Lexing.lex_start_p; lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_start_pos; tok } | '"' { reset_string_buffer(); string_start_loc := Lexing.lexeme_start lexbuf; ignore (string lexbuf); reset_string_buffer (); comment lexbuf } | "''" { comment lexbuf } | "'" newline "'" { update_loc lexbuf None 1 false 1; comment lexbuf } | "'" [^ '\\' '\'' '\010' '\013' ] "'" { comment lexbuf } | "'\\" ['\\' '"' '\'' 'n' 't' 'b' 'r' ' '] "'" { comment lexbuf } | "'\\" ['0'-'9'] ['0'-'9'] ['0'-'9'] "'" { comment lexbuf } | "'\\" 'x' ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] "'" { comment lexbuf } | newline { update_loc lexbuf None 1 false 0; comment lexbuf } | _ { comment lexbuf } (* Ocamldoc verbatim, inside comments ; mostly the same as the comment rule *) and verbatim = parse | "(*" { comment_stack := Comment :: !comment_stack; comment lexbuf } | "*)" { (* leave the verbatim block and unparse the token *) comment_stack := (match !comment_stack with | Verbatim :: s -> s | _ -> assert false); lexbuf.Lexing.lex_curr_p <- lexbuf.Lexing.lex_start_p; lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_start_pos; (* let the surrounding comments close themselves *) match !comment_stack with | Comment :: _ -> comment lexbuf | CommentCont :: r -> comment_stack := Comment :: r; comment lexbuf | _ -> OCAMLDOC_VERB } | "v}" { (* Unparse the token but leave the comment stack. The token rule will reparse, detect it, pop the verbatim and return to the comment rule. *) rewind lexbuf 2; OCAMLDOC_VERB } | "\"" { reset_string_buffer(); string_start_loc := Lexing.lexeme_start lexbuf; ignore (string lexbuf); reset_string_buffer (); verbatim lexbuf } | "''" { verbatim lexbuf } | "'" newline "'" { update_loc lexbuf None 1 false 1; verbatim lexbuf } | "'" [^ '\\' '\'' '\010' '\013' ] "'" { verbatim lexbuf } | "'\\" ['\\' '"' '\'' 'n' 't' 'b' 'r' ' '] "'" { verbatim lexbuf } | "'\\" ['0'-'9'] ['0'-'9'] ['0'-'9'] "'" { verbatim lexbuf } | "'\\" 'x' ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] "'" { verbatim lexbuf } | newline { update_loc lexbuf None 1 false 0; verbatim lexbuf } | eof { OCAMLDOC_VERB } | _ { verbatim lexbuf } and string = parse '"' | eof { STRING (get_stored_string ()) } | '\\' newline ([' ' '\t'] * as space) { update_loc lexbuf None 1 false (String.length space); string lexbuf } | '\\' ['\\' '\'' '"' 'n' 't' 'b' 'r' ' '] { store_string_char(char_for_backslash(Lexing.lexeme_char lexbuf 1)); string lexbuf } | '\\' ['0'-'9'] ['0'-'9'] ['0'-'9'] { (match can_overflow (char_for_decimal_code 1) lexbuf with | Overflow _ -> let s = Lexing.lexeme lexbuf in for i = 0 to String.length s - 1 do store_string_char s.[i] done | InRange c -> store_string_char c); string lexbuf } | '\\' 'x' ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] { store_string_char(char_for_hexadecimal_code lexbuf 2); string lexbuf } | '\\' _ { if in_comment () then string lexbuf else begin (* Should be an error, but we are very lax. raise (Error (Illegal_escape (Lexing.lexeme lexbuf), Location.curr lexbuf)) *) store_string_char (Lexing.lexeme_char lexbuf 0); store_string_char (Lexing.lexeme_char lexbuf 1); string lexbuf end } | newline { update_loc lexbuf None 1 false 0; let s = Lexing.lexeme lexbuf in for i = 0 to String.length s - 1 do store_string_char s.[i]; done; string lexbuf } | _ { store_string_char(Lexing.lexeme_char lexbuf 0); string lexbuf } { let token = let rec tok lexbuf = function | [] -> parse_token lexbuf | x::xs -> begin try x lexbuf with | _ -> tok lexbuf xs end in fun lexbuf -> tok lexbuf !lexer_extensions let rec token_locs lexbuf = match token lexbuf with COMMENT -> token_locs lexbuf | token -> token, ( lexbuf.lex_start_p, lexbuf.lex_curr_p) let rec token_pos lexbuf = match token lexbuf with COMMENT -> token_pos lexbuf | token -> token, ( lexbuf.lex_start_p.pos_cnum, lexbuf.lex_curr_p.pos_cnum) let token_locs_and_comments lexbuf = let token = token lexbuf in token, ( lexbuf.lex_start_p, lexbuf.lex_curr_p) let get_token = token let token_with_comments = get_token let rec token lexbuf = match get_token lexbuf with COMMENT -> token lexbuf | tok -> tok let tokens_of_file filename = let ic = open_in filename in try init (); let lexbuf = Lexing.from_channel ic in let rec iter tokens = let token = token_pos lexbuf in match token with (EOF, _) -> List.rev tokens | _ -> iter (token :: tokens) in let tokens = iter [] in close_in ic; tokens with e -> close_in ic; raise e let tokens_with_loc_of_string s = init (); let lexbuf = Lexing.from_string s in let rec iter tokens = let token = token_pos lexbuf in match token with (EOF, _) -> List.rev tokens | _ -> iter (token :: tokens) in let tokens = iter [] in tokens let tokens_of_string s = init (); let lexbuf = Lexing.from_string s in let rec iter tokens = let token = token lexbuf in match token with (EOF) -> List.rev tokens | _ -> iter (token :: tokens) in let tokens = iter [] in tokens let lines () = List.rev ( !lines_starts ) } ocp-indent-1.5.3/src/approx_tokens.ml000066400000000000000000000063251273277264100176160ustar00rootroot00000000000000(**************************************************************************) (* *) (* TypeRex OCaml Studio *) (* Thomas Gazagnaire, Fabrice Le Fessant, Louis Gesbert *) (* *) (* OCaml *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 2011-2013 OCamlPro *) (* Copyright 1996-2011 INRIA. *) (* All rights reserved. This file is distributed under the terms of *) (* the Q Public License version 1.0. *) (* *) (**************************************************************************) (* ADMIN: fabrice *) (* Instead of raising an error when a CHAR, INT, INT32, INT64 or NATIVEINT overflows, we just changed the returned value to take that into account. *) type 'a overflow = | InRange of 'a | Overflow of string type token = | AMPERAMPER | AMPERSAND | AND | AS | ASSERT | BACKQUOTE | BANG | BAR | BARBAR | BARRBRACKET | BEGIN | CHAR of (char overflow) | CLASS | COLON | COLONCOLON | COLONEQUAL | COLONGREATER | COMMA (* Start of comment from code *) | COMMENT (* Start of inline code section within comment: "{[" *) | OCAMLDOC_CODE (* Start of verbatim section within comment: "{v" *) | OCAMLDOC_VERB (* Continuation of comment after a closed ocamldoc code or verb section *) | COMMENTCONT | CONSTRAINT | DO | DONE | DOT | DOTDOT | DOWNTO | ELSE | END | EOF | EQUAL | EXCEPTION | EXTERNAL | FALSE | FLOAT of (string) | FOR | FUN | FUNCTION | FUNCTOR | GREATER | GREATERRBRACE | GREATERRBRACKET | IF | ILLEGAL_CHAR of (char) | IN | INCLUDE | INFIXOP0 of (string) | INFIXOP1 of (string) | INFIXOP2 of (string) | INFIXOP3 of (string) | INFIXOP4 of (string) | INHERIT | INITIALIZER | INT of (int overflow) | INT32 of (int32 overflow) | INT64 of (int64 overflow) | LABEL of (string) | LAZY | LBRACE | LBRACELESS | LBRACKET | LBRACKETBAR | LBRACKETLESS | LBRACKETGREATER | LBRACKETPERCENT | LBRACKETPERCENTPERCENT | LBRACKETAT | LBRACKETATAT | LBRACKETATATAT | LESS | LESSMINUS | LET | LIDENT of (string) | LINE_DIRECTIVE | LPAREN | MATCH | METHOD | MINUS | MINUSDOT | MINUSGREATER | MODULE | MUTABLE | NATIVEINT of (nativeint overflow) | NEW | OBJECT | OF | OPEN | OPTLABEL of (string) | OR | PLUS | PLUSDOT | PREFIXOP of (string) | PRIVATE | QUESTION | QUESTIONQUESTION | QUOTATION | QUOTE | RBRACE | RBRACKET | REC | RPAREN | SEMI | SEMISEMI | SHARP | SIG | STAR | STRING of (string) | STRUCT | THEN | TILDE | TO | TRUE | TRY | TYPE | UIDENT of (string) | UNDERSCORE | VAL | VIRTUAL | WHEN | WHILE | WITH | EOL | SPACES ocp-indent-1.5.3/src/indentArgs.ml000066400000000000000000000220671273277264100170210ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) open Cmdliner type input = InChannel of in_channel | File of string type t = { file_out : string option; numeric: bool; (* [indent_config] Stores the config strings, because different files may have different defaults if located in different directories *) indent_config: string list; debug: bool; inplace : bool; indent_empty: bool; in_lines: int -> bool; indent_printer: out_channel -> unit IndentPrinter.output_kind; syntax_exts: string list; dynlink : [`Mod of string | `Pkg of string] list; } let options = let config = let doc = "Configure the indentation parameters. See section \ $(b,CONFIGURATION) for more information." in let config_converter = (fun str -> try (* just check syntax *) ignore (IndentConfig.update_from_string IndentConfig.default str); `Ok str with Invalid_argument s -> `Error s), (Format.pp_print_string) in Arg.(value & opt_all config_converter [] & info ["c";"config"] ~docv:"CONFIG" ~doc) in let debug = let doc = "Enable debug output to stderr." in Arg.(value & flag & info ["d";"debug"] ~doc) in let inplace = let doc = "Re-indent files in-place." in Arg.(value & flag & info ["i";"inplace"] ~doc) in let indent_empty = let doc = "Return indent for empty lines, too. Especially usefull \ with $(--numeric)." in Arg.(value & flag & info ["indent-empty"] ~doc) in let lines = let doc = "Only re-indent the lines in $(docv) (eg. 10-12), \ adapting to the current indentation of surrounding lines. \ Lines start at 1." in let range_converter = (fun str -> try match Util.string_split '-' str with | [s] -> let li = int_of_string s in `Ok(Some li, Some li) | [s1;s2] -> let f = function "" -> None | s -> Some (int_of_string s) in `Ok (f s1, f s2) | _ -> failwith "range_converter" with Failure _ -> `Error "invalid range specification."), (fun fmt -> function | Some n1, Some n2 when n1 = n2 -> Format.pp_print_int fmt n1 | o1, o2 -> let f fmt = function None -> () | Some n -> Format.pp_print_int fmt n in Format.fprintf fmt "%a-%a" f o1 f o2) in Arg.(value & opt range_converter (None,None) & info ["l";"lines"] ~docv:"RANGE" ~doc) in let numeric = let doc = "Instead of re-indenting the file, output one integer per line \ representing the indentation value. When specified together \ with $(i,--lines), only print as many values as lines in the \ range." in Arg.(value & flag & info ["numeric"] ~doc) in let output = let doc = "Output to $(docv). The default is to print to stdout." in Arg.(value & opt (some string) None & info ["o";"output"] ~docv:"FILE" ~doc) in let print_config = let doc = "Print the current parameters to stdout and exit. \ (See section $(b,CONFIGURATION) for more information.)" in Arg.(value & flag & info ["print-config"] ~doc) in let syntax = let doc = "Extend the handled syntax for OCaml syntax extensions." in let arg = Arg.(value & opt_all (list string) [] & info ["syntax"] ~doc) in Term.(pure List.flatten $ arg) in let load_pkgs = let doc = "Load plugins." in let arg = Arg.(value & opt_all (list string) [] & info ["load-pkgs"] ~doc) in Term.(pure List.flatten $ arg) in let load_mods = let doc = "Load plugins." in let arg = Arg.(value & opt_all (list string) [] & info ["load-mods"] ~doc) in Term.(pure List.flatten $ arg) in let files = let arg = Arg.(value & pos_all file [] & info [] ~docv:"FILE") in let f = function | [] -> [InChannel stdin] | l -> List.map (function "-" -> InChannel stdin | s -> File s) l in Term.(pure f $ arg) in let build_t indent_config debug inplace indent_empty lines numeric file_out print_config syntax_exts load_pkgs load_mods files = if inplace && (file_out <> None || numeric) then `Error (false, "incompatible options used with --inplace") else if print_config then (let conf, synt,dlink = IndentConfig.local_default () in print_endline (IndentConfig.to_string ~sep:"\n" conf); if synt <> [] then Printf.printf "syntax = %s\n" (String.concat " " synt); if dlink <> [] then Printf.printf "load = %s\n" (String.concat " " ( List.map (function `Pkg s -> s | `Mod s -> s) dlink)); exit 0) else `Ok ( { file_out; numeric; indent_config; debug; inplace; indent_empty = indent_empty || (match lines with | Some fst, Some lst when fst = lst -> true | _ -> false); in_lines = (match lines with | None, None -> fun _ -> true | Some first, Some last -> fun l -> first <= l && l <= last | Some first, None -> fun l -> first <= l | None, Some last -> fun l -> l <= last); indent_printer = (fun oc -> if numeric then IndentPrinter.Numeric (fun n () -> output_string oc (string_of_int n); output_string oc "\n") else IndentPrinter.Print (if debug then (fun s () -> output_string oc s; try let _ = String.index s '\n' in flush stdout with Not_found -> ()) else (fun s () -> output_string oc s))); syntax_exts; dynlink = (List.map (fun s -> `Mod s) load_mods) @ (List.map (fun s -> `Pkg s) load_pkgs) }, files ) in let t = Term.(pure build_t $ config $ debug $ inplace $ indent_empty $ lines $ numeric $ output $ print_config $ syntax $ load_pkgs $ load_mods $ files) in Term.ret t let info = let doc = "Automatic indentation of OCaml source files" in let man = [ `S "DESCRIPTION"; `P "Indent OCaml source files according to the official conventions, with \ a small number of tunable parameters."; `P "Outputs the indented version of each FILE given in the command line to \ standard output, unless invoked with the `--inplace' option (see \ $(b,OPTIONS) below). If no FILE is provided, reads from standard \ input."; `S "CONFIGURATION"; `P "Parameters can be defined on the command-line via the $(i,--config) \ option, or as a configuration definition in one of the following, \ searched in order: a file named `.ocp-indent' in the current directory \ or its parents (which allows for per-project indentation settings), \ the file `$HOME/.ocp/ocp-indent.conf', or the environment variable \ $OCP_INDENT_CONFIG." ] @ IndentConfig.man @ [ `S "BUGS"; `P "Bugs are tracked on github at \ $(i,https://github.com/OCamlPro/ocp-indent/issues). The $(i,tests) \ directory of the source distribution is a good snapshot of the current \ status, and can be checked online at \ $(i,http://htmlpreview.github.io/?\ https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing.html)"; `S "SEE ALSO"; `P "ocaml(1), ocp-index(1)"; `S "AUTHORS"; `P "Louis Gesbert and Thomas Gazagnaire from OCamlPro, from an original \ prototype by Jun Furuse."; `S "LICENSE"; `P "Copyright (C) 2013 OCamlPro."; `P "ocp-indent is free software, released under the terms of the GNU General \ Public License version 3, the text of which can be found in the file \ `LICENSE' distributed with the sources." ] in Term.info "ocp-indent" ~version:IndentVersion.version ~doc ~man ocp-indent-1.5.3/src/indentArgs.mli000066400000000000000000000032211273277264100171610ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) type input = InChannel of in_channel | File of string (* Type of parameters obtained from command-line options *) type t = private { file_out : string option; numeric: bool; indent_config: string list; debug: bool; inplace : bool; indent_empty: bool; in_lines: int -> bool; indent_printer: out_channel -> unit IndentPrinter.output_kind; syntax_exts: string list; dynlink : [`Pkg of string | `Mod of string ] list; } val options: (t * input list) Cmdliner.Term.t val info: Cmdliner.Term.info ocp-indent-1.5.3/src/indentBlock.ml000066400000000000000000001572071273277264100171640ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012,2015 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) open Pos open Nstream open Approx_lexer open Util module Node = struct (* Node kind *) type kind = | KParen | KBrace | KBracket | KBracketBar | KLet | KAnd of kind | KLetIn | KIn | KExpr of int (* actually handles also patterns / types / ... *) (* Parameter:Priority - next expression is deindented if the op has lower priority *) | KBody of kind | KArrow of kind | KColon | KType | KException | KOpen | KInclude | KVal | KBar of kind (* Stores the original token and line offset for alignment of comment continuations *) | KComment of Nstream.token * int (* ocamldoc verbatim block *) | KVerbatim of Nstream.token * int | KUnknown | KStruct | KSig | KModule | KBegin | KObject | KMatch | KTry | KWith of kind | KLoop | KIf | KThen | KElse | KDo | KFun | KWhen | KExternal | KCodeInComment | KExtendedExpr of string list | KExtendedItem of string list | KAttrId of string list * bool (* Priority of open expression constructs (see below for operators) *) let prio = function | KIn | KArrow _ -> 0 | KThen | KElse -> 10 | KExpr i -> i | _ -> -10 let prio_max = 200 let prio_dot = 160 let prio_apply = 140 let expr_atom = KExpr prio_max let expr_apply = KExpr 140 (* Special operators that should break arrow indentation have this prio (eg monad operators, >>=) *) let prio_flatop = 59 let prio_semi = 5 let rec follow = function | KAnd k | KBody k | KWith k -> follow k | k -> k let rec string_of_kind = function | KExpr i -> Printf.sprintf "KExpr(%d)" i | KParen -> "KParen" | KBrace -> "KBrace" | KBracket -> "KBracket" | KBracketBar -> "KBracketBar" (* | KField -> "KField" *) | KLet -> "KLet" | KIn -> "KIn" | KAnd k -> aux "KAnd" k | KLetIn -> "KLetIn" | KBody k -> aux "KBody" k | KArrow k -> aux "KArrow" k | KColon -> "KColon" | KVal -> "KVal" | KBar k -> aux "KBar" k | KOpen -> "KOpen" | KInclude -> "KInclude" | KComment _ -> "KComment" | KVerbatim _ -> "KVerbatim" | KUnknown -> "KUnknown" | KType -> "Ktype" | KException -> "KException" | KStruct -> "KStruct" | KSig -> "KSig" | KModule -> "KModule" | KBegin -> "KBegin" | KObject -> "KObject" | KMatch -> "KMatch" | KTry -> "KTry" | KWith k -> aux "KWith" k | KLoop -> "KLoop" | KIf -> "KIf" | KThen -> "Kthen" | KElse -> "KElse" | KDo -> "KDo" | KFun -> "KFun" | KWhen -> "KWhen" | KExternal -> "KExternal" | KCodeInComment -> "KCodeInComment" | KExtendedExpr name -> Printf.sprintf "KExtendedExpr(%s)" (String.concat "." (List.rev name)) | KExtendedItem name -> Printf.sprintf "KExtendedItem(%s)" (String.concat "." (List.rev name)) | KAttrId(name, dotted) -> Printf.sprintf "KAttrId(%s,%B)" (String.concat "." (List.rev name)) dotted and aux str k = Printf.sprintf "%s(%s)" str (string_of_kind k) (* A node: - has a kind - has the current line offset [indent] - has the current token offset [column] - has a inner padding [pad] - has a line count [count] XXX XXX XXX [ XXX ] XXX XXX XXX [ XXX ] <----------x--------> <-pad-> <-pad-> *) type t = { kind: kind; indent: int; (* expression starting column *) column: int; (* starting column of the token*) pad: int; (* padding: how much children should be indented from current line *) line_indent: int; (* starting column of the current line *) line: int; (* starting line of the expression *) } let to_string i t = Printf.sprintf "%s%s %d|%d-%d-%d(%d)" (String.make i ' ') (string_of_kind t.kind) t.line t.line_indent t.indent t.column t.pad let default = { kind = KUnknown; indent = 0; column = 0; pad = 0; line = 0; line_indent = 0; } let shift node n = let n = max n (- node.indent) in { node with indent = node.indent + n; column = node.column + n } end module Path = struct open Node type t = Node.t list let to_string t = String.concat " \027[35m/\027[m " (List.map (fun n -> Node.to_string 0 n) (List.rev t)) let top = function | [] -> Node.default | t :: _ -> t let indent = function | [] -> 0 | t :: _ -> t.indent let pad = function | [] -> 0 | t :: _ -> t.pad let maptop f = function | [] | {kind=KCodeInComment}::_ as l -> l | t::l -> f t :: l let shift path n = maptop (fun t -> Node.shift t n) path end open Node (* A block is: - a node path to go to this block - the last token of this block (when a comment, it is stacked to keep the last meaningful token) - the last token offset - the original starting column for this block *) type t = { path: Path.t; last: Nstream.token list; toff: int; orig: int; } let shift t n = { t with path = Path.shift t.path n } let to_string t = Path.to_string t.path (* Printf.sprintf "%s\n%d %b" (Path.to_string t.path) t.toff *) let empty = { path = []; last = []; toff = 0; orig = 0; } (* (* Does the token close a top LET construct ? *) (* NB: we do this with another way below, but this one might be more robust *) let rec close_top_let = function | None -> true | Some t -> match t.token with | COMMENT _ -> assert false (* COMMENT must be skipped *) (* Tokens that allow a let-in after them *) | AMPERSAND | AMPERAMPER | BARBAR | BEGIN | COLONCOLON | COLONEQUAL | COMMA | DO | DOWNTO | ELSE | EQUAL | GREATER | IF | IN | INFIXOP0 _ | INFIXOP1 _ | INFIXOP2 _ | INFIXOP3 _ | INFIXOP4 _ | LBRACE | LBRACELESS | LBRACKET | LBRACKETBAR | LBRACKETLESS | LBRACKETGREATER | LESS | LESSMINUS | LPAREN | MATCH | MINUS | MINUSDOT | MINUSGREATER | OR | PLUS | PLUSDOT | QUESTION | QUESTIONQUESTION | SEMI | STAR | THEN | TO | TRY | WHEN | WHILE | TILDE -> false | _ -> true *) (* Go back to the node path path until [f] holds *) let rec unwind f path = match path with | { kind } :: _ when f kind -> path | { kind=KCodeInComment } :: _ -> path | { kind = KAttrId _ } :: { kind } :: _ when f kind -> path (* never remove the KattrId following a KExtendedItem *) | _ :: path -> unwind f path | [] -> [] (* Unwinds the path while [f] holds, returning the last step for which it does *) let unwind_while f path = let rec aux acc = function | { kind=KCodeInComment } :: _ as p -> acc :: p | { kind } as h :: p when f kind -> aux h p | p -> acc :: p in match path with | { kind=KCodeInComment } :: _ -> None | { kind } as h :: p when f kind -> Some (aux h p) | _ -> None let top_kind = function | KStruct|KSig|KParen|KBegin|KObject|KExtendedItem _ -> true | _ -> false let stritem_kind = function | KModule|KVal|KLet|KExternal|KType|KException|KOpen|KInclude -> true | _ -> false (* Unwind the struct/sig top *) let unwind_top = unwind top_kind (* Get the parent node *) let parent = function | [] | {kind=KCodeInComment}::_ as t -> t | _ :: t -> t (* Get the next token, skipping comments (and in-comment tokens) *) let next_token_full = let rec skip depth stream = match Nstream.next stream with | None -> None | Some (tok,stream) -> match tok.token with | COMMENT -> skip depth stream | OCAMLDOC_VERB | OCAMLDOC_CODE -> skip (depth + 1) stream | COMMENTCONT -> if depth = 0 then None else skip (depth-1) stream | _ when depth = 0 -> Some (tok,stream) | _ -> skip depth stream in skip 0 let next_token stream = match next_token_full stream with | None -> None | Some (t,_) -> Some t.token let last_token t = let rec aux = function | [] -> None | {token = COMMENT | COMMENTCONT} :: r -> aux r | t :: _ -> Some t.token in aux t.last (* a more efficient way to do this would be to store a "context-type" in the stack *) let rec is_inside_type path = match unwind (function | KParen | KBegin | KBracket | KBrace | KBracketBar | KVal | KLet | KLetIn | KBody (KVal | KLet | KLetIn) | KBody(KType|KExternal) | KColon | KStruct | KSig | KObject -> true | _ -> false) path with | {kind=KBody(KVal|KType|KExternal) | KColon}::_ -> true | {kind=KParen | KBegin | KBracket | KBrace}::p -> is_inside_type p | _ -> false (* Returns None if the current token ends a line, the offset of the next token otherwise *) let next_offset tok stream = match next_token_full stream with | None -> None | Some (next,_) -> if Region.end_line tok.region < Region.start_line next.region then None else Some next.offset let reset_padding ?(pad=0) path = Path.maptop (fun n -> {n with pad}) path let reset_line_indent config current_line path = let limit_overindent = match config.IndentConfig.i_max_indent with | Some m -> let m = max 0 (m - config.IndentConfig.i_base) in fun i -> min i m | None -> fun i -> i in let rec aux acc = function | {line} as t :: r when line = current_line -> aux (t::acc) r | p -> let p, acc, extra = match acc with | {kind = KParen|KBracket|KBrace|KBracketBar} as acc1 :: acc when acc1.line_indent = acc1.column -> (* ignore those if at start of line *) acc1 :: p, acc, acc1.pad | _ -> p, acc, 0 in List.fold_left (fun p t -> {t with indent = t.line_indent + limit_overindent (t.indent - t.line_indent) + extra} ::p) p acc in aux [] path let dump t = Printf.eprintf "\027[35m# \027[32m%8s\027[m %s\n%!" (match t.last with tok::_ -> shorten_string 30 (Lazy.force tok.substr) | _ -> "") (to_string t) (* different kinds of position: [T]: token aligned: the child is aligned with the token position [L]: line aligned: the child is aligned with the begining of line [A]: absolute position *) type pos = L | T | A of int (* position *) (* indent configuration of the infix operators *) let op_prio_align_indent config = let open IndentConfig in let align, indent = match config.i_align_ops with | true -> T, 0 | false -> L, config.i_base in let is_monadop s = match String.sub s 0 (min 2 (String.length s)) with | ">>" | ">|" | "@@" | "@>" -> true | _ -> false in let is_monadop s = is_monadop s (* "*>>=", "+>>>", "/>>|", etc. *) || (String.length s > 3 && is_monadop (String.sub s 1 2)) in function (* anything else : -10 *) (* in -> : 0 *) | SEMI -> prio_semi,L,-2 (* special negative indent is only honored at beginning of line *) (* then else : 10 *) | BAR -> 10,T,-2 | OF -> 20,L,2 | LESSMINUS | COLONEQUAL -> 20,L,config.i_base | COMMA -> 30,align,-2 | MINUSGREATER -> 32,L,0 (* is an operator only in types *) | COLON -> 35,T,config.i_base | COLONGREATER -> 35,L,config.i_base | OR | BARBAR -> 40,T,0 | AMPERSAND | AMPERAMPER -> 50,T,0 | (INFIXOP0 s | INFIXOP1 s | INFIXOP2 s | INFIXOP3 s | INFIXOP4 s) (* these should deindent fun -> *) when is_monadop s -> prio_flatop,L,0 | INFIXOP0 s -> (match String.sub s 0 (min 2 (String.length s)) with | "|!" | "|>" -> prio_flatop,T,0 | _ -> 60,align,indent) | EQUAL | LESS | GREATER -> 60,align,0 | INFIXOP1 _ -> 70,align,indent | COLONCOLON -> 80,align,indent | INFIXOP2 _ | PLUSDOT | PLUS | MINUSDOT | MINUS -> 90,align,indent | INFIXOP3 _ | STAR -> 100,align,indent | INFIXOP4 _ -> 110,align,indent (* apply: 140 *) | AS -> prio_apply,L,0 | TILDE | QUESTION -> prio_apply,L,config.i_base | LABEL _ | OPTLABEL _ -> if config.i_align_params = Always then 145,T,config.i_base else 145,L,config.i_base | SHARP -> 150,align,config.i_base | DOT -> prio_dot,align,config.i_base | _ -> assert false let handle_dotted block tok = let starts_line = tok.newlines > 0 in let current_line = Region.start_line tok.region in let is_attr_id = function | { kind = KAttrId (_, dotted) } :: _ -> not dotted | _ -> false in let make_dotted_attr_id = function | { kind = KAttrId (names, _) } as node :: ({ kind = (KExtendedItem [] | KExtendedExpr [])} :: _ as path) -> { node with kind = KAttrId (names, true) } :: path | _ -> assert false in let is_dotted_attr_id = function | { kind = KExtendedExpr [] } :: _ -> true | { kind = KExtendedItem [] } :: _ -> true | { kind = KAttrId (_, dotted) } :: _ -> dotted | _ -> false in let make_attr_id name = function | ({ kind = (KExtendedItem [] | KExtendedExpr []); indent; pad; } :: _ as path) -> let indent = if starts_line then indent + pad else indent + pad + String.length (Lazy.force tok.between) - 1 in let column = if starts_line then indent else block.toff + tok.offset in { kind = (KAttrId ([name], false)); indent; line_indent = indent; column; line = current_line; pad = 0 } :: path | ({ kind = KAttrId (names, _)} as node) :: path -> { node with kind = KAttrId (name :: names, false); } :: path | _ -> assert false in if is_dotted_attr_id block.path then match tok.token with | LIDENT s | UIDENT s -> Some (make_attr_id s block.path) | AND | AS | ASSERT | BEGIN | CLASS | CONSTRAINT | DO | DONE | DOWNTO | ELSE | END | EXCEPTION | EXTERNAL | FALSE | FOR | FUN | FUNCTION | FUNCTOR | IF | IN | INCLUDE | INHERIT | INITIALIZER | LAZY | LET | MATCH | METHOD | MODULE | MUTABLE | NEW | OBJECT | OF | OPEN | OR | PRIVATE | REC | SIG | STRUCT | THEN | TO | TRUE | TRY | TYPE | VAL | VIRTUAL | WHEN | WHILE | WITH -> Some (make_attr_id (Lazy.force tok.substr) block.path) | _ -> None else if is_attr_id block.path then match tok.token with | DOT -> Some (make_dotted_attr_id block.path) | _ -> None else None (* Take a block, a token stream and a token. Return the new block stack. *) let rec update_path config block stream tok = let open IndentConfig in let starts_line = tok.newlines > 0 in let current_line = Region.start_line tok.region in let node replace kind pos pad path = let parent = Path.top path in if starts_line then let indent = match pos with | A p -> p | L -> parent.indent + if replace then 0 else parent.pad | T -> parent.column + if replace then 0 else parent.pad in { kind; indent; line_indent=indent; column=indent; pad; line = current_line } else let column = block.toff + tok.offset in { kind; indent = parent.indent; line_indent=parent.line_indent; column; pad; line = current_line } in (* Add a new child block *) let append kind pos ?(pad=config.i_base) = function | {kind = KAttrId (names, _)} :: ({kind = KExtendedItem [] | KExtendedExpr [] } as n) :: path -> let n = { n with kind = match n.kind with | KExtendedItem [] -> KExtendedItem (List.rev names) | KExtendedExpr [] -> KExtendedExpr (List.rev names) | _ -> assert false } in let path = {n with pad = config.i_ppx_stritem_ext } :: path in node false kind pos pad path :: path | path -> node false kind pos pad path :: path in (* replace the current block with a new one *) let replace kind pos ?(pad=config.i_base) path = match path with | [] | {kind=KCodeInComment} :: _ -> node true kind pos pad path :: path | _::t -> node true kind pos pad path :: t in (* Used when expressions are merged together (for example in "3 +" the "+" extends the lower-priority expression "3") *) let extend kind pos ?(pad=config.i_base) = function | [] | {kind=KCodeInComment} :: _ as path -> node true kind pos pad path :: path | h::p -> let negative_indent () = (* Special negative indent: relative, only at beginning of line, and when prio is changed or there is a paren to back-align to *) if pad >= 0 || not starts_line then None else match p with | {kind=KParen|KBracket|KBracketBar |KBrace|KBar _|KWith KBrace|KBody _} as paren :: _ when paren.line = h.line -> let paren_len = match paren.kind with | KParen | KBracket | KBrace | KBar _ | KBody _ -> 1 | KBracketBar -> 2 | KWith KBrace -> 4 | _ -> assert false in let indent = paren.column + paren_len + 1 (* usually 1 space *) + pad in Some ({ h with kind; indent; column=indent; line_indent = indent-pad; pad = max h.pad (h.indent-indent)} :: p) | _ -> match kind,h.kind with | KExpr pk, KExpr ph when ph = pk -> (* respect the indent of the above same-priority term, we assume it was already back-indented *) Some ({ h with kind; indent=h.column; column=h.column; line_indent = h.column; pad = h.pad } :: p) | _ -> let indent = h.column + pad in if indent < 0 then None else Some ({ h with kind; indent; column=indent; line_indent = indent; pad = -pad } :: p) in match negative_indent () with | Some p -> p | None -> (* normal case *) (* change indent to set the starting column of the expression *) let pad = max 0 pad in let indent,pad = if pos = T then h.column, pad else (* set indent of the whole expr accoring to its parent *) Path.indent p + Path.pad p, pad in let line_indent = if starts_line then indent else h.line_indent in { h with kind; indent; line_indent; pad } :: p in (* use before appending a new expr_atom: checks if that may cause an apply and folds parent exprs accordingly *) let fold_expr path = match path with | {kind=KExpr _} as e :: ({kind=KFun} as fn) :: p -> {fn with line_indent = e.line_indent} :: p | {kind=KExpr i} as e :: _ when i = prio_max -> (* we are appending two expr_atom next to each other: this is an apply. *) (* this "folds" the left-side of the apply *) let p = match unwind_while (fun kind -> prio kind >= prio_apply) path with | Some({kind=KExpr i} as e1 :: p) when i = prio_apply -> {e1 with line_indent = e.line_indent} :: p | Some({kind=KExpr _; line} :: {kind=KModule|KInclude|KOpen|KBody KModule} :: _ as p) -> (* ignore align_params for functor application *) extend (KExpr prio_apply) L (reset_line_indent config line p) | Some({kind=KExpr _; line} :: {kind=KArrow (KMatch|KTry) | KTry | KMatch; line=arrow_line}::_ as p) when config.i_align_params = Auto && line = arrow_line -> (* Special case: switch to token-aligned (see test js-args) *) extend (KExpr prio_apply) T p | Some p -> extend (KExpr prio_apply) (if config.i_align_params = Always then T else L) p | None -> assert false in p | _ -> path in let before_append_atom = function | {kind=KWith(KTry|KMatch as m)}::parent as path -> (* Special case: 'match with' and no bar for the 1st case: we append a virtual bar for alignment *) let path = match parent with | {kind = KExpr i} :: _ when i = prio_flatop -> reset_padding path | _ -> path in let p = append (KBar m) L ~pad:2 path in if not starts_line then let column = max 0 (block.toff + tok.offset - 2) in Path.maptop (fun h -> {h with column}) p else p | path -> fold_expr path in let atom path = let path = before_append_atom path in let pad = match path with {kind=KExpr _; pad}::_ -> pad | _ -> config.i_base in append expr_atom L ~pad path in let open_paren kind path = let path = before_append_atom path in let path = match next_offset tok stream with | None (* EOL *) -> reset_line_indent config current_line path | Some _ -> path in let p = append kind L path in let p = match p with (* Special case: paren after arrow has extra indent (see test js-begin) *) | {kind=KParen|KBegin|KBracket|KBracketBar|KBrace} :: {kind=KArrow _} :: _ when not starts_line -> Path.shift p config.i_base | p -> p in match p with | [] -> [] | h::p as path -> match kind with | KBegin -> path | KParen when if not config.i_align_ops then not starts_line else match next_token stream with | Some(SIG|STRUCT|OBJECT) -> true | _ -> false -> path | _ -> (* set alignment for next lines relative to [ *) (match next_offset tok stream with | Some pad -> let indent = if starts_line then h.indent else block.toff + tok.offset in { h with indent; column=indent; pad } :: p | None -> if starts_line then path else {h with column = h.indent + h.pad} :: p) in let close f path = (* Remove the padding for the closing brace/bracket/paren/etc. *) Path.maptop (fun h -> {h with kind=expr_atom; pad=0}) (unwind f path) in let make_infix tok path = let op_prio, align, indent = op_prio_align_indent config tok.token in let in_record = match unwind_while (fun kind -> prio kind >= op_prio) path with | Some ({ kind = KExpr _ } :: { kind = KBrace } :: _) -> true | _ -> false in (* special cases *) let indent = (* don't back-indent operators when alone on their line (except BAR because that would disrupt typing) *) if indent < 0 && tok.token <> BAR && not (tok.token = SEMI && in_record) && next_offset tok stream = None then 0 else indent in match path with | {kind=KExpr prio}::_ when prio >= op_prio && prio < prio_max -> (* we are just after another operator (should be an atom). handle as unary (eg. x + -y) : indented but no effect on following expressions *) (* append KUnknown L path *) append (KExpr prio) L ~pad:(max 0 indent) path | _ -> match unwind_while (fun kind -> prio kind >= op_prio) path with | Some p -> extend (KExpr op_prio) align ~pad:indent p | None -> (* used as prefix ? Don't apply T indent *) append (KExpr op_prio) L ~pad:(max 0 indent) path in (* KComment/KUnknown nodes correspond to comments or top-level stuff, they shouldn't be taken into account when indenting the next token *) let block0 = block in let block = match block.path with | {kind=KComment _|KVerbatim _|KUnknown}::path -> {block with path} | _ -> block in let (>>!) opt f = match opt with Some x -> x | None -> f () in handle_dotted block tok >>! fun () -> match tok.token with | SEMISEMI -> append KUnknown L ~pad:0 (unwind_top block.path) | INCLUDE -> append KInclude L (unwind_top block.path) | EXCEPTION -> let p = unwind (function KExpr _ -> false | _ -> true) block.path in (match p with | {kind=KWith KMatch|KBar KMatch}::_ -> append expr_atom L block.path | _ -> append KException L (unwind_top block.path)) | BEGIN -> open_paren KBegin block.path | OBJECT -> append KObject L block.path | VAL -> append KVal L (unwind_top block.path) | MATCH -> let p = fold_expr block.path in if starts_line then append KMatch L p else let enforce_strict = config.i_strict_with = Always || config.i_strict_with = Auto && match p with | {kind=KBegin; indent; column} :: _ -> column = indent | _ -> false in let p, pad = if enforce_strict then let p = reset_line_indent config current_line p in reset_padding p, config.i_base else p, Path.pad p + config.i_base in append KMatch L ~pad p | TRY -> let p = fold_expr block.path in if starts_line then append KTry L p else let enforce_strict = config.i_strict_with = Always || config.i_strict_with = Auto && match p with | {kind=KBegin; indent; column} :: _ -> column = indent | _ -> false in let p, pad = if enforce_strict then let p = reset_line_indent config current_line p in reset_padding p, config.i_base else p, Path.pad p + config.i_base in append KTry L ~pad p | LPAREN -> open_paren KParen block.path | LBRACKET | LBRACKETGREATER | LBRACKETLESS -> open_paren KBracket block.path | LBRACKETPERCENT | LBRACKETAT -> let path = before_append_atom block.path in append ~pad:4 (KExtendedExpr []) L path | LBRACKETATAT -> let path = (unwind (function KBody k | k -> top_kind k || stritem_kind k) block.path) in let path = match path with | {kind = KBody k | k} :: p -> if top_kind k then path else p | [] -> [] in append ~pad:4 (KExtendedItem []) L path | LBRACKETPERCENTPERCENT | LBRACKETATATAT -> append ~pad:4 (KExtendedItem []) L (unwind_top block.path) | LBRACKETBAR -> open_paren KBracketBar block.path | LBRACE | LBRACELESS -> open_paren KBrace block.path | FUNCTION -> (match fold_expr block.path with | l :: _ as p when not starts_line && l.kind <> KExpr 0 && (config.i_strict_with = Never || config.i_strict_with = Auto && l.kind <> KBegin) -> let p = reset_line_indent config current_line p in append (KWith KMatch) L ~pad:(max (max l.pad config.i_base) config.i_with) p | p -> let p = reset_line_indent config current_line p in append (KWith KMatch) L ~pad:config.i_with p) | FUN | FUNCTOR -> (match block.path with | {kind=KArrow KFun}::path -> let path = unwind (function KFun -> true | _ -> false) path in (match path with | {line; column; line_indent}::_ when line = current_line || column = line_indent -> replace KFun L path | _ -> append KFun L block.path) | p -> append KFun L (fold_expr p)) | STRUCT | SIG -> let k = match tok.token with | STRUCT -> KStruct | SIG -> KSig | _ -> assert false in let expr_start = unwind (function KParen | KLet | KLetIn | KBody _ -> true | _ -> false) block.path in let indent = match expr_start with | {kind=KParen}::{kind=KExpr prio; line; indent}::_ when prio = prio_apply && line = current_line -> indent | _ -> Path.indent block.path in Path.maptop (fun n -> {n with indent}) (append k L (reset_padding block.path)) | WHEN -> append KWhen L ~pad:(config.i_base + if starts_line then 0 else 2) (unwind (function | KWith(KTry|KMatch) | KBar(KTry|KMatch) | KFun -> true | _ -> false) block.path) | OPEN -> if last_token block = Some LET then append KOpen L block.path else append KOpen L (unwind_top block.path) | LET -> (* Two ways to detect let vs letin ; both seem to work, but need to check which one is the most robust (for example w.r.t. unfinished expressions) *) (* - it's a top Let if it is after a closed expression *) (match block.path with | {kind=KExpr i}::p when i = prio_max -> append KLet L (unwind_top p) | [] | {kind=KCodeInComment}::_ as p-> append KLet L (unwind_top p) | _ -> append KLetIn L (fold_expr block.path)) (* - or if after a specific token *) (* if close_top_let block.last then *) (* append KLet L config.i_base (unwind_top block.path) *) (* else *) (* append KLetIn L config.i_base (fold_expr block.path) *) | CLASS -> append KLet L (unwind_top block.path) | METHOD -> append KLet L (unwind_top block.path) | INITIALIZER -> append (KBody KLet) L (unwind_top block.path) | CONSTRAINT -> let path = unwind (function KType | KBody KType | KObject -> true | _ -> false) block.path in append KLet L path | AND -> let unwind_to = function | KLet | KLetIn | KType | KModule -> true | _ -> false in let path = unwind (unwind_to @* follow) block.path in (match path with | [] | {kind=KCodeInComment}::_ -> append (KAnd KUnknown) L path | {kind=KType|KModule|KBody (KType|KModule)} :: ({kind=KWith _} as m) :: p -> (* hack to align "and" with the 'i' of "with": consider "with" was 1 column further to the right *) let m = if starts_line then {m with column = m.column+1} else m in replace (KAnd m.kind) T ~pad:0 (m :: p) | {kind=KType|KModule|KBody (KType|KModule)} :: ({kind=KAnd (KWith _)} as m) :: p -> replace m.kind T ~pad:0 (m :: p) | h::_ -> append (KAnd (follow h.kind)) L (parent path)) | IN -> let path = unwind ((function KLetIn | KLet -> true | _ -> false) @* follow) block.path in let pad = match next_token stream with | Some LET -> 0 | _ -> config.i_in in (match unwind_while ((=) KIn) (parent path) with | Some p -> extend KIn L ~pad p | None -> extend KIn L ~pad path) | TYPE -> (match last_token block with | Some (MODULE | CLASS) -> append KUnknown L block.path (* module type *) | Some (WITH|AND) | Some COLON (* 'type' inside type decl, for GADTs *) -> append KType L block.path | _ -> append KType L (unwind_top block.path)) | MODULE -> (match last_token block with | Some LET -> append KUnknown L block.path (* let module *) | Some COLON | Some EQUAL when next_token stream = Some TYPE -> append KUnknown L block.path (* : module type of *) | Some (WITH|AND) -> append KType L block.path | _ -> append KModule L (unwind_top block.path)) | END -> close (function KStruct|KSig|KBegin|KObject -> true | _ -> false) block.path | WITH -> (match next_token_full stream with | Some ({token = TYPE|MODULE as tm}, _) -> let path = unwind (function | KModule | KOpen | KInclude | KParen | KBegin | KColon | KBody KModule -> true | _ -> false) block.path in let kind = match tm with TYPE -> KType | MODULE -> KModule | _ -> assert false in append (KWith kind) L path | next -> let path = unwind (function |KTry|KMatch |KVal|KType|KBody KType|KException (* type-conv *) |KColon |KBrace -> true |KWith KTry -> (* useful for lwt's try-finally *) Lazy.force tok.substr = "finally" | _ -> false ) block.path in match path with | {kind=KBrace; pad} :: _ -> (match next with | Some (next, _) when Region.start_line next.region = Region.end_line tok.region -> Path.maptop (fun n -> {n with indent=n.column}) (append (KWith KBrace) L ~pad:next.offset path) | _ -> append (KWith KBrace) L ~pad:(pad + config.i_with) path) | {kind=KVal|KType|KException as kind}::_ -> replace (KWith kind) L path | {kind=KTry|KMatch as kind} as n :: parent :: _ when n.line = current_line && n.column <> n.line_indent && config.i_strict_with <> Always -> let path,pad = if parent.line_indent = parent.column then path, max parent.pad config.i_with else reset_line_indent config n.line path, max config.i_with (if parent.pad > 0 then config.i_base else 0) in replace (KWith kind) L ~pad path | {kind=(KTry|KMatch as kind)}::p -> if starts_line then append (KWith kind) L ~pad:config.i_with p else replace (KWith kind) L ~pad:config.i_with (reset_line_indent config current_line path) | {kind=KColon}::_ as p -> (* may happen with sexp extension, 'with default' *) append expr_atom L p | _ -> path) | IF -> (match last_token block with | Some ELSE -> replace KIf L block.path | _ -> append KIf L (fold_expr block.path)) | THEN -> extend KThen L (unwind ((=) KIf) block.path) | ELSE -> let pad = match config.i_strict_else with | Always -> config.i_base | Never -> if next_offset tok stream <> None then config.i_base else 0 | Auto -> if next_offset tok stream <> None then config.i_base else match next_token stream with | Some (LET|MATCH|TRY|FUN|FUNCTION) -> 0 | _ -> config.i_base in extend KElse L ~pad (unwind ((=) KThen) block.path) | WHILE | FOR -> append KLoop L (fold_expr block.path) | TO | DOWNTO -> let p = Path.maptop (fun n -> { n with indent = n.indent + config.i_base }) (unwind ((=) KLoop) block.path) in replace KLoop L p | DO -> extend KDo L (unwind ((=) KLoop) block.path) | DONE -> close ((=) KDo) block.path | BARRBRACKET -> close ((=) KBracketBar) block.path | RPAREN -> close ((=) KParen) block.path | RBRACE | GREATERRBRACE -> close ((=) KBrace) block.path | RBRACKET -> close (function | KBracket | KExtendedItem _ | KExtendedExpr _ -> true | _ -> false) block.path | GREATERRBRACKET -> close ((=) KBracket) block.path | BAR -> let path = unwind (function | KParen | KBegin | KBracket | KBrace | KBracketBar | KWith(KMatch|KTry) | KBar(KMatch|KTry) | KArrow(KMatch|KTry) | KLet | KLetIn | KBody(KType) -> true | _ -> false) block.path in (match path with | {kind=KWith m} :: {kind=KExpr i} :: _ when i = prio_flatop -> append (KBar m) L (reset_padding path) | {kind=KWith m} :: _ -> append (KBar m) L path | {kind=KArrow (KMatch|KTry as m)} :: ({kind=KBar _} as h:: _ as p) -> Path.maptop (fun x -> {x with column = h.column}) (replace (KBar m) (A h.column) p) | {kind=KArrow m} :: p -> append (KBar m) L p | _ -> match block.path with | {kind = KExpr _}::_ -> make_infix tok block.path | _ -> append (KBar KType) L block.path) | MINUSGREATER -> let rec find_parent path = let path = unwind (function | KParen | KBegin | KBracket | KBrace | KBracketBar | KWith(KMatch|KTry) | KBar(KMatch|KTry) | KArrow(KMatch|KTry) | KFun | KBody(KType|KExternal) | KColon | KStruct | KSig | KObject -> true | _ -> false) path in match path with | {kind=KFun} :: ({kind=KExpr i} as e) :: path when i = prio_flatop -> (* eg '>>= fun x ->': indent like the top of the expression *) {e with kind = KExpr 0} :: path | {kind=KFun; line } :: _ when next_offset tok stream = None && line = current_line -> (* Special case: [fun ->] at eol, this should be strictly indented wrt the above line, independently of the structure *) append (KArrow KFun) L (reset_line_indent config line path) | {kind=KFun} :: _ -> append (KArrow KFun) L path | {kind=KBar m}::{kind=KWith _; line}::_ when line = current_line -> (* Special case: don't respect match_clause when 'with X ->' is on a single line *) let pad = if next_offset tok stream <> None then config.i_base else match next_token stream with | Some (MATCH|TRY|FUN|FUNCTION) -> 0 | _ -> config.i_base in append (KArrow m) L ~pad (reset_line_indent config line path) | {kind=KWith m | KBar m} :: _ -> let pad = config.i_match_clause - if starts_line then config.i_base else 0 in append (KArrow m) L ~pad path | {kind=KArrow(KMatch|KTry)} :: p -> (* might happen if doing 'when match' for example *) (match unwind (function | KParen | KBegin | KBracket | KBrace | KBracketBar | KWith(KMatch|KTry) | KFun | KBody(KType|KExternal) | KColon | KStruct | KSig | KObject -> true | _ -> false) p with | {kind=KWith(_)}::p -> find_parent p | _ -> make_infix tok block.path) | _ -> make_infix tok block.path in find_parent block.path | EQUAL -> let unwind_to = function | KParen | KBegin | KBrace | KBracket | KBracketBar | KBody _ | KExternal | KModule | KType | KLet | KLetIn | KException | KVal | KBar KType | KStruct | KSig | KObject | KAnd(KModule|KType|KLet|KLetIn) -> true | _ -> false in let rec find_parent path = let path = unwind unwind_to path in (match path with | [] | {kind=KCodeInComment}::_ -> make_infix tok block.path | {kind=KBody KType}::p -> (* type t = t' = ... *) (match p with | {kind = KWith (KType|KModule) | KAnd KWith (KType|KModule)}::_ -> find_parent p | _ -> replace (KBody KType) L ~pad:config.i_type path) | {kind=KBrace}::_ -> (match unwind_while (fun kind -> prio kind > prio_semi) block.path with | Some ({kind=KExpr prio}::_) when prio = prio_semi + 1 -> (* already after a field binding: this '=' must be the normal operator *) make_infix tok block.path | Some p -> extend (KExpr (prio_semi+1)) T ~pad:config.i_base p | None -> make_infix tok block.path) | {kind=KParen|KBegin|KBracket|KBracketBar|KBody _|KBar KType}::_ -> make_infix tok block.path | {kind=KAnd kind | kind} as h::p -> let indent = match next_token stream, kind with | Some (STRUCT|SIG), _ -> 0 | _, (KType | KBody KType) -> config.i_type | _ -> config.i_base in if starts_line then let h = {h with indent = h.indent + indent; pad = 0} in replace (KBody kind) L ~pad:0 (h :: p) else let h = {h with indent = h.column} in replace (KBody kind) T ~pad:indent (h :: p)) in find_parent block.path | COLONEQUAL | INFIXOP2 "+=" -> (match unwind_while (function KExpr _ | KType -> true | _ -> false) block.path with | Some ({kind=KType}::_ as p) -> (* type t := t' *) replace (KBody KType) L p | _ -> make_infix tok block.path) | COLON -> let path = unwind (function | KParen | KBegin | KBrace | KBracket | KBracketBar | KBody _ | KModule | KLet | KLetIn | KExternal | KVal | KAnd(KModule|KLet|KLetIn) -> true | _ -> false) block.path in (match path with | {kind = KModule|KLet|KLetIn|KExternal | KAnd(KModule|KLet|KLetIn|KExternal)} :: _ -> append KColon L path | {kind=KVal} :: {kind=KObject} :: _ -> make_infix tok path | {kind=KVal} as h :: p -> let indent = config.i_base in if starts_line then let h = {h with indent = h.indent + indent; pad = 0} in replace (KBody h.kind) L ~pad:0 (h :: p) else replace (KBody h.kind) L ~pad:indent (h :: p) | {kind=KBrace}::_ -> (* record type *) (match block.path with | {kind=KExpr i}::{kind=KBrace}::_ as p when i = prio_max -> extend KColon L p | {kind=KExpr i}::({kind=KExpr j}::{kind=KBrace}::_ as p) when i = prio_max && j = prio_apply -> (* "mutable" *) extend KColon L p | _ -> make_infix tok block.path) | _ -> make_infix tok block.path) | SEMI -> (match unwind (fun kind -> prio kind < prio_semi) block.path with | {kind=KColon}::({kind=KBrace}::_ as p) -> p | _ -> make_infix tok block.path) (* Some commom preprocessor directives *) | UIDENT ("INCLUDE"|"IFDEF"|"THEN"|"ELSE"|"ENDIF" |"TEST"|"TEST_UNIT"|"TEST_MODULE" |"BENCH"|"BENCH_FUN"|"BENCH_MODULE"|"BENCH_INDEXED" as s) when starts_line -> if String.sub s 0 4 = "TEST" || (String.length s > 4 && String.sub s 0 5 = "BENCH") then append KLet L ~pad:(2 * config.i_base) (unwind_top block.path) else replace KUnknown L (unwind_top block.path) | EXTERNAL -> append KExternal L (unwind_top block.path) | DOT -> let last_expr = unwind_while (function KExpr _ -> true | _ -> false) block.path in (match last_expr with | Some ({kind=KExpr _} :: {kind=KType} :: ({kind=KColon} :: _ as p)) -> (* let f: type t. t -> t = ... *) p | Some ({kind=KExpr i} :: ({kind=KBrace|KWith KBrace} as h :: p)) when (i = prio_max || i = prio_dot) && next_offset tok stream = None -> (* special case: distributive { Module. field; field } *) { h with pad = config.i_base } :: p | _ -> make_infix tok block.path) | AMPERAMPER | BARBAR -> (* back-indented when after if or when and not alone *) let op_prio, _align, _indent = op_prio_align_indent config tok.token in (match unwind_while (fun kind -> prio kind >= op_prio) block.path with | Some ({kind=KExpr _; line}::{kind=KWhen|KIf; line=line_if}::_ as p) when line = line_if && next_offset tok stream <> None -> extend (KExpr op_prio) T ~pad:(-3) p | _ -> make_infix tok block.path) | LESS -> if is_inside_type block.path then (* object type *) open_paren KBrace block.path else make_infix tok block.path | GREATER -> if is_inside_type block.path then match unwind (function | KParen | KBegin | KBracket | KBrace | KBracketBar | KBody(KType|KExternal) -> true | _ -> false) block.path with | {kind=KBrace}::_ as p -> close (fun _ -> true) p | _ -> append expr_apply L (fold_expr block.path) else make_infix tok block.path | LESSMINUS | COMMA | OR | AMPERSAND | INFIXOP0 _ | INFIXOP1 _ | COLONCOLON | INFIXOP2 _ | PLUSDOT | PLUS | MINUSDOT | MINUS | INFIXOP3 _ | STAR | INFIXOP4 _ | SHARP | AS | COLONGREATER | OF -> make_infix tok block.path | LABEL _ | OPTLABEL _ -> (match unwind_while (function | KExpr _ | KLet | KLetIn | KFun | KAnd(KLet|KLetIn) -> true | _ -> false) block.path with | Some ({kind=KExpr _}::_) | None -> (* considered as infix, but forcing function application *) make_infix tok (fold_expr block.path) | _ -> (* in function definition *) atom block.path) | UIDENT _ -> (match block.path with | {kind=KBody KType}::_ when starts_line && next_token stream <> Some DOT -> (* type =\nA\n| B : append a virtual bar before A for alignment *) let path = append (KBar KType) L ~pad:2 block.path in atom path | {kind=KBracket} as br::({kind=KBody KType; line}::_ as p) when starts_line -> (* type = [\n`A\n| `B ]: append a virtual bar before `A *) let path = if br.line > line then {br with pad = 0} :: p else block.path in let path = append (KBar KType) L ~pad:2 path in atom path | {kind=KModule | KInclude | KOpen}::_ when not starts_line -> (* indent functor parameters as if indent was flushed (like after a newline) *) Path.maptop (fun n -> let indent = n.indent + n.pad in {n with indent; line_indent = indent; pad = config.i_base} ) (atom block.path) | _ -> atom block.path) | INT64 _ | INT32 _ | INT _ | LIDENT _ | FLOAT _ | CHAR _ | STRING _ | TRUE | FALSE | NATIVEINT _ | UNDERSCORE | TILDE | QUESTION | QUOTE | QUOTATION -> atom block.path | PREFIXOP _ | BANG | QUESTIONQUESTION -> (* FIXME: should be highest priority, > atom ( append is not right for atoms ) *) atom block.path | ASSERT | LAZY | NEW | MUTABLE -> append expr_apply L (before_append_atom block.path) | INHERIT -> append (KExpr 0) L (unwind_top block.path) | OCAMLDOC_CODE -> let indent = Path.indent block0.path + Path.pad block0.path in { kind = KCodeInComment; line = Region.start_line tok.region; indent = indent; line_indent = indent; column = indent; pad = config.i_base } :: block0.path | OCAMLDOC_VERB -> (match block0.path with | {kind=KComment (tok,toff);indent;pad}::_ -> { kind = KVerbatim (tok,toff); line = Region.start_line tok.region; indent = indent + pad; line_indent = indent + pad; column = indent + pad; pad = 0 } :: block0.path | _ -> dump block0; assert false) | COMMENTCONT -> (match unwind (function KCodeInComment | KVerbatim _ -> true | _ -> false) block0.path with | {kind=KCodeInComment|KVerbatim _} :: p -> p | _ -> block.path) | COMMENT -> let s = Lazy.force tok.substr in let pad = let len = String.length s in let i = ref 2 in while !i < len && s.[!i] = '*' do incr i done; while !i < len && s.[!i] = ' ' do incr i done; if !i >= len || s.[!i] = '\n' || s.[!i] = '\r' then 3 else !i in if not starts_line then let col = block.toff + tok.offset in Path.maptop (fun n -> {n with indent = col}) (append (KComment (tok, col)) L ~pad block.path) else (match block.path with | {kind=KExpr i}::_ when i = prio_max -> let blocklevel () = let p = unwind_top block.path in let col = Path.indent p + Path.pad p in append (KComment (tok, col)) (A col) ~pad block.path in (* after a closed expr: look-ahead *) (match next_token_full stream with | None -> blocklevel () | Some ((* full block-closing tokens + newline *) {token = SEMISEMI | DONE | END | GREATERRBRACE | GREATERRBRACKET | RBRACE | RBRACKET | RPAREN } , _) when tok.newlines > 1 -> blocklevel () | Some ((* semi block-closing tokens *) {token = SEMISEMI | DONE | END | GREATERRBRACE | GREATERRBRACKET | RBRACE | RBRACKET | RPAREN | THEN | ELSE | IN | EQUAL } , _) when tok.newlines <= 1 -> (* indent as above *) let col = (Path.top block0.path).line_indent in append (KComment (tok, col)) (A col) ~pad block.path | next -> (* indent like next token, _unless_ we are directly after a case in a sum-type *) let align_bar = if tok.newlines > 1 || not (is_inside_type block0.path) then None else let find_bar = unwind_while (function KBar _ | KExpr _ -> true | _ -> false) block0.path in match find_bar with | Some ({kind=KBar _; column}::_) -> Some column | _ -> None in match align_bar with | Some indent -> append (KComment (tok,indent)) (A indent) ~pad block.path | None -> (* recursive call to indent like next line *) let path = match next with | Some ({token = EOF }, _) | None -> [] | Some (next,stream) -> update_path config block stream { next with newlines = tok.newlines } in let col = Path.indent path in append (KComment (tok,col)) (A col) ~pad block.path) | _ -> let col = Path.indent block.path + Path.pad block.path in append (KComment (tok,col)) (A col) ~pad block.path) |DOTDOT -> (match block.path with | {kind = KBody KType} :: p -> p | _ -> append KUnknown L block.path) |VIRTUAL |REC |PRIVATE|EOF |BACKQUOTE|ILLEGAL_CHAR _ -> (* indent the token, but otherwise ignored *) append KUnknown L block.path | LINE_DIRECTIVE -> append KUnknown (A 0) ~pad:0 block.path | EOL | SPACES -> assert false let update config block stream tok = let path = update_path config block stream tok in let last = match tok.token with | COMMENT | COMMENTCONT | OCAMLDOC_VERB | EOF -> tok :: block.last | _ -> [tok] in let toff = if tok.newlines > 0 then Path.indent path else block.toff + tok.offset in let orig = Region.start_column tok.region in { path; last; toff; orig } let indent t = Path.indent t.path let original_column t = match t.path with | {kind=KComment (tok,_)|KVerbatim (tok,_)} :: _ -> Region.start_column tok.region | _ -> t.orig let offset t = match t.path with | {kind=KComment (_,toff)|KVerbatim(_,toff)} :: _ -> toff | _ -> t.toff let padding t = Path.pad t.path let set_column t col = { t with path = Path.maptop (fun n -> {n with indent = col}) t.path; toff = col } let reverse t = let col = t.orig in let expected = t.toff in if col = expected then t else match t.last with | {token=COMMENTCONT}::_ -> (* don't adapt indent on the ']}' because there is a hack with its padding *) t | tok :: _ when tok.newlines > 0 -> let diff = col - expected in let path = match t.path with | n::[] -> { n with indent = col; column = col } :: [] | ({kind=KComment (tok,_)} as n)::r -> { n with kind=KComment (tok,col); indent = col; column = col } :: r | ({kind=KVerbatim (tok,_)} as n)::r -> { n with kind=KVerbatim (tok,col); indent = col; column = col } :: r | n1::n2::p -> { n1 with indent = col; column = col } :: { n2 with pad = n2.pad + diff } :: p | [] -> [] in { t with path; toff = col } | _ -> { t with toff = col } let guess_indent line t = let path = unwind (function KUnknown | KComment _ | KVerbatim _ -> false | _ -> true) t.path in match path, t.last with | _, ({token = COMMENT | COMMENTCONT} as tok :: _) when line <= Region.end_line tok.region -> (* Inside comment *) Path.indent t.path + Path.pad t.path | {kind=KExpr i}::p, ({token=EOF} :: tok :: _ | tok::_) when i = prio_max && line > Region.end_line tok.region + 1 -> (* closed expr and newline: we probably want a toplevel block *) let p = unwind_top p in Path.indent p + Path.pad p | path, _ -> (* we probably want to write a child of the current node *) let path = match unwind_while (function KExpr p -> p >= prio_apply | _ -> false) path with Some p -> p | None -> path in match path with | {indent;pad}::_ -> indent + pad | [] -> 0 let is_clean t = List.for_all (fun node -> match node.kind with | KCodeInComment -> false | KVerbatim _ -> false | KComment _ -> false (* we need the next token to decide, because that may be "(* *)" but also "(* {[". In the last case, it will be followed by OCAMLDOC_* or COMMENTCONT, and until then the lexer stores a state *) (* **tuareg hack** "*)" (who says we want ocp-indent to handle coloration too ?) *) | _ -> true) t.path let is_at_top t = match t.path with | [] -> true | [{kind}] -> stritem_kind kind | _ -> false let is_declaration t = is_clean t && match t.path with | [] -> true | {kind=KStruct|KSig|KBegin|KObject} :: _ -> true | _ -> false let is_in_comment t = match t.path with | {kind = KComment _ | KVerbatim _}::_ -> true | p -> List.exists (fun n -> n.kind = KCodeInComment) p (* (* for syntax highlighting: returns kind of construct at point *) type construct_kind = | CK_paren (* parens and begin/end *) | CK_block (* struct/end sig/end etc. *) | CK_toplevel let construct_kind t token = *) ocp-indent-1.5.3/src/indentBlock.mli000066400000000000000000000061251273277264100173250ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012,2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) (** Indenter block *) type t (** Shift a block by a given offset *) val shift: t -> int -> t (** Set the start column of the given block to [column] *) val set_column: t -> int -> t (** [reverse block] updates the stack to account for the original indentation, assumed as correct. Useful for partial indentation *) val reverse: t -> t (** Return the current line offset *) val offset: t -> int (** Return the padding of the block, ie expected relative indentation of sub-blocks *) val padding: t -> int (** Return the block indentation *) val indent: t -> int (** Return the block original starting column *) val original_column: t -> int (** The empty block *) val empty: t (** [update t str tok] computes the new block state after processing the token [tok] in block [t]. The next tokens can be observed in the stream [str]. *) val update : IndentConfig.t -> t -> Nstream.t -> Nstream.token -> t (** Display token and stack of the block *) val dump: t -> unit (** [guess_indent line block] For indenting empty lines: attempt to guess what the most probable indent at this point would be *) val guess_indent: int -> t -> int (** A block is considered clean when it is not linked to any parser state (ie it's not within a comment, string, or ocamldoc stuff). This is not enough for a safe checkpoint: lots of rules depend on the previous/next token to decide indentation. *) val is_clean: t -> bool (** True only when the block is at the root of the file (the stack is empty, the block isn't included in any syntactical construct). Implies is_clean *) val is_at_top: t -> bool (** Returns true if the given block is at a top-level declaration level, ie not within any expression or type definition, but possibly inside a module, signature or class definition. Implies is_clean. Should be safe for checkpoints *) val is_declaration: t -> bool (** Either we are at a comment, or within an ocamldoc block *) val is_in_comment: t -> bool ocp-indent-1.5.3/src/indentConfig.ml000066400000000000000000000360001273277264100173220ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) open Compat type threechoices = Always | Never | Auto type t = { i_base: int; i_type: int; i_in: int; i_with: int; i_match_clause: int; i_ppx_stritem_ext: int; i_max_indent: int option; i_strict_with: threechoices; i_strict_else: threechoices; i_strict_comments: bool; i_align_ops: bool; i_align_params: threechoices; } let default = { i_base = 2; i_type = 2; i_in = 0; i_with = 0; i_match_clause = 2; i_ppx_stritem_ext = 2; i_max_indent = Some 4; i_strict_with = Never; i_strict_else = Always; i_strict_comments = false; i_align_ops = true; i_align_params = Auto; } let presets = [ "apprentice", { i_base = 2; i_type = 4; i_in = 2; i_with = 2; i_match_clause = 4; i_ppx_stritem_ext = 2; i_max_indent = None; i_strict_with = Never; i_strict_else = Always; i_strict_comments = false; i_align_ops = true; i_align_params = Always }; "normal", default; "JaneStreet", { i_base = 2; i_type = 2; i_in = 0; i_with = 0; i_match_clause = 2; i_ppx_stritem_ext = 2; i_max_indent = Some 2; i_strict_with = Auto; i_strict_else = Always; i_strict_comments = true; i_align_ops = true; i_align_params = Always }; ] let threechoices_of_string = function | "always" -> Always | "never" -> Never | "auto" -> Auto | _ -> failwith "threechoices_of_string" let string_of_threechoices = function | Always -> "always" | Never -> "never" | Auto -> "auto" let intoption_of_string = function | "none" | "None" -> None | n -> try Some (int_of_string n) with Failure "int_of_string" -> failwith "intoption_of_string" let string_of_intoption = function | Some n -> string_of_int n | None -> "none" let to_string ?(sep=",") indent = Printf.sprintf "base = %d%s\ type = %d%s\ in = %d%s\ with = %d%s\ match_clause = %d%s\ ppx_stritem_ext = %d%s\ max_indent = %s%s\ strict_with = %s%s\ strict_else = %s%s\ strict_comments = %b%s\ align_ops = %b%s\ align_params = %s" indent.i_base sep indent.i_type sep indent.i_in sep indent.i_with sep indent.i_match_clause sep indent.i_ppx_stritem_ext sep (string_of_intoption indent.i_max_indent) sep (string_of_threechoices indent.i_strict_with) sep (string_of_threechoices indent.i_strict_else) sep indent.i_strict_comments sep indent.i_align_ops sep (string_of_threechoices indent.i_align_params) let set ?(extra=fun _ -> None) t var_name value = try match var_name with | "base" -> {t with i_base = int_of_string value} | "type" -> {t with i_type = int_of_string value} | "in" -> {t with i_in = int_of_string value} | "with" -> {t with i_with = int_of_string value} | "match_clause" -> {t with i_match_clause = int_of_string value} | "ppx_stritem_ext" -> {t with i_ppx_stritem_ext = int_of_string value} | "max_indent" -> {t with i_max_indent = intoption_of_string value} | "strict_with" -> {t with i_strict_with = threechoices_of_string value} | "strict_else" -> {t with i_strict_else = threechoices_of_string value} | "with_never" -> (* backwards compat, don't document *) {t with i_strict_with = if bool_of_string value then Always else Never} | "strict_comments" -> {t with i_strict_comments = bool_of_string value} | "align_ops" -> {t with i_align_ops = bool_of_string value} | "align_params" -> {t with i_align_params = threechoices_of_string value} | var_name -> match extra var_name with | Some f -> f value; t | None -> let e = Printf.sprintf "unknown configuration key %S" var_name in raise (Invalid_argument e) with | Failure "int_of_string" -> let e = Printf.sprintf "%s should be an integer, not %S" var_name value in raise (Invalid_argument e) | Failure "bool_of_string" -> let e = Printf.sprintf "%s should be either \"true\" or \"false\", not %S" var_name value in raise (Invalid_argument e) | Failure "threechoices_of_string" -> let e = Printf.sprintf "%s should be either \"always\", \"never\" or \"auto\", not %S" var_name value in raise (Invalid_argument e) | Failure "intoption_of_string" -> let e = Printf.sprintf "%s should be either an integer or \"none\", not %S" var_name value in raise (Invalid_argument e) let update_from_string ?extra indent s = List.fold_left (fun indent s -> match Util.string_split '=' s with | [] | [""] -> indent | [var;value] -> set ?extra indent (String.trim var) (String.trim value) | [preset] -> (try List.assoc (String.trim preset) presets with Not_found -> let e = Printf.sprintf "unknown preset %S" preset in raise (Invalid_argument e)) | _ -> let e = Printf.sprintf "wrong \"param=value\" pair in %S" s in raise (Invalid_argument e)) indent (Util.string_split_chars ",\n" s) (* Remember to also document the template configuration file ../.ocp-indent *) let man = let option_name name kind default = Printf.sprintf "$(b,%s)=%s (default=%s)" name kind default in let pre s = List.fold_right (fun line acc -> let i = ref 0 and line = String.copy line in while !i < String.length line && line.[!i] = ' ' do line.[!i] <- '\xa0'; incr i done; `P line :: (if acc = [] then [] else `Noblank :: acc)) (Util.string_split '\n' s) [] in [ `P "A configuration definition is a list of bindings in the form \ $(i,NAME=VALUE) or of $(i,PRESET), separated by commas or newlines"; `P "Syntax: $(b,[PRESET,]VAR=VALUE[,VAR=VALUE...])" ] @ `I (option_name "base" "INT" (string_of_int default.i_base), "Indentation used when none of the following options applies.") :: pre " let foo =\n\ \ $(b,..)bar" @ `I (option_name "type" "INT" (string_of_int default.i_type), "Indentation for type definitions.") :: pre " type t =\n\ \ $(b,..)int" @ `I (option_name "in" "INT" (string_of_int default.i_in), "Indentation after `let ... in', unless followed by another `let'.") :: pre " let foo = () in\n\ \ $(b,..)bar" @ `I (option_name "with" "INT" (string_of_int default.i_with), "Indentation after `match ... with', `try ... with' or `function'.") :: pre " match foo with\n\ \ $(b,..)| _ -> bar" @ `I (option_name "match_clause" "INT" (string_of_int default.i_match_clause), "Indentation for clauses inside a pattern-match (after arrows).") :: pre " match foo with\n\ \ | _ ->\n\ \ $(b,..)bar" @ `I (option_name "ppx_stritem_ext" "INT" (string_of_int default.i_ppx_stritem_ext), "Indentation for items inside a [%%id ... ] extension node).") :: pre " [%% id.id\n\ \ $(b,..)let x = 3\ \ ]" @ `I (option_name "max_indent" "" (string_of_intoption default.i_max_indent), "When nesting expressions on the same line, their indentations are \ stacked in some cases so that they remain correct if you close them \ one per line. However, this can lead to large indentations in complex \ code, so this parameter sets a maximum indentation. Note that it \ only affects indentation after function arrows and opening parens at \ the ends of lines.") :: pre " let f = g (h (i (fun x ->\n\ \ $(b,....)x)\n\ \ )\n\ \ )" @ `I (option_name "strict_with" "" (string_of_threechoices default.i_strict_with), "If `never', match bars are indented, superseding `with', \ whenever `match with' doesn't start its line.\n\ If `auto', there are exceptions for constructs like \ `begin match with'.\n\ If `always', `with' is always strictly respected.") :: pre " Example with `strict_with=$(b,never),with=0':\n\ \ begin match foo with\n\ \ $(b,..)| _ -> bar\n\ \ end" @ `I (option_name "strict_else" "" (string_of_threechoices default.i_strict_else), "If `always', indent after the `else' keyword normally, like after \ `then'.\n\ If `auto', indent after `else' unless in a few \ \"unclosable\" cases (`let .... in', `match', etc.).\n\ If `never', the `else' keyword won't indent when followed \ by a newline.") :: pre " Example with `strict_else=$(b,auto)':\n\ \ if cond then\n\ \ foo\n\ \ else\n\ \ $(b,let) x = bar in\n\ \ baz" @ `I (option_name "strict_comments" "BOOL" (string_of_bool default.i_strict_comments), "In-comment indentation is normally preserved, as long as it respects \ the left margin or the comments starts with a newline. Setting this \ to `true' forces alignment within comments. Lines starting with `*' \ are always aligned") :: [] @ `I (option_name "align_ops" "BOOL" (string_of_bool default.i_align_ops), "Toggles preference of column-alignment over line indentation for most \ of the common operators and after mid-line opening parentheses.") :: pre " Example with `align_ops=$(b,true)':\n\ \ let f x = x\n\ \ + y\n\ \ \n\ \ Example with `align_ops=$(b,false)':\n\ \ let f x = x\n\ \ + y" @ `I (option_name "align_params" "" (string_of_threechoices default.i_align_params), "If `never', function parameters are indented one level from the \ line of the function. \ If `always', they are aligned from the column of the function. \ if `auto', alignment is chosen over indentation in a few cases, e.g. \ after match arrows") :: pre " Example with `align_params=$(b,never)':\n\ \ match foo with\n\ \ | _ -> some_fun\n\ \ $(b,..)parameter\n\ \ \n\ \ Example with `align_params=$(b,always)' or `$(b,auto)':\n\ \ match foo with\n\ \ | _ -> some_fun\n\ \ $(b,..)parameter" @ [ `P "Available presets are `normal', the default, `apprentice' which may \ make some aspects of the syntax more obvious for beginners, and \ `JaneStreet'." ] let save t file = try let oc = open_out file in output_string oc (to_string ~sep:"\n" t); output_char oc '\n'; true with Sys_error _ -> Printf.eprintf "ocp-indent warning: could not open %S for writing configuration.\n%!" file; false let syntax_ext syntax_list_ref dynlink_list_ref = function | "syntax" -> Some (fun syntaxes -> List.iter (fun syn -> (* if List.mem syn (IndentExt.available ()) then *) syntax_list_ref := syn :: !syntax_list_ref (* else *) (* let e = Printf.sprintf "unknown syntax extension %S" syn in *) (* raise (Invalid_argument e) *) ) (Util.string_split ' ' syntaxes)) | "load" -> Some (fun pkgs -> List.iter (fun s -> let dl = if Filename.check_suffix s ".cmo" || Filename.check_suffix s ".cma" || Filename.check_suffix s ".cmxs" then `Mod s else `Pkg s in dynlink_list_ref := dl :: !dynlink_list_ref) (Util.string_split ' ' pkgs)) | _ -> None let load ?(indent=default) file = try let ic = open_in file in let contents = let b = Buffer.create 512 in try while true do let s = input_line ic in let n = try String.index s '#' with Not_found -> String.length s in Buffer.add_substring b s 0 n; Buffer.add_char b '\n' done; assert false with End_of_file -> close_in ic; Buffer.contents b in let exts = ref [] in let dynlink = ref [] in let t = update_from_string ~extra:(syntax_ext exts dynlink) indent contents in t, !exts, !dynlink with | Sys_error _ -> Printf.eprintf "ocp-indent warning: could not open %S for reading configuration.\n%!" file; indent, [], [] | Invalid_argument err -> Printf.eprintf "ocp-indent warning: error in configuration file %S:\n%s\n%!" file err; default, [], [] let conf_file_name = ".ocp-indent" let rec find_conf_file path = let (/) = Filename.concat in if Sys.file_exists (path / conf_file_name) then Some (path / conf_file_name) else let path = if Filename.is_relative path then Sys.getcwd () / path else path in let parent = Filename.dirname path in if parent <> path then find_conf_file parent else None let local_default ?(path=Sys.getcwd()) () = let conf = default in let conf, syn, dlink = try let (/) = Filename.concat in let f = (Sys.getenv "HOME") / ".ocp" / "ocp-indent.conf" in if Sys.file_exists f then load ~indent:conf f else conf, [], [] with Not_found -> conf, [], [] in let conf, syn, dlink = match find_conf_file path with | Some c -> let conf, syn1, dlink1 = load ~indent:conf c in conf, syn1@syn, dlink1@dlink | None -> conf, syn, dlink in let conf = try update_from_string conf (Sys.getenv ("OCP_INDENT_CONFIG")) with | Not_found -> conf | Invalid_argument _ -> prerr_endline "Warning: invalid $OCP_INDENT_CONFIG"; conf in conf, syn, dlink ocp-indent-1.5.3/src/indentConfig.mli000066400000000000000000000063351273277264100175030ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) type threechoices = Always | Never | Auto (** See the [man] function to get the details of what the options are supposed to do (or the template .ocp-indent) *) type t = { (** indentation values *) i_base: int; i_type: int; i_in: int; i_with: int; i_match_clause: int; i_ppx_stritem_ext: int; (** indentation toggles *) i_max_indent: int option; i_strict_with: threechoices; i_strict_else: threechoices; i_strict_comments: bool; i_align_ops: bool; i_align_params: threechoices; } (** Documentation of the indentation options, in the Cmdliner 'Man.t' format *) val man: [ `S of string | `P of string | `Pre of string | `I of string * string | `Noblank ] list val default: t (** String format is ["option=value,option2=value,..."]. Commas can be replaced by newlines. Use [?extra] to handle extra options (by side-effects only) *) val update_from_string : ?extra:(string -> (string -> unit) option) -> t -> string -> t (** sep should be comma or newline if you want to reparse. Comma by default *) val to_string : ?sep:string -> t -> string (** Load from the given filename, optionally updating from the given indent instead of the default one. On error, returns the original indent config unchanged and prints a message to stderr. The file may also contain bindings of the form 'syntax=SYNTAX_EXTENSION[,...]', that are returned as a the list of their names *) val load: ?indent:t -> string -> t * string list * [`Mod of string | `Pkg of string] list (** Save the given indent config to the given filename; returns true on success *) val save: t -> string -> bool (** Looks in given and parent directories for a [.ocp-indent] configuration file *) val find_conf_file: string -> string option (** Returns the local default configuration, obtained from (in order), the built-in [default], the file [~/.ocp/ocp-indent.conf], a file [.ocp-indent] in the current directory or any parent, and the environment variable [OCP_INDENT_CONFIG]. Returns the list of syntax extensions that may have been activated in conf-files as well *) val local_default: ?path:string -> unit -> t * string list * [`Mod of string | `Pkg of string] list ocp-indent-1.5.3/src/indentExtend.ml000066400000000000000000000036421273277264100173520ustar00rootroot00000000000000(**************************************************************************) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) exception Syntax_not_found of string type t = { keywords : (string * Approx_tokens.token) list; lexer : (Lexing.lexbuf -> Approx_tokens.token) option } let extensions = Hashtbl.create 17 let register name ?(keywords=[]) ?lexer () = Hashtbl.add extensions name {keywords;lexer} let available () = Hashtbl.fold (fun name _ acc -> name::acc) extensions [] let find (name : string) = try Hashtbl.find extensions name with Not_found -> raise (Syntax_not_found name) (* predefined extensions *) open Approx_tokens let _ = register "lwt" ~keywords:[ "for_lwt", FOR; "lwt", LET; "match_lwt", MATCH; "try_lwt", TRY; "while_lwt", WHILE; "finally", WITH; (* -- no equivalence for this one, this is a hack ! *) ] (); register "mll" ~keywords:[ "rule", LET; "parse", FUNCTION; ] (); register "stream" ~keywords:[ "parser", FUNCTION; ] (); register "cstruct" ~keywords:[ "cstruct", TYPE; ] (); register "bitstring" ~keywords:[ "bitmatch", MATCH; ] (); ocp-indent-1.5.3/src/indentExtend.mli000066400000000000000000000025531273277264100175230ustar00rootroot00000000000000(**************************************************************************) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) exception Syntax_not_found of string type t = { keywords : (string * Approx_tokens.token) list; lexer : (Lexing.lexbuf -> Approx_tokens.token) option } (** Register lexer extension.*) val register : string -> ?keywords:(string * Approx_tokens.token) list -> ?lexer:(Lexing.lexbuf -> Approx_tokens.token) -> unit -> unit (** Get available extensions *) val available : unit -> string list (** Find an extension by its name *) val find : string -> t ocp-indent-1.5.3/src/indentLoader.ml000066400000000000000000000042651273277264100173330ustar00rootroot00000000000000(**************************************************************************) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) module SS = Set.Make(String) let loaded = ref SS.empty let predicates = if Dynlink.is_native then [ "plugin" ; "native" ] else [ "plugin" ; "byte" ] let dynlink debug s = if debug then Format.eprintf "loading archive %s..@." s; try Dynlink.loadfile s with exc -> Format.eprintf "Error while linking %s : %s@." s (Printexc.to_string exc); raise exc let load_pkg debug pkg = if not (SS.mem pkg !loaded) then begin let d = Findlib.package_directory pkg in let archive = try Findlib.package_property predicates pkg "archive" with Not_found -> "" in let archives = Util.string_split ' ' archive in List.iter (fun arch -> if arch <> "" then let arch' = Findlib.resolve_path ~base:d arch in dynlink debug arch') archives; loaded:=SS.add pkg !loaded end let rec partition mods pkgs = function | [] -> List.rev pkgs, List.rev mods | `Mod m :: rest -> partition (m::mods) pkgs rest | `Pkg p :: rest -> partition mods (p::pkgs) rest let load ?(debug=false) l = let pkglist,mods = partition [] [] l in List.iter (dynlink debug) mods; let eff_pkglist = Findlib.package_deep_ancestors predicates pkglist in List.iter (load_pkg debug) eff_pkglist ocp-indent-1.5.3/src/indentLoader.mli000066400000000000000000000020251273277264100174740ustar00rootroot00000000000000(**************************************************************************) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) (** Dynlink of modules and finlib packages *) val load : ?debug:bool -> [`Mod of string | `Pkg of string ] list -> unit ocp-indent-1.5.3/src/indentMain.ml000066400000000000000000000067161273277264100170140ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012,2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) module Args = IndentArgs let indent_channel ic args config out = let oc, need_close = match out with | None | Some "-" -> stdout, false | Some file -> open_out file, true in let output = { IndentPrinter. debug = args.Args.debug; config = config; in_lines = args.Args.in_lines; indent_empty = args.Args.indent_empty; adaptive = true; kind = args.Args.indent_printer oc; } in let stream = Nstream.of_channel ic in IndentPrinter.proceed output stream IndentBlock.empty (); flush oc; if need_close then close_out oc let config_syntaxes syntaxes = Approx_lexer.disable_extensions (); List.iter (fun stx -> try Approx_lexer.enable_extension stx with IndentExtend.Syntax_not_found name -> Format.eprintf "Warning: unknown syntax extension %S@." name) syntaxes let indent_file args = function | Args.InChannel ic -> let config, syntaxes, dlink = IndentConfig.local_default () in IndentLoader.load ~debug:args.Args.debug (dlink @ args.Args.dynlink); config_syntaxes (syntaxes @ args.Args.syntax_exts); let config = List.fold_left IndentConfig.update_from_string config args.Args.indent_config in indent_channel ic args config args.Args.file_out | Args.File path -> let config, syntaxes, dlink = IndentConfig.local_default ~path:(Filename.dirname path) () in IndentLoader.load ~debug:args.Args.debug (dlink @ args.Args.dynlink); config_syntaxes (syntaxes @ args.Args.syntax_exts); let config = List.fold_left IndentConfig.update_from_string config args.Args.indent_config in let out, need_move = if args.Args.inplace then let tmp_file = path ^ ".ocp-indent-tmp" in Some tmp_file, Some path else args.Args.file_out, None in let ic = open_in path in try indent_channel ic args config out; match out, need_move with | Some src, Some dst -> Sys.rename src dst | _, _ -> () with e -> close_in ic; raise e let main = Cmdliner.Term.( pure (fun (args,files) -> List.iter (indent_file args) files) $ Args.options ), Args.info let _ = match Cmdliner.Term.eval main with | `Error _ -> exit 1 | _ -> exit 0 ocp-indent-1.5.3/src/indentPrinter.ml000066400000000000000000000233651273277264100175520ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2012,2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) open Compat open Pos open Nstream open Approx_lexer open Util type output_elt = Newline | Indent of int | Whitespace of string | Text of string type 'a output_kind = | Numeric of (int -> 'a -> 'a) | Print of (string -> 'a -> 'a) | Extended of (IndentBlock.t -> output_elt -> 'a -> 'a) type 'a output = { debug: bool; config: IndentConfig.t; (* Returns true on the lines that should be reindented *) in_lines: int -> bool; adaptive: bool; indent_empty: bool; kind: 'a output_kind; } let std_output = { debug = false; config = IndentConfig.default; in_lines = (fun _ -> true); adaptive = true; indent_empty = false; kind = Print (fun s () -> print_endline s); } (* utility functions *) let pr_string output block text usr = match output.kind with | Numeric _ -> usr | Print f -> f text usr | Extended f -> f block (Text text) usr let pr_whitespace output block text usr = match output.kind with | Numeric _ -> usr | Print f -> f text usr | Extended f -> f block (Whitespace text) usr let pr_nl output block usr = match output.kind with | Numeric _ -> usr | Print pr -> pr "\n" usr | Extended pr -> pr block Newline usr (* indent functions *) type indentKind = Normal | Empty (* empty line: depending on options, don't indent or try to guess expected indent. *) | Padded (* for comment continuations: indent the first line as the following ones*) | Fixed of int (* indent to this value, ignoring the block *) let warn_tabs = ref true (* must be called exactly once for each line, in order *) (* let line_debug_counter = ref 0 *) let print_indent output line blank ?(kind=Normal) block usr = (* assert (incr line_debug_counter; line = !line_debug_counter); *) if output.in_lines line then let indent = match kind with | Normal -> IndentBlock.indent block | Empty -> if output.indent_empty then IndentBlock.guess_indent line block else 0 | Padded -> IndentBlock.indent block + IndentBlock.padding block | Fixed n -> n in match output.kind with | Numeric pr -> pr indent usr | Print pr -> pr (String.make indent ' ') usr | Extended pr -> pr block (Indent indent) usr else ( if !warn_tabs && String.contains blank '\t' then ( warn_tabs := false; prerr_endline "Warning: ocp-indent input contains indentation by tabs, \ partial indent will be unreliable." ); match output.kind with | Numeric _ -> usr | Print pr -> pr blank usr | Extended pr -> pr block (Whitespace blank) usr ) let print_token output block tok usr = let orig_start_column = IndentBlock.original_column block in let start_column = IndentBlock.offset block in (* Handle multi-line tokens (strings, comments) *) let rec print_extra_lines line pad last lines usr = match lines with | [] -> usr | text::next_lines -> let usr = usr |> pr_nl output block in if not (output.in_lines line) then usr |> print_indent output line "" block |> pr_string output block text |> print_extra_lines (line+1) pad text next_lines else if String.trim text = "" && tok.token <> OCAMLDOC_VERB then usr |> print_indent output line "" ~kind:Empty block |> print_extra_lines (line+1) pad text next_lines else let orig_line_indent = count_leading_spaces text in let orig_offset = orig_line_indent - orig_start_column in let text = String.sub text orig_line_indent (String.length text - orig_line_indent) in let indent_value = match pad with | None -> orig_line_indent | Some pad -> match tok.token with | STRING _ -> if ends_with_escape last then if is_prefix "\"" text || is_prefix "\\ " text then start_column else start_column + pad else orig_line_indent | COMMENT | COMMENTCONT -> let n = if is_prefix "*" text then 1 else pad in let n = if output.config.IndentConfig.i_strict_comments then n else max orig_offset n in let n = if next_lines = [] && text = "*)" then 0 else n in start_column + n | QUOTATION -> start_column + if next_lines = [] && (text = ">>" || (String.length text >= 2 && text.[0] = '|' && text.[String.length text - 1] = '}')) then 0 else max orig_offset pad | _ -> start_column + max orig_offset pad in usr |> print_indent output line "" ~kind:(Fixed indent_value) block |> pr_string output block text |> print_extra_lines (line+1) pad text next_lines in let line = Region.start_line tok.region in let text, next_lines = if line = Region.end_line tok.region then (Lazy.force tok.substr), [] else match string_split '\n' (Lazy.force tok.substr) with | [] -> assert false | hd::tl -> hd,tl in let pad = if next_lines = [] then None else match tok.token with | STRING _ -> (match String.trim text with | "\"" | "\"\\" -> None | _ -> Some 1 (* length of '"' *)) | COMMENT -> (match String.trim text with | "(*" when not output.config.IndentConfig.i_strict_comments -> None | _ -> Some (IndentBlock.padding block)) | COMMENTCONT -> Some (IndentBlock.padding block) | OCAMLDOC_VERB -> None | QUOTATION -> let i = ref 1 in let len = String.length text in let endc = if len > 0 && text.[0] = '{' then '|' else '<' in while !i < len && text.[!i] <> endc do incr i done; if !i + 1 >= len then None else ( incr i; while !i < len && text.[!i] = ' ' do incr i done; Some !i ) | _ -> Some 2 in usr |> pr_string output block text |> print_extra_lines (line+1) pad text next_lines (* [block] is the current indentation block [stream] is the token stream *) let rec loop output block stream usr = match Nstream.next stream with | None -> usr (* End of file *) | Some (t, stream) -> let line = Region.start_line t.region in let last_line = line - t.newlines in (* handle leading blanks (output other lines right now, whitespace in front of the current token and on the same line is handled later) *) let blank, usr = let rec indent_between line blanks usr = match blanks with | [] -> assert false | bl::[] -> bl, usr |> pr_nl output block | bl::blanks -> usr |> pr_nl output block |> print_indent output line bl ~kind:Empty block |> indent_between (line + 1) blanks in let blanks = string_split '\n' (Lazy.force t.between) in match blanks with | [] -> assert false | bl::[] -> bl, usr (* no newline *) | bl::blanks -> usr |> (if last_line = 0 then print_indent output 1 "" ~kind:Empty block else fun usr -> usr) |> pr_whitespace output block bl |> indent_between (last_line + 1) blanks in (* Compute block and indent *) let block = IndentBlock.update output.config block stream t in (* Update block according to the indent in the file if before the handled region *) let block = if output.adaptive && not (output.in_lines line) then IndentBlock.reverse block else block in if output.debug then IndentBlock.dump block; (* Handle token *) let at_line_start = t.newlines > 0 in let usr = if at_line_start then let kind = match t.token with | COMMENT when is_prefix "(*\n" (Lazy.force t.substr) -> Fixed (String.length blank) | OCAMLDOC_VERB -> Padded | EOF -> Empty | COMMENTCONT -> Padded | _ -> Normal in usr |> print_indent output line blank ~kind block else usr |> pr_whitespace output block blank in let usr = usr |> print_token output block t in match t.token with EOF -> usr | _ -> usr |> loop output block stream let proceed output stream block usr = usr |> loop output block stream ocp-indent-1.5.3/src/indentPrinter.mli000066400000000000000000000045621273277264100177210ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) (** Passed to the function specified with the [Extended] output_kind *) type output_elt = Newline | Indent of int | Whitespace of string | Text of string (** * If [Print f], the whole input is fed as strings through f, with expected lines reindented (with spaces). * If [Numeric f], the indentation values (i.e. total number of leading spaces) for each lines on which [in_lines] is true are passed through the function. * If [Extended f], every element is fed to [f] with arguments [state element]. There is at least an element for each token, but there may be more (whitespace, multiline tokens...). You may safely raise an exception from [f] to stop further processing. This version can be used for syntax highlighting or storing checkpoints. *) type 'a output_kind = | Numeric of (int -> 'a -> 'a) | Print of (string -> 'a -> 'a) | Extended of (IndentBlock.t -> output_elt -> 'a -> 'a) type 'a output = { debug: bool; config: IndentConfig.t; (** Returns true on the lines that should be reindented (lines start at 1) *) in_lines: int -> bool; (** if true, partial indent will adapt to the current indent of the file *) adaptive: bool; indent_empty: bool; kind: 'a output_kind; } val std_output : unit output val proceed : 'a output -> Nstream.t -> IndentBlock.t -> 'a -> 'a ocp-indent-1.5.3/src/nstream.ml000066400000000000000000000112741273277264100163720ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012-2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) open Pos open Approx_lexer type token = { region : Region.t; token : Approx_lexer.token; newlines: int; between : string Lazy.t; substr : string Lazy.t; offset : int; } type cons = | Cons of token * t | Null and t = cons lazy_t let of_string ?(start_pos=Position.zero) ?(start_offset=0) string = let lexbuf = { Lexing. refill_buff = (fun lexbuf -> lexbuf.Lexing.lex_eof_reached <- true); lex_buffer = string; lex_buffer_len = String.length string; lex_abs_pos = start_offset; lex_start_pos = start_offset; lex_curr_pos = start_offset; lex_last_pos = start_offset; lex_last_action = 0; lex_mem = [||]; lex_eof_reached = true; lex_start_p = start_pos; lex_curr_p = start_pos; } in Approx_lexer.init (); let rec loop last = let open Lexing in match Approx_lexer.token_with_comments lexbuf with | EOL | SPACES -> loop last | token -> let pos_last = Region.snd last and pos_start = lexbuf.lex_start_p and pos_end = lexbuf.lex_curr_p in let region = Region.create pos_start pos_end in let offset = Region.start_column region - Region.start_column last in let spaces = pos_start.pos_cnum - pos_last.pos_cnum in let len = pos_end.pos_cnum - pos_start.pos_cnum in let newlines = pos_start.pos_lnum - pos_last.pos_lnum in let between = lazy (String.sub string pos_last.pos_cnum spaces) in let substr = lazy (String.sub string pos_start.pos_cnum len) in Cons ({ region; token; newlines; between; substr; offset }, lazy (match token with | EOF -> Null | _ -> loop region) ) in let init_region = let pos_above = {start_pos with Lexing.pos_lnum = start_pos.Lexing.pos_lnum - 1} in Region.create pos_above pos_above in lazy (loop init_region) let of_channel ?(start_pos=Position.zero) ic = (* add some caching to the reader function, so that we can get back the original strings *) let buf = Buffer.create 511 in let reader str count = let n = input ic str 0 count in Buffer.add_substring buf str 0 n; n in let lexbuf = Lexing.from_function reader in let lexbuf = { lexbuf with Lexing.lex_start_p = start_pos; Lexing.lex_curr_p = start_pos; } in Approx_lexer.init (); let rec loop last = let open Lexing in match Approx_lexer.token_with_comments lexbuf with | EOL | SPACES -> loop last | token -> let pos_last = Region.snd last and pos_start = lexbuf.lex_start_p and pos_end = lexbuf.lex_curr_p in let spaces = pos_start.pos_cnum - pos_last.pos_cnum in let len = pos_end.pos_cnum - pos_start.pos_cnum in let newlines = pos_start.pos_lnum - pos_last.pos_lnum in let between = Lazy.lazy_from_val (Buffer.sub buf 0 spaces) in let substr = Lazy.lazy_from_val (Buffer.sub buf spaces len) in let total = pos_end.pos_cnum - pos_last.pos_cnum in let more = Buffer.sub buf total (Buffer.length buf - total) in Buffer.clear buf; Buffer.add_string buf more; let region = Region.create pos_start pos_end in let offset = Region.start_column region - Region.start_column last in Cons ({ region; token; newlines; between; substr; offset }, lazy (match token with | EOF -> Null | _ -> loop region) ) in let init_region = let pos_above = {start_pos with Lexing.pos_lnum = start_pos.Lexing.pos_lnum - 1} in Region.create pos_above pos_above in lazy (loop init_region) let next = function | lazy Null -> None | lazy (Cons (car, cdr)) -> Some (car, cdr) ocp-indent-1.5.3/src/nstream.mli000066400000000000000000000035101273277264100165350ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012-2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) (** Stream with efficient n-lookup *) open Pos (** Enhanced tokens *) type token = { region : Region.t; token : Approx_lexer.token; newlines: int; between : string Lazy.t; substr : string Lazy.t; offset : int; } type t (** Creates a stream from a string. Make sure you don't change the string in-place after calling [of_string], or anything could happen *) val of_string: ?start_pos:Position.t -> ?start_offset:int -> string -> t (** Creates a stream from a channel. Better if you don't want to block, but less efficient *) val of_channel: ?start_pos:Position.t -> in_channel -> t (** Get next token from the filter. Returns None after EOF *) val next: t -> (token * t) option ocp-indent-1.5.3/src/ocaml_3/000077500000000000000000000000001273277264100156775ustar00rootroot00000000000000ocp-indent-1.5.3/src/ocaml_3/compat.ml000066400000000000000000000011571273277264100175200ustar00rootroot00000000000000 let ( |> ) : 'a -> ('a -> 'b) -> 'b = fun x f -> f x module String = struct include String let is_space = function | ' ' | '\012' | '\n' | '\r' | '\t' -> true | _ -> false let trim s = let len = length s in let i = ref 0 in while !i < len && is_space (unsafe_get s !i) do incr i done; let j = ref (len - 1) in while !j >= !i && is_space (unsafe_get s !j) do decr j done; if !i = 0 && !j = len - 1 then s else if !j >= !i then sub s !i (!j - !i + 1) else "" end module Lazy = struct include Lazy let from_val = lazy_from_val end ocp-indent-1.5.3/src/ocaml_4/000077500000000000000000000000001273277264100157005ustar00rootroot00000000000000ocp-indent-1.5.3/src/ocaml_4/compat.ml000066400000000000000000000003651273277264100175210ustar00rootroot00000000000000external ( @* ) : ('a -> 'b) -> 'a -> 'b = "%apply" external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply" module String = struct include String let is_space = function | ' ' | '\012' | '\n' | '\r' | '\t' -> true | _ -> false end ocp-indent-1.5.3/src/ocp-indent-lib.mllib000066400000000000000000000001321273277264100202030ustar00rootroot00000000000000Approx_tokens Approx_lexer Compat Pos Util Nstream IndentConfig IndentBlock IndentPrinter ocp-indent-1.5.3/src/ocp-indent.ocp000066400000000000000000000023151273277264100171260ustar00rootroot00000000000000comp += [ "-g" "-w" "+A-4-9-44" ] begin library "ocp-indent.lexer" files = [ "indentExtend.ml" "approx_tokens.ml" "approx_lexer.mll" ] bundle = [ "ocp-indent" ] end begin library "ocp-indent.utils" sort = false files = [ "pos.ml" "util.ml" "nstream.ml" ] if ocaml_major_version = "3" then { files += [ "ocaml_3/compat.ml" ] } else { files += [ "ocaml_4/compat.ml" ] } requires = [ "ocp-indent.lexer" ] bundle = [ "ocp-indent" ] end begin library "ocp-indent.dynlink" files = [ "indentLoader.ml" ] requires = [ "findlib" "dynlink" "ocp-indent.lexer" "ocp-indent.utils" ] bundle = [ "ocp-indent" ] end begin library "ocp-indent.lib" sort = false files = [ "indentConfig.ml" "indentBlock.ml" "indentPrinter.ml" ] requires = [ "ocp-indent.lexer" "ocp-indent.utils" ] bundle = [ "ocp-indent" ] end begin program "ocp-indent" sort = false files = [ "indentVersion.ml" (ocp2ml) (* auto-generated by ocp-build *) "indentArgs.ml" "indentMain.ml" ] requires = [ "cmdliner" "ocp-indent.lexer" "ocp-indent.lib" "ocp-indent.dynlink" ] end ocp-indent-1.5.3/src/pos.ml000066400000000000000000000042101273277264100155120ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) module Position = struct type t = Lexing.position = { pos_fname : string; pos_lnum : int; pos_bol : int; pos_cnum : int; } let to_string t = Printf.sprintf "%s%d:%d" (if t.pos_fname = "" then "" else t.pos_fname ^ ":") t.pos_lnum (t.pos_cnum - t.pos_bol) let zero = { pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0 } let column p = p.pos_cnum - p.pos_bol end module Region = struct open Position type t = Position.t * Position.t let fst = fst let snd = snd let create p1 p2 = (p1,p2) let start_column (p,_) = column p let end_column (_,p) = column p let start_line (p,_) = p.pos_lnum let end_line (_,p) = p.pos_lnum let char_offset (p, _) = p.pos_cnum let length (p1, p2) = p2.Position.pos_cnum - p1.Position.pos_cnum let zero = (Position.zero, Position.zero) let translate (p,p') diff = { p with pos_cnum = p .pos_cnum + diff }, { p' with pos_cnum = p'.pos_cnum + diff } end ocp-indent-1.5.3/src/pos.mli000066400000000000000000000045221273277264100156710ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) (** Lexer positions & regions *) (** Lexer positions *) module Position : sig (** A position in a lexer stream *) type t = Lexing.position (** Pretty-print a position *) val to_string: t -> string (** Initial position *) val zero: t (** Get the coloumn offset associated to a lexing position *) val column: t -> int end (** Lexer regions *) module Region : sig (** A region in a lexer stream *) type t (** Create a region from a starting and an ending position *) val create: Position.t -> Position.t -> t val fst: t -> Position.t val snd: t -> Position.t (** Return the column where the region starts *) val start_column: t -> int (** Return the column where the region ends *) val end_column: t -> int (** Get the region offset (number of characters from the beginning of the file *) val char_offset: t -> int (** Get the lenght of a region *) val length: t -> int (** Return the line number where the region starts *) val start_line: t -> int (** Return the line number where the region ends *) val end_line: t -> int (** The empty region *) val zero: t (** [translate t x] shifts a region by [x] characters *) val translate: t -> int -> t end ocp-indent-1.5.3/src/util.ml000066400000000000000000000060631273277264100156760ustar00rootroot00000000000000(**************************************************************************) (* *) (* Copyright 2011 Jun Furuse *) (* Copyright 2012,2013 OCamlPro *) (* *) (* All rights reserved.This file is distributed under the terms of the *) (* GNU Lesser General Public License version 3.0 with linking *) (* exception. *) (* *) (* TypeRex is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* Lesser GNU General Public License for more details. *) (* *) (**************************************************************************) let compose : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c = fun f g x -> f (g (x)) let ( @* ) = compose let default d = function Some x -> x | None -> d let string_split char str = let rec aux pos = try let i = String.index_from str pos char in String.sub str pos (i - pos) :: aux (succ i) with Not_found | Invalid_argument _ -> let l = String.length str in [ String.sub str pos (l - pos) ] in aux 0 let string_split_chars chars str = let len = String.length str in let rec split pos = let rec lookup i = if i >= len then raise Not_found else if String.contains chars str.[i] then i else lookup (succ i) in try let i = lookup pos in if i > pos then String.sub str pos (i - pos) :: split (succ i) else split (succ i) with Not_found | Invalid_argument _ -> [ String.sub str pos (len - pos) ] in split 0 let is_prefix pfx str = let pfxlen = String.length pfx in let rec check i = i >= pfxlen || pfx.[i] = str.[i] && check (i+1) in String.length str >= pfxlen && check 0 let ends_with_escape s = let rec aux n = n >= 0 && s.[n] = '\\' && not (aux (n-1)) in aux (String.length s - 1) let count_leading_spaces s = let rec aux i = if i >= String.length s || s.[i] <> ' ' then i else aux (i+1) in aux 0 let shorten_string n s = match string_split '\n' s with | [] -> "" | [s] -> if String.length s <= n then s else let n1 = (n - 3) / 2 in let n2 = n - 3 - n1 in String.sub s 0 n1 ^ "..." ^ String.sub s (String.length s - n2) n2 | s1::r1::r -> let s2 = let rec last x = function x::r -> last x r | [] -> x in last r1 r in let l1 = String.length s1 and l2 = String.length s2 in let n1 = min l1 (max ((n-3) / 2) (n-3 - l2)) in let n2 = min l2 (n - 3 - n1) in String.sub s1 0 n1 ^ "..." ^ String.sub s2 (l2 - n2) n2 ocp-indent-1.5.3/tests/000077500000000000000000000000001273277264100147355ustar00rootroot00000000000000ocp-indent-1.5.3/tests/.ocp-indent000066400000000000000000000000071273277264100167730ustar00rootroot00000000000000normal ocp-indent-1.5.3/tests/failing-output/000077500000000000000000000000001273277264100177045ustar00rootroot00000000000000ocp-indent-1.5.3/tests/failing-output/edge-cases.ml000066400000000000000000000026151273277264100222420ustar00rootroot00000000000000 (* this could be fixed, but we actually want to handle the first case differently for when there is only one case (see next examples) *) let f x = function A -> x; 2 | B -> y; 3 (* if we were to fix to the case above, the second >>= would be below the _ (test taken from js-fun) *) let _ = x >>= fun x -> try x with _ -> () >>= fun x -> x (* (and also: the some_handling here would be below Not_found) *) let _ = try _ with Not_found -> some_handling let f = fun x -> x let f = (fun x -> x ) let f g = g @@ fun x -> x let f g = g @@ (fun x -> x ) (* the above should probably be consistent with: *) let f x y = y + match x with A -> 0 let f x y = y + (match x with A -> 0 ) (* wich means we may over-indent even when the block is non-closable *) let f x y = y + match x with | A -> 0 let f x y = y + (match x with | A -> 0 ) let f x y = y + match x with | A -> 0 let _ = somefun (fun x -> x); somefun (if bla then bli); somefun (if bla then bli else blu) let _ = a ; b (* Surprisingly, this is the indentation correpsonding to OCaml's interpretation of this code. Indenting this accordingly may help users notice that they're doing something dubious. *) let b = `b let d = `d ;; let a = b function (_ : [ `c ]) -> d ;; ocp-indent-1.5.3/tests/failing-output/escaped-nl.ml000066400000000000000000000012301273277264100222450ustar00rootroot00000000000000let s1 = "No field 'install', but a field 'remove': install instructions \ probably part of 'build'. Use the 'install' field or a .install \ file" let x = cond 40 `Warning "Package uses flags that aren't recognised by earlier versions in \ OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ instead for compatibility" ~detail:alpha_flags (alpha_flags <> []) let s2 = "bla bla bli bli \ blo" let s3 = "\ " let s4 = " \ " let s5 = " \ \ " let s6 = " " let s7 = " " let c1 = ' ' let x1 = f x ' ' y z let zz = "\ s \ \ " ocp-indent-1.5.3/tests/failing-output/indent-empty-numeric.ml000066400000000000000000000000251273277264100243100ustar00rootroot000000000000000 0 2 2 0 0 0 0 2 15 ocp-indent-1.5.3/tests/failing-output/js-args.ml000066400000000000000000000074201273277264100216070ustar00rootroot00000000000000let () = foo.bar <- f x y z let should_check_can_sell_and_marking regulatory_regime = match z with | `foo -> some_function argument (* The above typically occurs in a multi-pattern match clause, so the clause expression is on a line by itself. This is the more typical way a long single-pattern match clause would be written: *) let should_check_can_sell_and_marking regulatory_regime = match z with | `foo -> some_function argument let f = fun x -> ghi x (* common *) let x = try x with | a -> b | c -> d let x = try x with | a -> b | c -> d let x = try x with | a -> b | c -> d let z = some_function argument let () = f a b ~c:c d let () = f a b ~c:1. d let () = My_module.f a b ~c:c d (* This last case is where Tuareg is inconsistent with the others. *) let () = My_module.f a b ~c:1. d let () = messages := Message_store.create (Session_id.of_string "") (* Tuareg indents these lines too far to the left. *) "herd-retransmitter" Message_store.Message_size.Byte let () = raise (Bug ("foo" (* In this and similar cases, we want the subsequent lines to align with the first expression. *) ^ "bar")); raise (Bug ("foo" ^ "quux" ^ "bar")); raise (Bug (foo + quux ^ "bar")); raise (Bug ((foo + quux) ^ "bar")) (* Except in specific cases, we want the argument indented relative to the function being called. (Exceptions include "fun" arguments where the line ends with "->" and subsequent lines beginning with operators, like above.) *) let () = Some (Message_store.create s "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) (* We like the indentation of most arguments, but want to get back towards the left margin in a few special cases: *) let _ = foo (bar (fun x -> (* special: "fun _ ->" at EOL *) baz)) (* assume no more arguments to "bar" *) let _ = foo ~a_long_field_name:(check (fun bar -> baz)) let _ = foo ~a_long_field_name:(check (fun bar -> baz)) let _ = foo (bar (quux (fnord (fun x -> (* any depth *) baz)))) (* We also wanted to tweak the operator indentation, making operators like <= not special cases in contexts like this: *) let _ = assert (foo (bar + baz <= quux)) (* lined up under left argument to op, sim. to ^ above *) (* Sim. indentation of if conditions: *) let _ = if (a <= b) then () let _ = (* Comparisons are different than conditionals; we don't regard them as conceptually part of the [if] expression. *) if a <= b then () let _ = (* We regard the outermost condition terms as conceptually part of the [if] expression and indent accordingly. Whether [&&] or [||], conditionals effectively state lists of conditions for [then]. *) if Edge_adjustment.is_zero arb.cfg.extra_edge && 0. = sys.plugs.edge_backoff && 0. = zero_acvol_edge_backoff then 0. else 1. let _ = if Edge_adjustment.is_zero arb.cfg.extra_edge && 0. = sys.plugs.edge_backoff && 0. = zero_acvol_edge_backoff then 0. else 1. let _ = let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> Pcre.pmatch ~pat ts.RQ.description ) in x (* combination of operator at BOL and -> at EOL: *) let _ = Shell.ssh_lines x |! List.map ~f:(f (g (fun x -> let name, path = String.lsplit2_exn ~on:'|' x in String.strip name, String.strip path))) (* open paren ending line like begin *) let _ = if a (p ^/ "s") [ e ] = Ok () then `S ( let label count = sprintf "%d s" c ^ if c = 1 then ":" else "s" in x ) ocp-indent-1.5.3/tests/failing-output/js-begin.ml000066400000000000000000000002711273277264100217340ustar00rootroot00000000000000let f = function | zoo -> begin foo; bar; end ;; let g = function | zoo -> ( foo; bar; ) ;; let () = begin match foo with | Bar -> snoo end ;; ocp-indent-1.5.3/tests/failing-output/js-fun.ml000066400000000000000000000023111273277264100214350ustar00rootroot00000000000000(* preferred list style *) let z = f [ y ; foo ~f:(fun () -> arg) ] ;; let z = f [ y ; foo ~f:(fun () -> arg ) ] ;; (* legacy list style *) let _ = [ f (fun x -> x); f (fun x -> x); f (fun x -> x); ] let _ = [ f (fun x -> x ); f (fun x -> x ); f (fun x -> x ); ] ;; let _ = [f (fun x -> x ); f (fun x -> x ); f (fun x -> x ); ] ;; let _ = x >>= fun x -> (try x with _ -> ()) >>= fun x -> try x with _ -> () >>= fun x -> x ;; let () = expr >>| function | x -> 3 | y -> 4 ;; let () = expr >>| fun z -> match z with | x -> 3 | y -> 4 ;; let () = expr >>| fun z -> function | x -> 3 | y -> 4 ;; let () = my_func () >>= function | A -> 0 | B -> 0 ;; let () = my_func () >>= (function | A -> 0 | B -> 0) ;; let () = expr >>| function | x -> 3 | y -> 4 ;; let () = expr >>| (function | x -> 3 | y -> 4) ;; let f = f >>= m (fun f -> fun x -> y); z ;; let f = f |> m (fun f -> fun x -> y ); z ;; let f = f |> m (fun f -> fun x -> y); z ;; ocp-indent-1.5.3/tests/failing-output/js-functor.ml000066400000000000000000000024331273277264100223320ustar00rootroot00000000000000module M = Foo (G) (H) module M = Foo (G) (struct let x end) (H) (* To me, this looks fine as it is. The rule seems fine as "indent arguments by 2". To illustrate, with a case where the functor name is longer: *) module M = Functor (G) (H) (I) include Foo (struct let x end) (struct let y end) include Foo (struct let x end) (struct let y end) include Foo (struct let x end) (struct let y end) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) module M = Foo (struct let x end) (struct let y end) module M : S = Make (M) module M : S with type t := int = Make (M) module Simple_command(Arg:sig end) = struct end module Simple_command(Arg : sig end) = struct end module Simple_command (Arg:sig end) = struct end module Simple_command (Arg : sig end) = struct end module Simple_command (Arg : sig end) = struct end ocp-indent-1.5.3/tests/failing-output/js-pattern.ml000066400000000000000000000012271273277264100223270ustar00rootroot00000000000000let f = function | _ -> 0 ;; let f x = match x with | _ -> 0 ;; let f = function | _ -> 0 ;; let f x = match x with | _ -> 0 ;; let f x = begin match x with | _ -> 0 end ;; let check_price t = function | { Exec. trade_at_settlement = (None | Some false); } -> () let check_price t = function | simpler -> () | other -> () (* Sometimes we like to write big alternations like this, in which case the comment should typically align with the following clause. *) let 0 = match x with | A (* a *) -> a let 0 = match x with A (* a *) -> a let _ = a || match a with | a -> true | b -> false ocp-indent-1.5.3/tests/failing-output/js-record.ml000066400000000000000000000012131273277264100221230ustar00rootroot00000000000000type x = { foo : int ; bar : int } let x = { x with foo = 3 ; bar = 5 } let x = { (* blah blah blah *) foo = 3 ; bar = 5 } ;; let x = [{ x with foo = 3 ; bar = 5 }] let x = [{ (* blah blah blah *) foo = 3 ; bar = 5 }] ;; let x = { M.x with M. foo = 3 } ;; let x = { x with M. foo = 3 } ;; let x = { M. foo = 3 } ;; let _ = { foo with Bar. field1 = value1 ; field2 = value2 } ;; let _ = { foo with Bar. field1 = value1 ; field2 = value2 } ;; (* multicomponent record module pathname *) let _ = { A.B. a = b ; c = d } ;; ocp-indent-1.5.3/tests/failing-output/js-syntax.ml000066400000000000000000000006611273277264100222010ustar00rootroot00000000000000(* s *) let _ = [%raise_structural_sexp "feature's tip is already an ancestor of new base" { feature_tip = (old_tip : Rev.t) ; new_base = (new_base : Rev.t) }] let _ = [%raise_structural_sexp "feature's tip is already an ancestor of new base" { feature_tip = (old_tip : Rev.t) ; new_base = (new_base : Rev.t) } ] ocp-indent-1.5.3/tests/failing-output/js-to-do.ml000066400000000000000000000042701273277264100216750ustar00rootroot00000000000000(* Indentation that Jane Street needs to think about and make precise. These are long term ideas, possibly even conflicting with other tests. *) (* js-args *) let _ = let min_closing_backoff = -. ( Hidden_float.expose (arb.cfg.base_edge @! Buy) +. Hidden_float.expose (arb.cfg.base_edge @! Sell)) in 0 (* js-type *) (* The following tests incorporate several subtle and different indentation ideas. Please consider this only a proposal for discussion, for now. First, notice the display treatment of "(,)" tuples, analogous to "[;]" lists. While "(,)" is an intensional combination of "()" and ",", unlike "[;]" lists, we believe "(,)" isn't too big a departure. Value expression analogies are included in js-type.ml, (meant to be) consistent with the proposed type indentation. Second, and more divergently, the proposed indentation of function types is based on the idea of aligning the arguments, even the first argument, even where that means automatically inserting spaces within lines. This applies to the extra spaces in ":__unit" and "(____Config.Network.t" below. We believe this fits into a more general incorporation of alignment into ocp-indent, to replace our internal alignment tool with a syntax-aware one. We like to align things for readability, like big records, record types, lists used to build tables, etc. The proposal also includes indenting "->" in the circumstances below relative to the enclosing "()", by two spaces. In a sense, this happens first, and then the first argument is aligned accordingly. So, there's no manual indentation or spacing below. *) val instances : unit -> ( Config.Network.t -> (App.t * Config.instance * Config.app) list -> verbose:bool -> 'm , 'm ) Command.Spec.t val instances : unit -> ( Config.Network.t -> (App.t * Config.instance * Config.app) list -> verbose:bool -> 'm , 'm ) Command.Spec.t (* presumed analog with stars *) val instances : unit * ( Config.Network.t * (App.t * Config.instance * Config.app) list * bool * 'm , 'm ) Command.Spec.t ocp-indent-1.5.3/tests/failing-output/js-upon.ml000066400000000000000000000005271273277264100216350ustar00rootroot00000000000000let f x = stop (* We don't do this as a matter of style, but the indentation reveals a common mistake. *) >>> fun () -> don't_wait_for (close fd); bind fd let f x = stop (* This is what was intended, which is indented correctly, although it's bad style on my part. *) >>> (fun () -> don't_wait_for (close fd)); bind ocp-indent-1.5.3/tests/failing-output/list_of_funs.ml000066400000000000000000000010131273277264100227230ustar00rootroot00000000000000let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = x [ (fun () -> 3) ; (fun () -> 4) ] let f x = [ (fun () -> 3) ; (fun () -> 4) ] let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = x [ (fun () -> 3) ; (fun () -> 4) ] let f x = [ (fun () -> 3) ; (fun () -> 4) ] ocp-indent-1.5.3/tests/failing.html000066400000000000000000003404621273277264100172450ustar00rootroot00000000000000 Failing tests, ocp-indent version 1.5.3 (2016-06-23)

Failing tests, ocp-indent version 1.5.3 (2016-06-23)

Differences in edge-cases.ml

ExpectedOcp-indent output
0
1
(* this could be fixed, but we actually want to handle the first case
(* this could be fixed, but we actually want to handle the first case
2
   differently for when there is only one case (see next examples) *)
   differently for when there is only one case (see next examples) *)
3
let f x = function A -> x;
let f x = function A -> x;
4
  2
  2
5
                 | B -> y;
                 | B -> y;
6
                   3
                   3
7
8
(* if we were to fix to the case above, the second >>= would be below the _
(* if we were to fix to the case above, the second >>= would be below the _
9
   (test taken from js-fun) *)
   (test taken from js-fun) *)
10
let _ =
let _ =
11
  x
  x
12
  >>= fun x ->
  >>= fun x ->
13
  try x with _ -> ()
  try x with _ -> ()
14
    >>= fun x ->
    >>= fun x ->
15
    x
    x
16
17
(* (and also: the some_handling here would be below Not_found) *)
(* (and also: the some_handling here would be below Not_found) *)
18
let _ =
let _ =
19
  try
  try
20
    _
    _
21
  with Not_found ->
  with Not_found ->
22
    some_handling
    some_handling
23
24
let f = fun x ->
let f = fun x ->
25
  x
  x
26
27
let f = (fun x ->
let f = (fun x ->
28
    x
    x
29
  )
  )
30
31
let f g = g @@ fun x ->
let f g = g @@ fun x ->
32
  x
  x
33
34
let f g = g @@ (fun x ->
let f g = g @@ (fun x ->
35
    x
    x
36
  )
  )
37
38
39
(* the above should probably be consistent with: *)
(* the above should probably be consistent with: *)
40
let f x y = y + match x with A ->
let f x y = y + match x with A ->
41
    0
    0
42
43
let f x y = y + (match x with A ->
let f x y = y + (match x with A ->
44
    0
    0
45
  )
  )
46
47
(* wich means we may over-indent even when the block is non-closable *)
(* wich means we may over-indent even when the block is non-closable *)
48
49
let f x y = y + match x with
let f x y = y + match x with
50
  | A -> 0
  | A -> 0
51
52
let f x y = y + (match x with
let f x y = y + (match x with
53
    | A -> 0
    | A -> 0
54
  )
  )
55
56
let f x y = y + match x with
let f x y = y + match x with
57
  | A -> 0
  | A -> 0
58
59
let _ =
let _ =
60
  somefun
  somefun
61
    (fun x ->
    (fun x ->
62
       x);
       x);
63
  somefun
  somefun
64
    (if
    (if
65
      bla
      bla
66
     then
     then
67
       bli);
       bli);
68
  somefun
  somefun
69
    (if bla then
    (if bla then
70
       bli
       bli
71
     else
     else
72
       blu)
       blu)
73
74
let _ =
let _ =
75
  a
  a
76
  ;
  ;
77
  b
  b
78
79
(* Surprisingly, this is the indentation correpsonding to OCaml's interpretation
(* Surprisingly, this is the indentation correpsonding to OCaml's interpretation
80
   of this code.  Indenting this accordingly may help users notice that they're
   of this code.  Indenting this accordingly may help users notice that they're
81
   doing something dubious. *)
   doing something dubious. *)
82
let b = `b
let b = `b
83
let d = `d
let d = `d
84
;;
;;
85
let a = b
let a = b
86
function·(_·:·[·`c·])·->·d
····function·(_·:·[·`c·])·->·d
87
;;
;;

Differences in escaped-nl.ml.ref

ExpectedOcp-indent output
0
let s1 = "No field 'install', but a field 'remove': install instructions \
let s1 = "No field 'install', but a field 'remove': install instructions \
1
          probably part of 'build'. Use the 'install' field or a .install \
          probably part of 'build'. Use the 'install' field or a .install \
2
          file"
          file"
3
4
let x =
let x =
5
  cond 40 `Warning
  cond 40 `Warning
6
    "Package uses flags that aren't recognised by earlier versions in \
    "Package uses flags that aren't recognised by earlier versions in \
7
     OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \
     OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \
8
     instead for compatibility"
     instead for compatibility"
9
    ~detail:alpha_flags
    ~detail:alpha_flags
10
    (alpha_flags <> [])
    (alpha_flags <> [])
11
12
let s2 = "bla bla
let s2 = "bla bla
13
 bli bli \
 bli bli \
14
          blo"
          blo"
15
16
let s3 = "\
let s3 = "\
17
"
"
18
19
let s4 = " \
let s4 = " \
20
         "
         "
21
22
let s5 = "  \
let s5 = "  \
23
          \
          \
24
         "
         "
25
26
let s6 = "
let s6 = "
27
"
"
28
29
let s7 = "  
let s7 = "  
30
"
"
31
32
let c1 = '
let c1 = '
33
'
···········'
34
35
let x1 = f x '
let x1 = f x '
36
'·y
···············'·y
37
    z
    z
38
39
let zz = "\
let zz = "\
40
41
s \
s \
42
 \
 \
43
 "
 "

Differences in js-args.ml

ExpectedOcp-indent output
0
let () =
let () =
1
  foo.bar <-
  foo.bar <-
2
    f x
    f x
3
      y z
      y z
4
5
let should_check_can_sell_and_marking regulatory_regime =
let should_check_can_sell_and_marking regulatory_regime =
6
  match z with
  match z with
7
  | `foo
  | `foo
8
    -> some_function
    -> some_function
9
         argument
         argument
10
(* The above typically occurs in a multi-pattern match clause, so the clause
(* The above typically occurs in a multi-pattern match clause, so the clause
11
   expression is on a line by itself.  This is the more typical way a long
   expression is on a line by itself.  This is the more typical way a long
12
   single-pattern match clause would be written: *)
   single-pattern match clause would be written: *)
13
let should_check_can_sell_and_marking regulatory_regime =
let should_check_can_sell_and_marking regulatory_regime =
14
  match z with
  match z with
15
  | `foo ->
  | `foo ->
16
    some_function
    some_function
17
      argument
      argument
18
19
let f = fun x ->
let f = fun x ->
20
  ghi
  ghi
21
    x
    x
22
23
(* common *)
(* common *)
24
let x =
let x =
25
  try x with
  try x with
26
  | a -> b
  | a -> b
27
  | c -> d
  | c -> d
28
let x = try x with
let x = try x with
29
  | a -> b
  | a -> b
30
  | c -> d
  | c -> d
31
let x =
let x =
32
  try x
  try x
33
  with
  with
34
  | a -> b
  | a -> b
35
  | c -> d
  | c -> d
36
37
let z =
let z =
38
  some_function
  some_function
39
    argument
    argument
40
41
42
43
let () =
let () =
44
  f a b ~c:c
  f a b ~c:c
45
    d
    d
46
47
let () =
let () =
48
  f a b ~c:1.
  f a b ~c:1.
49
    d
    d
50
51
let () =
let () =
52
  My_module.f a b ~c:c
  My_module.f a b ~c:c
53
    d
    d
54
55
(* This last case is where Tuareg is inconsistent with the others. *)
(* This last case is where Tuareg is inconsistent with the others. *)
56
let () =
let () =
57
  My_module.f a b ~c:1.
  My_module.f a b ~c:1.
58
    d
    d
59
60
61
62
let () =
let () =
63
  messages :=
  messages :=
64
    Message_store.create (Session_id.of_string "")
    Message_store.create (Session_id.of_string "")
65
      (* Tuareg indents these lines too far to the left. *)
      (* Tuareg indents these lines too far to the left. *)
66
      "herd-retransmitter"
      "herd-retransmitter"
67
      Message_store.Message_size.Byte
      Message_store.Message_size.Byte
68
69
70
71
let () =
let () =
72
  raise (Bug ("foo"
  raise (Bug ("foo"
73
              (* In this and similar cases, we want the subsequent lines to
              (* In this and similar cases, we want the subsequent lines to
74
                 align with the first expression. *)
                 align with the first expression. *)
75
              ^ "bar"));
              ^ "bar"));
76
  raise (Bug ("foo" ^ "quux"
  raise (Bug ("foo" ^ "quux"
77
              ^ "bar"));
              ^ "bar"));
78
  raise (Bug (foo + quux
  raise (Bug (foo + quux
79
              ^ "bar"));
              ^ "bar"));
80
  raise (Bug ((foo + quux)
  raise (Bug ((foo + quux)
81
              ^ "bar"))
              ^ "bar"))
82
83
(* Except in specific cases, we want the argument indented relative to the
(* Except in specific cases, we want the argument indented relative to the
84
   function being called.  (Exceptions include "fun" arguments where the line
   function being called.  (Exceptions include "fun" arguments where the line
85
   ends with "->" and subsequent lines beginning with operators, like above.) *)
   ends with "->" and subsequent lines beginning with operators, like above.) *)
86
let () =
let () =
87
  Some (Message_store.create s
  Some (Message_store.create s
88
          "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte)
          "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte)
89
90
91
92
(* We like the indentation of most arguments, but want to get back towards the
(* We like the indentation of most arguments, but want to get back towards the
93
   left margin in a few special cases: *)
   left margin in a few special cases: *)
94
let _ =
let _ =
95
  foo (bar (fun x ->                    (* special: "fun _ ->" at EOL *)
  foo (bar (fun x ->                    (* special: "fun _ ->" at EOL *)
96
    baz))                               (* assume no more arguments to "bar" *)
    baz))                               (* assume no more arguments to "bar" *)
97
let _ =
let _ =
98
  foo
  foo
99
    ~a_long_field_name:(check (fun bar ->
    ~a_long_field_name:(check (fun bar ->
100
      baz))
      baz))
101
let _ =
let _ =
102
  foo ~a_long_field_name:(check (fun bar ->
  foo ~a_long_field_name:(check (fun bar ->
103
    baz))
    baz))
104
let _ =
let _ =
105
  foo (bar (quux (fnord (fun x ->       (* any depth *)
  foo (bar (quux (fnord (fun x ->       (* any depth *)
106
    baz))))
    baz))))
107
108
(* We also wanted to tweak the operator indentation, making operators like <=
(* We also wanted to tweak the operator indentation, making operators like <=
109
   not special cases in contexts like this:  *)
   not special cases in contexts like this:  *)
110
let _ =
let _ =
111
  assert (foo (bar + baz
  assert (foo (bar + baz
112
               <= quux))                (* lined up under left argument to op,
               <= quux))                (* lined up under left argument to op,
113
                                           sim. to ^ above *)
                                           sim. to ^ above *)
114
(* Sim. indentation of if conditions: *)
(* Sim. indentation of if conditions: *)
115
let _ =
let _ =
116
  if (a
  if (a
117
      <= b)
      <= b)
118
  then ()
  then ()
119
let _ =
let _ =
120
  (* Comparisons are different than conditionals; we don't regard them as
  (* Comparisons are different than conditionals; we don't regard them as
121
     conceptually part of the [if] expression. *)
     conceptually part of the [if] expression. *)
122
  if a
  if a
123
     <= b
     <= b
124
  then ()
  then ()
125
let _ =
let _ =
126
  (* We regard the outermost condition terms as conceptually part of the [if]
  (* We regard the outermost condition terms as conceptually part of the [if]
127
     expression and indent accordingly.  Whether [&&] or [||], conditionals
     expression and indent accordingly.  Whether [&&] or [||], conditionals
128
     effectively state lists of conditions for [then]. *)
     effectively state lists of conditions for [then]. *)
129
  if Edge_adjustment.is_zero arb.cfg.extra_edge
  if Edge_adjustment.is_zero arb.cfg.extra_edge
130
  && 0. = sys.plugs.edge_backoff
  && 0. = sys.plugs.edge_backoff
131
  && 0. = zero_acvol_edge_backoff
  && 0. = zero_acvol_edge_backoff
132
  then 0.
  then 0.
133
  else 1.
  else 1.
134
let _ =
let _ =
135
  if
  if
136
    Edge_adjustment.is_zero arb.cfg.extra_edge
    Edge_adjustment.is_zero arb.cfg.extra_edge
137
    && 0. = sys.plugs.edge_backoff
    && 0. = sys.plugs.edge_backoff
138
    && 0. = zero_acvol_edge_backoff
    && 0. = zero_acvol_edge_backoff
139
  then 0.
  then 0.
140
  else 1.
  else 1.
141
let _ =
let _ =
142
  let entries = List.filter (Lazy.force transferstati) ~f:(fun ts ->
  let entries = List.filter (Lazy.force transferstati) ~f:(fun ts ->
143
    Pcre.pmatch ~pat ts.RQ.description
    Pcre.pmatch ~pat ts.RQ.description
144
  ) in
  ) in
145
  x
  x
146
147
(* combination of operator at BOL and -> at EOL: *)
(* combination of operator at BOL and -> at EOL: *)
148
let _ =
let _ =
149
  Shell.ssh_lines x
  Shell.ssh_lines x
150
  |! List.map ~f:(f (g (fun x ->
  |! List.map ~f:(f (g (fun x ->
151
·······let·name,·path·=·String.lsplit2_exn·~on:'|'·x·in
····let·name,·path·=·String.lsplit2_exn·~on:'|'·x·in
152
·······String.strip·name,·String.strip·path)))
····String.strip·name,·String.strip·path)))
153
154
(* open paren ending line like begin *)
(* open paren ending line like begin *)
155
let _ =
let _ =
156
  if a (p ^/ "s") [ e ] = Ok () then `S (
  if a (p ^/ "s") [ e ] = Ok () then `S (
157
    let label count =
    let label count =
158
      sprintf "%d s" c ^ if c = 1 then ":" else "s"
      sprintf "%d s" c ^ if c = 1 then ":" else "s"
159
    in
    in
160
    x
    x
161
  )
  )

Differences in js-begin.ml

ExpectedOcp-indent output
0
let f = function
let f = function
1
  | zoo -> begin
  | zoo -> begin
2
      foo;
      foo;
3
      bar;
      bar;
4
    end
    end
5
;;
;;
6
let g = function
let g = function
7
  | zoo -> (
  | zoo -> (
8
      foo;
      foo;
9
      bar;
      bar;
10
    )
    )
11
;;
;;
12
let () =
let () =
13
  begin match foo with
  begin match foo with
14
········|·Bar·->·snoo
··|·Bar·->·snoo
15
  end
  end
16
;;
;;

Differences in js-fun.ml

ExpectedOcp-indent output
0
(* preferred list style *)
(* preferred list style *)
1
let z =
let z =
2
  f
  f
3
    [ y
    [ y
4
    ; foo ~f:(fun () ->
    ; foo ~f:(fun () ->
5
        arg)
        arg)
6
    ]
    ]
7
;;
;;
8
let z =
let z =
9
  f
  f
10
    [ y
    [ y
11
    ; foo ~f:(fun () ->
    ; foo ~f:(fun () ->
12
        arg
        arg
13
      )
      )
14
    ]
    ]
15
;;
;;
16
17
(* legacy list style *)
(* legacy list style *)
18
let _ =
let _ =
19
  [ f (fun x ->
  [ f (fun x ->
20
      x);
      x);
21
    f (fun x ->
    f (fun x ->
22
      x);
      x);
23
    f (fun x ->
    f (fun x ->
24
      x);
      x);
25
  ]
  ]
26
let _ =
let _ =
27
  [ f (fun x ->
  [ f (fun x ->
28
      x
      x
29
    );
    );
30
    f (fun x ->
    f (fun x ->
31
      x
      x
32
    );
    );
33
    f (fun x ->
    f (fun x ->
34
      x
      x
35
    );
    );
36
  ]
  ]
37
;;
;;
38
let _ =
let _ =
39
  [f (fun x ->
  [f (fun x ->
40
     x
     x
41
   );
   );
42
   f (fun x ->
   f (fun x ->
43
     x
     x
44
   );
   );
45
   f (fun x ->
   f (fun x ->
46
     x
     x
47
   );
   );
48
  ]
  ]
49
;;
;;
50
51
let _ =
let _ =
52
  x
  x
53
  >>= fun x ->
  >>= fun x ->
54
  (try x with _ -> ())
  (try x with _ -> ())
55
  >>= fun x ->
  >>= fun x ->
56
  try x with _ -> ()
  try x with _ -> ()
57
    >>= fun x ->
    >>= fun x ->
58
    x
    x
59
;;
;;
60
61
let () =
let () =
62
  expr
  expr
63
  >>| function
  >>| function
64
  | x -> 3
  | x -> 3
65
  | y -> 4
  | y -> 4
66
;;
;;
67
68
let () =
let () =
69
  expr
  expr
70
  >>| fun z -> match z with
  >>| fun z -> match z with
71
···············|·x·->·3
··|·x·->·3
72
···············|·y·->·4
··|·y·->·4
73
;;
;;
74
75
let () =
let () =
76
  expr
  expr
77
  >>| fun z -> function
  >>| fun z -> function
78
  | x -> 3
  | x -> 3
79
  | y -> 4
  | y -> 4
80
;;
;;
81
82
let () =
let () =
83
  my_func () >>= function
  my_func () >>= function
84
  | A -> 0
  | A -> 0
85
  | B -> 0
  | B -> 0
86
;;
;;
87
88
let () =
let () =
89
  my_func () >>= (function
  my_func () >>= (function
90
    | A -> 0
    | A -> 0
91
    | B -> 0)
    | B -> 0)
92
;;
;;
93
94
let () =
let () =
95
  expr
  expr
96
  >>| function
  >>| function
97
  | x -> 3
  | x -> 3
98
  | y -> 4
  | y -> 4
99
;;
;;
100
101
let () =
let () =
102
  expr
  expr
103
  >>| (function
  >>| (function
104
    | x -> 3
    | x -> 3
105
    | y -> 4)
    | y -> 4)
106
;;
;;
107
108
109
110
let f =
let f =
111
  f >>= m (fun f ->
  f >>= m (fun f ->
112
    fun x ->
    fun x ->
113
      y);
      y);
114
  z
  z
115
;;
;;
116
117
let f =
let f =
118
  f
  f
119
  |> m (fun f ->
  |> m (fun f ->
120
    fun x ->
    fun x ->
121
      y
      y
122
  );
  );
123
  z
  z
124
;;
;;
125
let f =
let f =
126
  f
  f
127
  |> m (fun f ->
  |> m (fun f ->
128
    fun x ->
    fun x ->
129
      y);
      y);
130
  z
  z
131
;;
;;

Differences in js-functor.ml

ExpectedOcp-indent output
0
module M =
module M =
1
  Foo (G)
  Foo (G)
2
    (H)
    (H)
3
4
module M =
module M =
5
  Foo
  Foo
6
    (G)
    (G)
7
    (struct
    (struct
8
      let x
      let x
9
    end)
    end)
10
    (H)
    (H)
11
12
(* To me, this looks fine as it is.  The rule seems fine as "indent arguments by
(* To me, this looks fine as it is.  The rule seems fine as "indent arguments by
13
   2".  To illustrate, with a case where the functor name is longer: *)
   2".  To illustrate, with a case where the functor name is longer: *)
14
module M =
module M =
15
  Functor (G)
  Functor (G)
16
    (H)
    (H)
17
    (I)
    (I)
18
19
20
21
include Foo (struct
include Foo (struct
22
    let x
    let x
23
  end) (struct
  end) (struct
24
    let y
    let y
25
  end)
  end)
26
27
include
include
28
  Foo (struct
  Foo (struct
29
······let·x
····let·x
30
····end)·(struct
··end)·(struct
31
······let·y
····let·y
32
····end)
··end)
33
34
include
include
35
  Foo
  Foo
36
    (struct
    (struct
37
      let x
      let x
38
    end) (struct
    end) (struct
39
······let·y
····let·y
40
····end)
··end)
41
42
include Persistent.Make
include Persistent.Make
43
··(struct·let·version·=·1·end)
····(struct·let·version·=·1·end)
44
··(Stable.Cr_soons_or_pending.V1)
····(Stable.Cr_soons_or_pending.V1)
45
46
include Persistent.Make
include Persistent.Make
47
··(struct
····(struct
48
····let·version·=·1
······let·version·=·1
49
··end)
····end)
50
··(Stable.Cr_soons_or_pending.V1)
····(Stable.Cr_soons_or_pending.V1)
51
52
include
include
53
  Persistent.Make
  Persistent.Make
54
    (struct let version = 1 end)
    (struct let version = 1 end)
55
    (Stable.Cr_soons_or_pending.V1)
    (Stable.Cr_soons_or_pending.V1)
56
57
include
include
58
  Persistent.Make
  Persistent.Make
59
    (struct
    (struct
60
      let version = 1
      let version = 1
61
    end)
    end)
62
    (Stable.Cr_soons_or_pending.V1)
    (Stable.Cr_soons_or_pending.V1)
63
64
module M =
module M =
65
  Foo (struct
  Foo (struct
66
······let·x
····let·x
67
····end)·(struct
··end)·(struct
68
······let·y
····let·y
69
····end)
··end)
70
71
module M : S =
module M : S =
72
  Make (M)
  Make (M)
73
module M : S with type t := int =
module M : S with type t := int =
74
  Make (M)
  Make (M)
75
76
77
78
module Simple_command(Arg:sig
module Simple_command(Arg:sig
79
  end) = struct end
  end) = struct end
80
81
module Simple_command(Arg : sig
module Simple_command(Arg : sig
82
  end) = struct end
  end) = struct end
83
84
module Simple_command (Arg:sig
module Simple_command (Arg:sig
85
  end) = struct end
  end) = struct end
86
87
module Simple_command (Arg : sig
module Simple_command (Arg : sig
88
  end) = struct end
  end) = struct end
89
90
module Simple_command
module Simple_command
91
··(Arg·:·sig
····(Arg·:·sig
92
···end)·=·struct·end
·····end)·=·struct·end

Differences in js-pattern.ml

ExpectedOcp-indent output
0
let f = function
let f = function
1
  | _ -> 0
  | _ -> 0
2
;;
;;
3
4
let f x = match x with
let f x = match x with
5
··········|·_·->·0
··|·_·->·0
6
;;
;;
7
8
let f =
let f =
9
  function
  function
10
  | _ -> 0
  | _ -> 0
11
;;
;;
12
13
let f x =
let f x =
14
  match x with
  match x with
15
  | _ -> 0
  | _ -> 0
16
;;
;;
17
18
let f x =
let f x =
19
  begin match x with
  begin match x with
20
········|·_·->·0
··|·_·->·0
21
  end
  end
22
;;
;;
23
24
let check_price t = function
let check_price t = function
25
  | { Exec.
  | { Exec.
26
      trade_at_settlement = (None | Some false);
      trade_at_settlement = (None | Some false);
27
    } -> ()
    } -> ()
28
29
let check_price t = function
let check_price t = function
30
  | simpler -> ()
  | simpler -> ()
31
  | other -> ()
  | other -> ()
32
33
(* Sometimes we like to write big alternations like this, in which case the
(* Sometimes we like to write big alternations like this, in which case the
34
   comment should typically align with the following clause. *)
   comment should typically align with the following clause. *)
35
let 0 =
let 0 =
36
  match x with
  match x with
37
  | A
  | A
38
    (* a *)
    (* a *)
39
    -> a
    -> a
40
let 0 =
let 0 =
41
  match x with
  match x with
42
    A
    A
43
    (* a *)
    (* a *)
44
    -> a
    -> a
45
46
let _ =
let _ =
47
  a
  a
48
  || match a with
  || match a with
49
·····|·a·->·true
··|·a·->·true
50
·····|·b·->·false
··|·b·->·false

Differences in js-record.ml

ExpectedOcp-indent output
0
type x =
type x =
1
  { foo : int
  { foo : int
2
  ; bar : int
  ; bar : int
3
  }
  }
4
5
let x =
let x =
6
  { x with
  { x with
7
    foo = 3
    foo = 3
8
  ; bar = 5
  ; bar = 5
9
  }
  }
10
11
let x =
let x =
12
  { (* blah blah blah *)
  { (* blah blah blah *)
13
    foo = 3
    foo = 3
14
  ; bar = 5
  ; bar = 5
15
  }
  }
16
;;
;;
17
18
let x =
let x =
19
  [{ x with
  [{ x with
20
     foo = 3
     foo = 3
21
   ; bar = 5
   ; bar = 5
22
   }]
   }]
23
24
let x =
let x =
25
  [{ (* blah blah blah *)
  [{ (* blah blah blah *)
26
·····foo·=·3
····foo·=·3
27
···;·bar·=·5
··;·bar·=·5
28
···}]
··}]
29
;;
;;
30
31
let x =
let x =
32
  { M.x with
  { M.x with
33
    M.
    M.
34
    foo = 3
    foo = 3
35
  }
  }
36
;;
;;
37
38
let x =
let x =
39
  { x with
  { x with
40
    M.
    M.
41
    foo = 3
    foo = 3
42
  }
  }
43
;;
;;
44
45
let x =
let x =
46
  { M.
  { M.
47
    foo = 3
    foo = 3
48
  }
  }
49
;;
;;
50
51
let _ =
let _ =
52
  { foo with
  { foo with
53
    Bar.
    Bar.
54
    field1 = value1
    field1 = value1
55
  ; field2 = value2
  ; field2 = value2
56
  }
  }
57
;;
;;
58
let _ =
let _ =
59
  { foo
  { foo
60
    with Bar.
    with Bar.
61
····field1·=·value1
······field1·=·value1
62
··;·field2·=·value2
····;·field2·=·value2
63
  }
  }
64
;;
;;
65
66
(* multicomponent record module pathname *)
(* multicomponent record module pathname *)
67
let _ =
let _ =
68
  { A.B.
  { A.B.
69
    a = b
    a = b
70
  ; c = d
  ; c = d
71
  }
  }
72
;;
;;

Differences in js-syntax.ml

ExpectedOcp-indent output
0
(* s *)
(* s *)
1
2
let _ =
let _ =
3
  [%raise_structural_sexp
  [%raise_structural_sexp
4
    "feature's tip is already an ancestor of new base"
    "feature's tip is already an ancestor of new base"
5
····{·feature_tip·=·(old_tip·:·Rev.t)
······{·feature_tip·=·(old_tip·:·Rev.t)
6
····;·new_base····=·(new_base·:·Rev.t)
······;·new_base····=·(new_base·:·Rev.t)
7
····}]
······}]
8
9
let _ =
let _ =
10
  [%raise_structural_sexp "feature's tip is already an ancestor of new base"
  [%raise_structural_sexp "feature's tip is already an ancestor of new base"
11
····{·feature_tip·=·(old_tip·:·Rev.t)
····························{·feature_tip·=·(old_tip·:·Rev.t)
12
····;·new_base····=·(new_base·:·Rev.t)
····························;·new_base····=·(new_base·:·Rev.t)
13
····}
····························}
14
  ]
  ]

Differences in js-to-do.ml

ExpectedOcp-indent output
0
(* Indentation that Jane Street needs to think about and make precise.
(* Indentation that Jane Street needs to think about and make precise.
1
2
   These are long term ideas, possibly even conflicting with other tests. *)
   These are long term ideas, possibly even conflicting with other tests. *)
3
4
5
6
(* js-args *)
(* js-args *)
7
8
let _ =
let _ =
9
  let min_closing_backoff =
  let min_closing_backoff =
10
    -. (   Hidden_float.expose (arb.cfg.base_edge @! Buy)
    -. (   Hidden_float.expose (arb.cfg.base_edge @! Buy)
11
········+.·Hidden_float.expose·(arb.cfg.base_edge·@!·Sell))
···········+.·Hidden_float.expose·(arb.cfg.base_edge·@!·Sell))
12
  in
  in
13
  0
  0
14
15
16
17
(* js-type *)
(* js-type *)
18
19
(* The following tests incorporate several subtle and different indentation
(* The following tests incorporate several subtle and different indentation
20
   ideas.  Please consider this only a proposal for discussion, for now.
   ideas.  Please consider this only a proposal for discussion, for now.
21
22
   First, notice the display treatment of "(,)" tuples, analogous to "[;]"
   First, notice the display treatment of "(,)" tuples, analogous to "[;]"
23
   lists.  While "(,)" is an intensional combination of "()" and ",", unlike
   lists.  While "(,)" is an intensional combination of "()" and ",", unlike
24
   "[;]" lists, we believe "(,)" isn't too big a departure.  Value expression
   "[;]" lists, we believe "(,)" isn't too big a departure.  Value expression
25
   analogies are included in js-type.ml, (meant to be) consistent with the
   analogies are included in js-type.ml, (meant to be) consistent with the
26
   proposed type indentation.
   proposed type indentation.
27
28
   Second, and more divergently, the proposed indentation of function types is
   Second, and more divergently, the proposed indentation of function types is
29
   based on the idea of aligning the arguments, even the first argument, even
   based on the idea of aligning the arguments, even the first argument, even
30
   where that means automatically inserting spaces within lines.  This applies
   where that means automatically inserting spaces within lines.  This applies
31
   to the extra spaces in ":__unit" and "(____Config.Network.t" below.
   to the extra spaces in ":__unit" and "(____Config.Network.t" below.
32
33
   We believe this fits into a more general incorporation of alignment into
   We believe this fits into a more general incorporation of alignment into
34
   ocp-indent, to replace our internal alignment tool with a syntax-aware one.
   ocp-indent, to replace our internal alignment tool with a syntax-aware one.
35
   We like to align things for readability, like big records, record types,
   We like to align things for readability, like big records, record types,
36
   lists used to build tables, etc.
   lists used to build tables, etc.
37
38
   The proposal also includes indenting "->" in the circumstances below relative
   The proposal also includes indenting "->" in the circumstances below relative
39
   to the enclosing "()", by two spaces.  In a sense, this happens first, and
   to the enclosing "()", by two spaces.  In a sense, this happens first, and
40
   then the first argument is aligned accordingly.  So, there's no manual
   then the first argument is aligned accordingly.  So, there's no manual
41
   indentation or spacing below. *)
   indentation or spacing below. *)
42
43
val instances
val instances
44
  :  unit
  :  unit
45
  -> (    Config.Network.t
  -> (    Config.Network.t
46
·······->·(App.t·*·Config.instance·*·Config.app)·list
··········->·(App.t·*·Config.instance·*·Config.app)·list
47
·······->·verbose:bool
··········->·verbose:bool
48
·······->·'m
··········->·'m
49
     , 'm
     , 'm
50
     ) Command.Spec.t
     ) Command.Spec.t
51
52
val instances
val instances
53
  :  unit
  :  unit
54
  -> (    Config.Network.t
  -> (    Config.Network.t
55
·······->·(App.t·*·Config.instance·*·Config.app)·list
··········->·(App.t·*·Config.instance·*·Config.app)·list
56
·······->·verbose:bool·->·'m
··········->·verbose:bool·->·'m
57
     , 'm
     , 'm
58
     ) Command.Spec.t
     ) Command.Spec.t
59
60
(* presumed analog with stars *)
(* presumed analog with stars *)
61
val instances :
val instances :
62
  unit
  unit
63
  * (   Config.Network.t
  * (   Config.Network.t
64
······*·(App.t·*·Config.instance·*·Config.app)·list
········*·(App.t·*·Config.instance·*·Config.app)·list
65
······*·bool
········*·bool
66
······*·'m
········*·'m
67
    , 'm
    , 'm
68
    ) Command.Spec.t
    ) Command.Spec.t

Differences in js-upon.ml

ExpectedOcp-indent output
0
let f x =
let f x =
1
  stop
  stop
2
  (* We don't do this as a matter of style, but the indentation reveals a common
  (* We don't do this as a matter of style, but the indentation reveals a common
3
     mistake. *)
     mistake. *)
4
  >>> fun () -> don't_wait_for (close fd);
  >>> fun () -> don't_wait_for (close fd);
5
················bind·fd
··bind·fd
6
7
let f x =
let f x =
8
  stop
  stop
9
  (* This is what was intended, which is indented correctly, although it's bad
  (* This is what was intended, which is indented correctly, although it's bad
10
     style on my part. *)
     style on my part. *)
11
  >>> (fun () -> don't_wait_for (close fd));
  >>> (fun () -> don't_wait_for (close fd));
12
  bind
  bind

Differences in list_of_funs.ml

ExpectedOcp-indent output
0
let f x =
let f x =
1
  (fun x -> x [ (fun () -> 3) ;
  (fun x -> x [ (fun () -> 3) ;
2
                (fun () -> 4) ])
                (fun () -> 4) ])
3
4
let f x = (fun x -> x [ (fun () -> 3) ;
let f x = (fun x -> x [ (fun () -> 3) ;
5
                        (fun () -> 4) ])
                        (fun () -> 4) ])
6
7
let f x =
let f x =
8
  x [ (fun () -> 3) ;
  x [ (fun () -> 3) ;
9
      (fun () -> 4) ]
      (fun () -> 4) ]
10
11
let f x =
let f x =
12
  [ (fun () -> 3) ;
  [ (fun () -> 3) ;
13
    (fun () -> 4) ]
    (fun () -> 4) ]
14
15
let f x =
let f x =
16
  (fun x -> x [ (fun () ->
  (fun x -> x [ (fun () ->
17
···················3)·;
·······3)·;
18
················(fun·()·->·4)·])
·······(fun·()·->·4)·])
19
20
let f x = (fun x -> x [ (fun () ->
let f x = (fun x -> x [ (fun () ->
21
···························3)·;
····3)·;
22
························(fun·()·->·4)·])
····(fun·()·->·4)·])
23
24
let f x =
let f x =
25
  x [ (fun () ->
  x [ (fun () ->
26
·········3)·;
······3)·;
27
      (fun () -> 4) ]
      (fun () -> 4) ]
28
29
let f x =
let f x =
30
  [ (fun () ->
  [ (fun () ->
31
·······3)·;
········3)·;
32
    (fun () -> 4) ]
    (fun () -> 4) ]
ocp-indent-1.5.3/tests/failing/000077500000000000000000000000001273277264100163465ustar00rootroot00000000000000ocp-indent-1.5.3/tests/failing/edge-cases.ml000066400000000000000000000026111273277264100207000ustar00rootroot00000000000000 (* this could be fixed, but we actually want to handle the first case differently for when there is only one case (see next examples) *) let f x = function A -> x; 2 | B -> y; 3 (* if we were to fix to the case above, the second >>= would be below the _ (test taken from js-fun) *) let _ = x >>= fun x -> try x with _ -> () >>= fun x -> x (* (and also: the some_handling here would be below Not_found) *) let _ = try _ with Not_found -> some_handling let f = fun x -> x let f = (fun x -> x ) let f g = g @@ fun x -> x let f g = g @@ (fun x -> x ) (* the above should probably be consistent with: *) let f x y = y + match x with A -> 0 let f x y = y + (match x with A -> 0 ) (* wich means we may over-indent even when the block is non-closable *) let f x y = y + match x with | A -> 0 let f x y = y + (match x with | A -> 0 ) let f x y = y + match x with | A -> 0 let _ = somefun (fun x -> x); somefun (if bla then bli); somefun (if bla then bli else blu) let _ = a ; b (* Surprisingly, this is the indentation correpsonding to OCaml's interpretation of this code. Indenting this accordingly may help users notice that they're doing something dubious. *) let b = `b let d = `d ;; let a = b function (_ : [ `c ]) -> d ;; ocp-indent-1.5.3/tests/failing/escaped-nl.ml000066400000000000000000000011241273277264100207110ustar00rootroot00000000000000let s1 = "No field 'install', but a field 'remove': install instructions \ probably part of 'build'. Use the 'install' field or a .install \ file" let x = cond 40 `Warning "Package uses flags that aren't recognised by earlier versions in \ OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ instead for compatibility" ~detail:alpha_flags (alpha_flags <> []) let s2 = "bla bla bli bli \ blo" let s3 = "\ " let s4 = " \ " let s5 = " \ \ " let s6 = " " let s7 = " " let c1 = ' ' let x1 = f x ' ' y z let zz = "\ s \ \ " ocp-indent-1.5.3/tests/failing/escaped-nl.ml.ref000066400000000000000000000011761273277264100214730ustar00rootroot00000000000000let s1 = "No field 'install', but a field 'remove': install instructions \ probably part of 'build'. Use the 'install' field or a .install \ file" let x = cond 40 `Warning "Package uses flags that aren't recognised by earlier versions in \ OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ instead for compatibility" ~detail:alpha_flags (alpha_flags <> []) let s2 = "bla bla bli bli \ blo" let s3 = "\ " let s4 = " \ " let s5 = " \ \ " let s6 = " " let s7 = " " let c1 = ' ' let x1 = f x ' ' y z let zz = "\ s \ \ " ocp-indent-1.5.3/tests/failing/js-args.ml000066400000000000000000000074261273277264100202570ustar00rootroot00000000000000let () = foo.bar <- f x y z let should_check_can_sell_and_marking regulatory_regime = match z with | `foo -> some_function argument (* The above typically occurs in a multi-pattern match clause, so the clause expression is on a line by itself. This is the more typical way a long single-pattern match clause would be written: *) let should_check_can_sell_and_marking regulatory_regime = match z with | `foo -> some_function argument let f = fun x -> ghi x (* common *) let x = try x with | a -> b | c -> d let x = try x with | a -> b | c -> d let x = try x with | a -> b | c -> d let z = some_function argument let () = f a b ~c:c d let () = f a b ~c:1. d let () = My_module.f a b ~c:c d (* This last case is where Tuareg is inconsistent with the others. *) let () = My_module.f a b ~c:1. d let () = messages := Message_store.create (Session_id.of_string "") (* Tuareg indents these lines too far to the left. *) "herd-retransmitter" Message_store.Message_size.Byte let () = raise (Bug ("foo" (* In this and similar cases, we want the subsequent lines to align with the first expression. *) ^ "bar")); raise (Bug ("foo" ^ "quux" ^ "bar")); raise (Bug (foo + quux ^ "bar")); raise (Bug ((foo + quux) ^ "bar")) (* Except in specific cases, we want the argument indented relative to the function being called. (Exceptions include "fun" arguments where the line ends with "->" and subsequent lines beginning with operators, like above.) *) let () = Some (Message_store.create s "herd-retransmitter" ~unlink:true Message_store.Message_size.Byte) (* We like the indentation of most arguments, but want to get back towards the left margin in a few special cases: *) let _ = foo (bar (fun x -> (* special: "fun _ ->" at EOL *) baz)) (* assume no more arguments to "bar" *) let _ = foo ~a_long_field_name:(check (fun bar -> baz)) let _ = foo ~a_long_field_name:(check (fun bar -> baz)) let _ = foo (bar (quux (fnord (fun x -> (* any depth *) baz)))) (* We also wanted to tweak the operator indentation, making operators like <= not special cases in contexts like this: *) let _ = assert (foo (bar + baz <= quux)) (* lined up under left argument to op, sim. to ^ above *) (* Sim. indentation of if conditions: *) let _ = if (a <= b) then () let _ = (* Comparisons are different than conditionals; we don't regard them as conceptually part of the [if] expression. *) if a <= b then () let _ = (* We regard the outermost condition terms as conceptually part of the [if] expression and indent accordingly. Whether [&&] or [||], conditionals effectively state lists of conditions for [then]. *) if Edge_adjustment.is_zero arb.cfg.extra_edge && 0. = sys.plugs.edge_backoff && 0. = zero_acvol_edge_backoff then 0. else 1. let _ = if Edge_adjustment.is_zero arb.cfg.extra_edge && 0. = sys.plugs.edge_backoff && 0. = zero_acvol_edge_backoff then 0. else 1. let _ = let entries = List.filter (Lazy.force transferstati) ~f:(fun ts -> Pcre.pmatch ~pat ts.RQ.description ) in x (* combination of operator at BOL and -> at EOL: *) let _ = Shell.ssh_lines x |! List.map ~f:(f (g (fun x -> let name, path = String.lsplit2_exn ~on:'|' x in String.strip name, String.strip path))) (* open paren ending line like begin *) let _ = if a (p ^/ "s") [ e ] = Ok () then `S ( let label count = sprintf "%d s" c ^ if c = 1 then ":" else "s" in x ) ocp-indent-1.5.3/tests/failing/js-args.ml.opts000066400000000000000000000000161273277264100212270ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-begin.ml000066400000000000000000000002771273277264100204040ustar00rootroot00000000000000let f = function | zoo -> begin foo; bar; end ;; let g = function | zoo -> ( foo; bar; ) ;; let () = begin match foo with | Bar -> snoo end ;; ocp-indent-1.5.3/tests/failing/js-begin.ml.opts000066400000000000000000000000161273277264100213570ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-fun.ml000066400000000000000000000023431273277264100201040ustar00rootroot00000000000000(* preferred list style *) let z = f [ y ; foo ~f:(fun () -> arg) ] ;; let z = f [ y ; foo ~f:(fun () -> arg ) ] ;; (* legacy list style *) let _ = [ f (fun x -> x); f (fun x -> x); f (fun x -> x); ] let _ = [ f (fun x -> x ); f (fun x -> x ); f (fun x -> x ); ] ;; let _ = [f (fun x -> x ); f (fun x -> x ); f (fun x -> x ); ] ;; let _ = x >>= fun x -> (try x with _ -> ()) >>= fun x -> try x with _ -> () >>= fun x -> x ;; let () = expr >>| function | x -> 3 | y -> 4 ;; let () = expr >>| fun z -> match z with | x -> 3 | y -> 4 ;; let () = expr >>| fun z -> function | x -> 3 | y -> 4 ;; let () = my_func () >>= function | A -> 0 | B -> 0 ;; let () = my_func () >>= (function | A -> 0 | B -> 0) ;; let () = expr >>| function | x -> 3 | y -> 4 ;; let () = expr >>| (function | x -> 3 | y -> 4) ;; let f = f >>= m (fun f -> fun x -> y); z ;; let f = f |> m (fun f -> fun x -> y ); z ;; let f = f |> m (fun f -> fun x -> y); z ;; ocp-indent-1.5.3/tests/failing/js-fun.ml.opts000066400000000000000000000000161273277264100210630ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-functor.ml000066400000000000000000000024371273277264100210000ustar00rootroot00000000000000module M = Foo (G) (H) module M = Foo (G) (struct let x end) (H) (* To me, this looks fine as it is. The rule seems fine as "indent arguments by 2". To illustrate, with a case where the functor name is longer: *) module M = Functor (G) (H) (I) include Foo (struct let x end) (struct let y end) include Foo (struct let x end) (struct let y end) include Foo (struct let x end) (struct let y end) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) include Persistent.Make (struct let version = 1 end) (Stable.Cr_soons_or_pending.V1) module M = Foo (struct let x end) (struct let y end) module M : S = Make (M) module M : S with type t := int = Make (M) module Simple_command(Arg:sig end) = struct end module Simple_command(Arg : sig end) = struct end module Simple_command (Arg:sig end) = struct end module Simple_command (Arg : sig end) = struct end module Simple_command (Arg : sig end) = struct end ocp-indent-1.5.3/tests/failing/js-functor.ml.opts000066400000000000000000000000161273277264100217530ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-pattern.ml000066400000000000000000000012531273277264100207700ustar00rootroot00000000000000let f = function | _ -> 0 ;; let f x = match x with | _ -> 0 ;; let f = function | _ -> 0 ;; let f x = match x with | _ -> 0 ;; let f x = begin match x with | _ -> 0 end ;; let check_price t = function | { Exec. trade_at_settlement = (None | Some false); } -> () let check_price t = function | simpler -> () | other -> () (* Sometimes we like to write big alternations like this, in which case the comment should typically align with the following clause. *) let 0 = match x with | A (* a *) -> a let 0 = match x with A (* a *) -> a let _ = a || match a with | a -> true | b -> false ocp-indent-1.5.3/tests/failing/js-pattern.ml.opts000066400000000000000000000000161273277264100217500ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-record.ml000066400000000000000000000012121273277264100205640ustar00rootroot00000000000000type x = { foo : int ; bar : int } let x = { x with foo = 3 ; bar = 5 } let x = { (* blah blah blah *) foo = 3 ; bar = 5 } ;; let x = [{ x with foo = 3 ; bar = 5 }] let x = [{ (* blah blah blah *) foo = 3 ; bar = 5 }] ;; let x = { M.x with M. foo = 3 } ;; let x = { x with M. foo = 3 } ;; let x = { M. foo = 3 } ;; let _ = { foo with Bar. field1 = value1 ; field2 = value2 } ;; let _ = { foo with Bar. field1 = value1 ; field2 = value2 } ;; (* multicomponent record module pathname *) let _ = { A.B. a = b ; c = d } ;; ocp-indent-1.5.3/tests/failing/js-record.ml.opts000066400000000000000000000000161273277264100215510ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-syntax.ml000066400000000000000000000005431273277264100206420ustar00rootroot00000000000000(* s *) let _ = [%raise_structural_sexp "feature's tip is already an ancestor of new base" { feature_tip = (old_tip : Rev.t) ; new_base = (new_base : Rev.t) }] let _ = [%raise_structural_sexp "feature's tip is already an ancestor of new base" { feature_tip = (old_tip : Rev.t) ; new_base = (new_base : Rev.t) } ] ocp-indent-1.5.3/tests/failing/js-syntax.ml.opts000066400000000000000000000000161273277264100216210ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-to-do.ml000066400000000000000000000042401273277264100203340ustar00rootroot00000000000000(* Indentation that Jane Street needs to think about and make precise. These are long term ideas, possibly even conflicting with other tests. *) (* js-args *) let _ = let min_closing_backoff = -. ( Hidden_float.expose (arb.cfg.base_edge @! Buy) +. Hidden_float.expose (arb.cfg.base_edge @! Sell)) in 0 (* js-type *) (* The following tests incorporate several subtle and different indentation ideas. Please consider this only a proposal for discussion, for now. First, notice the display treatment of "(,)" tuples, analogous to "[;]" lists. While "(,)" is an intensional combination of "()" and ",", unlike "[;]" lists, we believe "(,)" isn't too big a departure. Value expression analogies are included in js-type.ml, (meant to be) consistent with the proposed type indentation. Second, and more divergently, the proposed indentation of function types is based on the idea of aligning the arguments, even the first argument, even where that means automatically inserting spaces within lines. This applies to the extra spaces in ":__unit" and "(____Config.Network.t" below. We believe this fits into a more general incorporation of alignment into ocp-indent, to replace our internal alignment tool with a syntax-aware one. We like to align things for readability, like big records, record types, lists used to build tables, etc. The proposal also includes indenting "->" in the circumstances below relative to the enclosing "()", by two spaces. In a sense, this happens first, and then the first argument is aligned accordingly. So, there's no manual indentation or spacing below. *) val instances : unit -> ( Config.Network.t -> (App.t * Config.instance * Config.app) list -> verbose:bool -> 'm , 'm ) Command.Spec.t val instances : unit -> ( Config.Network.t -> (App.t * Config.instance * Config.app) list -> verbose:bool -> 'm , 'm ) Command.Spec.t (* presumed analog with stars *) val instances : unit * ( Config.Network.t * (App.t * Config.instance * Config.app) list * bool * 'm , 'm ) Command.Spec.t ocp-indent-1.5.3/tests/failing/js-to-do.ml.opts000066400000000000000000000000161273277264100213150ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/js-upon.ml000066400000000000000000000005451273277264100202770ustar00rootroot00000000000000let f x = stop (* We don't do this as a matter of style, but the indentation reveals a common mistake. *) >>> fun () -> don't_wait_for (close fd); bind fd let f x = stop (* This is what was intended, which is indented correctly, although it's bad style on my part. *) >>> (fun () -> don't_wait_for (close fd)); bind ocp-indent-1.5.3/tests/failing/js-upon.ml.opts000066400000000000000000000000161273277264100212540ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/failing/list_of_funs.ml000066400000000000000000000011151273277264100213700ustar00rootroot00000000000000let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = x [ (fun () -> 3) ; (fun () -> 4) ] let f x = [ (fun () -> 3) ; (fun () -> 4) ] let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = (fun x -> x [ (fun () -> 3) ; (fun () -> 4) ]) let f x = x [ (fun () -> 3) ; (fun () -> 4) ] let f x = [ (fun () -> 3) ; (fun () -> 4) ] ocp-indent-1.5.3/tests/passing/000077500000000000000000000000001273277264100164015ustar00rootroot00000000000000ocp-indent-1.5.3/tests/passing/alignment.ml000066400000000000000000000007221273277264100207120ustar00rootroot00000000000000let file_contents = [ ] @ [ foo ] @ [ bar ] let _ = match s.src with | None -> [ zz ] + 2 | Some s -> [ Variable ( s_src, OpamFormat.make_string (OpamFilename.to_string s) ); yy ]; foo | Some s -> { fww = s_src, OpamFormat.make_string (OpamFilename.to_string s) ; gdd = yy } let _ = [ x; y ] @ z let _ = [ x; y ] @ z let _ = [ x; y ] @ z ocp-indent-1.5.3/tests/passing/bracket.ml000066400000000000000000000002241273277264100203440ustar00rootroot00000000000000let _ = match a with | b -> cccccc [ d [ e ] ] | b' -> (ccccc' [ d' [ e' ] ]) ocp-indent-1.5.3/tests/passing/comments.ml000066400000000000000000000006341273277264100205630ustar00rootroot00000000000000(* A *) type x = (* A *) | Foo (* B *) | Bar (* AA *) (* D *) let x = 3 module M = struct (* M1 *) let x = a (* M2 *) let y = b (* M3 *) (* M4 *) end let f x = if true then 0 (* comment *) else if false then 1 let g x = if true then 0 (* comment *) else if false then 1 let _ = f x (* bla *) y (* bla *) (z) (* ending comments *) ocp-indent-1.5.3/tests/passing/core-failing.ml000066400000000000000000000005751273277264100213010ustar00rootroot00000000000000exception IOError of int * exn module type S = S with type ('a, 'b, 'c) map := ('a, 'b, 'c) t let _ = let start_finaliser_thread () = ignore (Thread.create (fun () -> Fn.forever (fun () -> match read_finaliser_queue () with | None -> Thread.delay 1.0 | Some f -> Exn.handle_uncaught ~exit:false f)) ()) in () module F (A) (B) ocp-indent-1.5.3/tests/passing/core-passing.ml000066400000000000000000000057231273277264100213340ustar00rootroot00000000000000type t1 = { a: int; b: int -> int; c: int; } let try_lock t = wrap_mutex a.b (fun () -> was_locked) let blit_string_bigstring ~src ?src_pos ?src_len ~dst ?dst_pos () = blit_common ~get_src_len:String.length ~get_dst_len:length ~blit:unsafe_blit_string_bigstring ~src ?src_pos ?src_len ~dst ?dst_pos () let f = test bla Int32.to_string pack_signed_32 module S : S1 with type t = S1.t with type comparator = S.comparator let error_string message = error message () <:sexp_of< unit >> let unimplemented s = () let () = StdLabels.List.iter ~f:(fun (exc, handler) -> Conv.Exn_converter.add_auto ~finalise:false exc handler) () let _ = Date.to_string date :: " " :: (if is_utc then ["Z"] else bla) val v : t let _ = let module M = (val m : S with type t = t') in x let a,b,c = d type t = t0 = { a: int; } type t2 = [ | `a | `b ] type t = private | A | B module Make : (S with type t = t') = struct type contents = C.t end module Map_and_set_binable = struct module C : (S with type t = t) val v end type compare = [`no_polymorphic_compare] -> [`no_polymorphic_compare] let _ = {Parts. sign = sign; hr = hr; } module M (A) : sig val bla : bla end = struct end val marshal_blit : ?flags : Marshal.extern_flags list -> 'a -> ?pos : int -> ?len : int -> t -> int let daemonize ?(redirect_stdout=`Dev_null) ?(redirect_stderr=`Dev_null) ?(cd = "/") ?umask:(umask_value = default_umask) () = bla val add : t -> (event -> Time.t -> unit) -> a let _ = match a with | A when b -> c | A b when b -> c module S : S1 with type t = S1.t with type comparator = S.comparator let _ = let f x = bla and g x = bli include struct exception Break = Break let y = 2 end let should_check_can_sell_and_marking regulatory_regime = match z with | `foo -> some_function argument; flu | `foo -> some_function argument; flu let _ = invalid_arg (sprintf "Dequeue.%s: index %i is not in [%d, %d]" fname i (front_index buf) (back_index buf)) let mem { ar; cmp } el = let len = Array.length ar in len > 0 && let rec loop pos = bla in blu let blit_to (type a) (blit : (Base.t, a) Blit.t) = (); fun t ~dst ~dst_pos -> blit ~src:t.base ~src_pos:t.pos ~src_len:t.len ~dst ~dst_pos () type 'a t = 'a Bin_prot.Type_class.writer = { size : 'a Size.sizer; write : 'a Write_ml.writer; unsafe_write : 'a Unsafe_write_c.writer; } let create ?(message = Pid.to_string (Unix.getpid ())) ?(close_on_exec=true) = xx module Make_using_comparator (Elt : Comparator.S) : S with type Elt.t = Elt.t with type Elt.comparator = Elt.comparator let _ = find_thread_count (In_channel.read_lines ("/proc/" ^ string_of_int (Unix.getpid ()) ^ "/status")) type variant = [ `Jan | `Feb | `Mar | `Apr | `May | `Jun | `Jul | `Aug | `Sep | `Oct | `Nov | `Dec ] ocp-indent-1.5.3/tests/passing/embedded-match.ml000066400000000000000000000007311273277264100215570ustar00rootroot00000000000000let f x = function | A when match x with A | B -> true | _ -> false -> B | A -> x | _ -> B let f x = if match x with | A -> true then 1 else 0 let f x = match x with | A -> true | B -> false | exception Not_found -> false | C -> true | exception (Failure _ | Invalid_argument _) -> true | exception (A | B) | exception B.Err | exception C.Types.Xxx "someparam" -> false exception MyExn of string ocp-indent-1.5.3/tests/passing/exprs.ml000066400000000000000000000017021273277264100200740ustar00rootroot00000000000000f "foo" g [ 1; 2] ;; let x = f 1 ((x 3) || (x f) lor (g lsl k) lor g && g lsr g) let f x = g (fun x -> x) [] x:x ?y:z () 0 let f ~p ~g () ?k () = let x = 0 in p let f = for i = 0 to 1; do a; b; done; x external f : 'a -> x : int -> t = "b" external g : x : t -> s : i -> d : t -> unit = "b2" let f ?(g = []) v ?(x = 0) ?l b = let l = g b ~p l in c ~l:"foo" b ~p ~l; u v ~p ~l b f let f () = g x y ?x:y ?y:w ~a:b let f () = f (fun () -> for i = 0 to 10 do g done; x ) external f: int -> int = "foo" let f () = for i = 0 to 10 do g done let f () = { x = 1; y = 2; } let f () = { x = 1; y = 2; } let f () = { x = 1; y = 2; } let f () = { x = 1 ; y = 2 } let f x = if x then x else f @@ fun () -> g; h ocp-indent-1.5.3/tests/passing/extensible.ml000066400000000000000000000006331273277264100210770ustar00rootroot00000000000000(* Simple declaration : OK *) type t = .. type t += A | B (* But : *) type t = .. type t += | A | B (* Inside modules : same pb *) module P = struct type t = .. type t += | A | B end module Q = struct type P.t += | C | D end (* another one *) module Q' = struct type P.t += | C = P.A | D end (* also *) module M = struct type t = .. let a = 1 let b = 2 end ocp-indent-1.5.3/tests/passing/gadt.ml000066400000000000000000000036261273277264100176610ustar00rootroot00000000000000type _ term = | Int : int -> int term | Add : (int -> int -> int) term | App : ('b -> 'a) term * 'b term -> 'a term let rec eval : type a. a term -> a = function | Int n -> n (* a = int *) | Add -> (fun x y -> x+y) (* a = int -> int -> int *) | App(f,x) -> (eval f) (eval x) (* eval called at types (b->a) and b for fresh b *) let two = eval (App (App (Add, Int 1), Int 1)) let rec sum : type a. a term -> _ = fun x -> let y = match x with | Int n -> n | Add -> 0 | App(f,x) -> sum f + sum x in y + 1 type _ typ = | Int : int typ | String : string typ | Pair : 'a typ * 'b typ -> ('a * 'b) typ let rec to_string: type t. t typ -> t -> string = fun t x -> match t with | Int -> string_of_int x | String -> Printf.sprintf "%S" x | Pair(t1,t2) -> let (x1, x2) = x in Printf.sprintf "(%s,%s)" (to_string t1 x1) (to_string t2 x2) type (_,_) eq = Eq : ('a,'a) eq let cast : type a b. (a,b) eq -> a -> b = fun Eq x -> x let rec eq_type : type a b. a typ -> b typ -> (a,b) eq option = fun a b -> match a, b with | Int, Int -> Some Eq | String, String -> Some Eq | Pair(a1,a2), Pair(b1,b2) -> begin match eq_type a1 b1, eq_type a2 b2 with | Some Eq, Some Eq -> Some Eq | _ -> None end | _ -> None type dyn = Dyn : 'a typ * 'a -> dyn let get_dyn : type a. a typ -> dyn -> a option = fun a (Dyn(b,x)) -> match eq_type a b with | None -> None | Some Eq -> Some x let _ = let f: type a. a list -> int = fun _x -> 42 in f [] let nth t n = if n < 0 then None else let rec nth_aux: type b. ('a, b) t -> int -> 'a option = fun t n -> match t with | Empty -> None | Node (a, t) -> if n = 0 then Some a else nth_aux t (n-1) in nth_aux t n let rec f : type a b. a = function | _ -> assert false and g : type a. a = function | _ -> assert false ocp-indent-1.5.3/tests/passing/ifand.ml000066400000000000000000000002611273277264100200130ustar00rootroot00000000000000let _ = if cond1 && cond2 then _ let _ = function | _ when x = 2 && y = 3 -> begin if a = b || b = c && c = d then _ end ocp-indent-1.5.3/tests/passing/indent-empty-1.ml000066400000000000000000000000771273277264100215120ustar00rootroot00000000000000module M = struct let f = end let g = fun x -> 3 + 4 * ocp-indent-1.5.3/tests/passing/indent-empty-1.ml.opts000066400000000000000000000000241273277264100224660ustar00rootroot00000000000000--lines 4 --numeric ocp-indent-1.5.3/tests/passing/indent-empty-1.ml.ref000066400000000000000000000000021273277264100222510ustar00rootroot000000000000004 ocp-indent-1.5.3/tests/passing/indent-empty-nm.ml000066400000000000000000000000771273277264100217640ustar00rootroot00000000000000module M = struct let f = end let g = fun x -> 3 + 4 * ocp-indent-1.5.3/tests/passing/indent-empty-nm.ml.opts000066400000000000000000000000311273277264100227360ustar00rootroot00000000000000--indent-empty --numeric ocp-indent-1.5.3/tests/passing/indent-empty-nm.ml.ref000066400000000000000000000000251273277264100225300ustar00rootroot000000000000000 2 2 4 0 0 0 2 2 15 ocp-indent-1.5.3/tests/passing/indent-empty.ml000066400000000000000000000000771273277264100213540ustar00rootroot00000000000000module M = struct let f = end let g = fun x -> 3 + 4 * ocp-indent-1.5.3/tests/passing/indent-empty.ml.opts000066400000000000000000000000171273277264100223320ustar00rootroot00000000000000--indent-empty ocp-indent-1.5.3/tests/passing/indent-empty.ml.ref000066400000000000000000000001261273277264100221220ustar00rootroot00000000000000module M = struct let f = end let g = fun x -> 3 + 4 * ocp-indent-1.5.3/tests/passing/js-and.ml000066400000000000000000000001321273277264100201030ustar00rootroot00000000000000module M : S with type a = b and type c = d and type e = f ;; ocp-indent-1.5.3/tests/passing/js-and.ml.opts000066400000000000000000000000161273277264100210700ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-andand.ml000066400000000000000000000003421273277264100205710ustar00rootroot00000000000000let all_equal = a = b && c = d && e = f (* this && should line up with previous one *) ;; (* '=' seems to be relevant here *) let _ = x && t.entity = entity && t.clearing_firm = clearing_firm && t.type_ = type_ ocp-indent-1.5.3/tests/passing/js-andand.ml.opts000066400000000000000000000000161273277264100215530ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-applicative.ml000066400000000000000000000001771273277264100216530ustar00rootroot00000000000000(* applicative_intf.ml *) let args = bar "A" @> baz "B" @> nil let args = bar "A" @> baz_qux @@ zap "D" @> nil ocp-indent-1.5.3/tests/passing/js-applicative.ml.opts000066400000000000000000000000161273277264100226270ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-bench.ml000066400000000000000000000023211273277264100204220ustar00rootroot00000000000000BENCH_FUN "Array.get (tuple)" = (* This is mis-indented only when BENCH_FUN is on the first line. *) let len = 300 in let arr = create ~len (1,2) in (fun () -> ignore(arr.(len-1))) BENCH_FUN "Array.set (tuple)" = let len = 300 in let arr = create ~len (1,2) in (fun () -> arr.(len-1) <- (3,4)) (* Some benchmarks of the blit operations *) BENCH_MODULE "Blit tests" = struct let lengths = [0; 10; 100; 1000; 10_000] BENCH_MODULE "Int" = struct BENCH_INDEXED "blit" len lengths = let src = create ~len 0 in let dst = create ~len 0 in (fun () -> Int.blit ~src ~src_pos:0 ~dst ~dst_pos:0 ~len) BENCH_INDEXED "blito" len lengths = let src = create ~len 0 in let dst = create ~len 0 in (fun () -> Int.blito ~src ~src_pos:0 ~dst ~dst_pos:0 ~src_len:len ()) end BENCH_MODULE "Float" = struct BENCH_INDEXED "blit" len lengths = let src = create ~len 0.0 in let dst = create ~len 0.0 in (fun () -> Float.blit ~src ~src_pos:0 ~dst ~dst_pos:0 ~len) BENCH_INDEXED "blito" len lengths = let src = create ~len 0.0 in let dst = create ~len 0.0 in (fun () -> Float.blito ~src ~src_pos:0 ~dst ~dst_pos:0 ~src_len:len ()) end end ocp-indent-1.5.3/tests/passing/js-bench.ml.opts000066400000000000000000000000161273277264100214050ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-bind.ml000066400000000000000000000011141273277264100202560ustar00rootroot00000000000000let assigned_to u = Deferred.List.filter (Request_util.requests ()) ~f:(fun request -> if _ then _ else status_request ~request () ~msg_client:no_msg >>= fun status -> not (up_to_date_user status u)) let old_good = foo bar qaz *>>= fun x -> hey ho lala *>>= fun y -> return (x,y) let old_good = foo bar qaz +>>= fun x -> hey ho lala +>>= fun y -> return (x,y) (* generalizations based on Tuareg code *) let old_good = foo bar qaz *>>| fun x -> hey ho lala *>>> fun y -> foo bar qaz +>>| fun x -> hey ho lala +>>> fun y -> return (x,y) ocp-indent-1.5.3/tests/passing/js-bind.ml.opts000066400000000000000000000000161273277264100212420ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-comment.ml000066400000000000000000000064401273277264100210130ustar00rootroot00000000000000(* ocp-indent is not going to be confused by comment-embedded tokens. *) type t = { (* This is a comment *) a: int; } type t = { (* This is a comment : with a colon. *) a: int; } type t = { a: int; (* with the : second field *) b: int; } type t = { a: int; b: int; (* and : the third... *) c: int; } (* colon in CR comment messes Tuareg up *) type cfg = { foo : int; (* ignore-CR someone: float? *) bar : string; } (* To be more precise about the Tuareg bug, it is the fact that the colon in the comment is the first or second colon after the start of the record definition. If the comment occurs after the first 2 fields in the record everything is fine. For example, this is OK: *) type t= { foo : int; bar : string; (* ignore-CR someone: float? *) baz : string; } (* but Tuareg messes this up *) type t= { foo : int; (* ignore-CR someone: float? *) bar : string; } (* Now that we have support for {v v} and {[ ]}, reindent inside comments, unless they are explicitly delimited as code or pre-formatted text. These three all end up flattened to the same level. *) (* type t = { (* This is a comment *) a: int; } *) (* type t = { (* This is a comment *) a: int; } *) (* type t = { (* This is a comment *) a: int; } *) (* Possible to-do warning: Star-prefixed lines are allowed and indented a little less, to line up with the star in the opening comment parenthesis. Maybe we don't care enough about them to worry about it, though. *) (** Doc comment text should be aligned with the first line, so indented more than otherwise. *) (* We're now using some ocamldoc block syntax to control indentation, and sweeks and the rest of us have been relying on it, in and out of doc comments. {[ let code = should be reindented like code so as to work also with vim ]} {v g This is totally verbatim text and shouldn't be reindented. It probably doesn't matter what the indentation of the first line of a verbatim block is. But how will this be done in vim? xx yy zz c v} Does this even confront ocp-indent? I think, when reindenting whole files, source code blocks do confront ocp-indent. *) (* {v (* comments embedded in verbatim sections *) (* want to be able to verbatim-out big chunks of code *) v} *) (* {v non-comments in verbatim sections duh v} *) module M = struct let x = 0 (* reference *) end module M = struct let () = () (* If there's a blank line before this, at least, shouldn't it revert to the block-level indentation, even if it doesn't precede a declaration? As long as the prior declaration is complete, I mean. If there isn't a blank line, I can see associating the comment with the line before. *) end module M = struct let () = () (* sim. *) end module M = struct let () = () (* no problem *) let () = () end val f : foo : int -> -> bar_snoo : a b (* this comment is in the wrong place *) -> unit val f : foo : int -> -> bar_snoo : a (* this comment is in the right place [under discussion] *) -> unit (* The only difference is the type "a b" instead of "a" for the labeled value bar_snoo. *) module M : sig val v : 'a t -> s -> 'a t (* ... *) end ocp-indent-1.5.3/tests/passing/js-comment.ml.opts000066400000000000000000000000161273277264100217700ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-comment.ml.ref000066400000000000000000000064201273277264100215640ustar00rootroot00000000000000(* ocp-indent is not going to be confused by comment-embedded tokens. *) type t = { (* This is a comment *) a: int; } type t = { (* This is a comment : with a colon. *) a: int; } type t = { a: int; (* with the : second field *) b: int; } type t = { a: int; b: int; (* and : the third... *) c: int; } (* colon in CR comment messes Tuareg up *) type cfg = { foo : int; (* ignore-CR someone: float? *) bar : string; } (* To be more precise about the Tuareg bug, it is the fact that the colon in the comment is the first or second colon after the start of the record definition. If the comment occurs after the first 2 fields in the record everything is fine. For example, this is OK: *) type t= { foo : int; bar : string; (* ignore-CR someone: float? *) baz : string; } (* but Tuareg messes this up *) type t= { foo : int; (* ignore-CR someone: float? *) bar : string; } (* Now that we have support for {v v} and {[ ]}, reindent inside comments, unless they are explicitly delimited as code or pre-formatted text. These three all end up flattened to the same level. *) (* type t = { (* This is a comment *) a: int; } *) (* type t = { (* This is a comment *) a: int; } *) (* type t = { (* This is a comment *) a: int; } *) (* Possible to-do warning: Star-prefixed lines are allowed and indented a little less, to line up with the star in the opening comment parenthesis. Maybe we don't care enough about them to worry about it, though. *) (** Doc comment text should be aligned with the first line, so indented more than otherwise. *) (* We're now using some ocamldoc block syntax to control indentation, and sweeks and the rest of us have been relying on it, in and out of doc comments. {[ let code = should be reindented like code so as to work also with vim ]} {v g This is totally verbatim text and shouldn't be reindented. It probably doesn't matter what the indentation of the first line of a verbatim block is. But how will this be done in vim? xx yy zz c v} Does this even confront ocp-indent? I think, when reindenting whole files, source code blocks do confront ocp-indent. *) (* {v (* comments embedded in verbatim sections *) (* want to be able to verbatim-out big chunks of code *) v} *) (* {v non-comments in verbatim sections duh v} *) module M = struct let x = 0 (* reference *) end module M = struct let () = () (* If there's a blank line before this, at least, shouldn't it revert to the block-level indentation, even if it doesn't precede a declaration? As long as the prior declaration is complete, I mean. If there isn't a blank line, I can see associating the comment with the line before. *) end module M = struct let () = () (* sim. *) end module M = struct let () = () (* no problem *) let () = () end val f : foo : int -> -> bar_snoo : a b (* this comment is in the wrong place *) -> unit val f : foo : int -> -> bar_snoo : a (* this comment is in the right place [under discussion] *) -> unit (* The only difference is the type "a b" instead of "a" for the labeled value bar_snoo. *) module M : sig val v : 'a t -> s -> 'a t (* ... *) end ocp-indent-1.5.3/tests/passing/js-comment1.ml000066400000000000000000000022261273277264100210720ustar00rootroot00000000000000type foo = int (* just in case *) (* These two shouldn't be indented differently, but are. *) type z = [ `Bar of foo (* a comment [expected to apply to `Foo as below] *) | `Foo ] type z = [ `Bar (* a comment *) | `Foo ] (* On second thought, I kind of like this way of thinking about this indentation, even though it is kind of parasyntactic: *) type z = (* Applies to "[" or `Bar. *) [ `Bar of foo (* Applies to "|" or `Foo. Indented too much. *) | `Foo ] type z = (* Applies to "[" or `Bar. *) [ `Bar (* Applies to "|" or `Foo. *) | `Foo ] (* The way we write code, that will line up more nicely. *) let _ = (foo (* This is indented too far to the left *) (bar)) (* It looks to me like we generally want the comment to apply to the following line in most circumstances, including this one. The default indent for an empty line after a function application that isn't terminated with a ";" or something would probably also be in a bit, in anticipation of an argument, although I don't think that's crucial. *) let _ = foo quux (* about bar *) bar (* about baz *) baz ocp-indent-1.5.3/tests/passing/js-comment1.ml.opts000066400000000000000000000000161273277264100220510ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-comment1.ml.ref000066400000000000000000000022371273277264100216470ustar00rootroot00000000000000type foo = int (* just in case *) (* These two shouldn't be indented differently, but are. *) type z = [ `Bar of foo (* a comment [expected to apply to `Foo as below] *) | `Foo ] type z = [ `Bar (* a comment *) | `Foo ] (* On second thought, I kind of like this way of thinking about this indentation, even though it is kind of parasyntactic: *) type z = (* Applies to "[" or `Bar. *) [ `Bar of foo (* Applies to "|" or `Foo. Indented too much. *) | `Foo ] type z = (* Applies to "[" or `Bar. *) [ `Bar (* Applies to "|" or `Foo. *) | `Foo ] (* The way we write code, that will line up more nicely. *) let _ = (foo (* This is indented too far to the left *) (bar)) (* It looks to me like we generally want the comment to apply to the following line in most circumstances, including this one. The default indent for an empty line after a function application that isn't terminated with a ";" or something would probably also be in a bit, in anticipation of an argument, although I don't think that's crucial. *) let _ = foo quux (* about bar *) bar (* about baz *) baz ocp-indent-1.5.3/tests/passing/js-default.ml000066400000000000000000000005741273277264100207770ustar00rootroot00000000000000type t = { last_trading : Week_date.Spec.t; first_notice : Week_date.Spec.t option; first_notice_exceptions : Date.t Year_month.Map.t with default(Year_month.Map.empty); offset : Week_date.Offset.t; (* n > 0 *) new_contract_expires_in_n_months : int } [@@deriving sexp, compare] module M = struct type t = { x: int } [@@deriving sexp] end ocp-indent-1.5.3/tests/passing/js-default.ml.opts000066400000000000000000000000161273277264100217520ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-fun-rec.ml000066400000000000000000000007641273277264100207130ustar00rootroot00000000000000let rec check_header t = if Iobuf.length t.buf < header_length then failwiths "Short packet" t !sexp_of_t; and session t = check_header t; Session_id.of_int_exn id_int and length t = let len = raw_length t in if len = eos_marker then 0 else len and sexp_of_t t = (* something pretty for debugging *) let lo, len = Iobuf.snapshot t.buf, Iobuf.length t.buf in protect ~finally:(fun () -> Iobuf.Snapshot.rewind lo t.buf; Iobuf.resize t.buf len) (fun () -> ()) ;; ocp-indent-1.5.3/tests/passing/js-fun-rec.ml.opts000066400000000000000000000000161273277264100216650ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-label.ml000066400000000000000000000004551273277264100204300ustar00rootroot00000000000000(* Get C.t and (r : S.t -> T.t) indented two chars right of their labels. *) type t = A.t -> bbb : C.t -> D.t -> e : (f : G.t -> H.t) -> I.t -> jjj : [ `K | `L ] -> M.t -> nnn : [ `O | `P ] -> qqq : (r : S.t -> T.t) -> U.t ocp-indent-1.5.3/tests/passing/js-label.ml.opts000066400000000000000000000000161273277264100214050ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-let.ml000066400000000000000000000020521273277264100201300ustar00rootroot00000000000000let foo some very long arguments that we break onto the next line = bar (); baz (* The [some] above is indented less when [let foo] is the first line. The problem goes away if there's anything on the line before [let foo]. *) (* The picture shows where we want the `=' to be. However, Tuareg currently moves it over to line up with the arguments. Perhaps this is merely a personal preference, but that seems ugly to me. pszilagyi: It's consistent with other infix operators (although this is syntax) for it to be where you prefer. *) let foo arguments = bar let foo arguments = bar (* This program parses, but the [let] is indented incorrectly. *) module M = struct module M : module type of M = struct let x = () end end (* Removing the [: module type of M] removes the bug. *) let parenthesized_let_tweak = (let sub value n l f = case ~value (message ("fix_sending_" ^ n) ~length:(35 + 29 + l) f) in x) let parenthesized_let_tweak = f ~x:(let n = S.S.g s.S.s ~s in y) ocp-indent-1.5.3/tests/passing/js-let.ml.opts000066400000000000000000000000161273277264100211120ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-list.ml000066400000000000000000000004241273277264100203200ustar00rootroot00000000000000(* mixed list styles *) let cases = [ Group ("publishing", [ basic_pre2 ~name; ]); (* I think this line and the 2 preceding ones are indented one space too few by ocp-indent *) Group ("recovery", [ basic_pre2 ~name ]); ] ocp-indent-1.5.3/tests/passing/js-list.ml.opts000066400000000000000000000000161273277264100213010ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-low-priority.ml000066400000000000000000000013331273277264100220250ustar00rootroot00000000000000(* Relatively low priority Jane Street indentation bugs. *) (* js-args *) (* uncommon *) let x = try x with a -> b | c -> d let x = try x with a -> b | c -> d (* js-comment *) let mk_cont_parser cont_parse = (); fun _state str ~max_pos ~pos -> let len = max_pos - pos + 1 in cont_parse ~pos ~len str (* sexp parser is sensitive to absent newlines at the end of files. *) (* It would be nice if a partially completed ocamldoc code fragment inside a comment had the closing delimiter "]}" indented nicely before the comment is closed. (This has to be the last comment in the file, to be partial.) *) (* Maybe add: {[ val state : t -> [ `Unstarted | `Running | `Stopped ] ]} ocp-indent-1.5.3/tests/passing/js-low-priority.ml.opts000066400000000000000000000000161273277264100230060ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-map.ml000066400000000000000000000001351273277264100201210ustar00rootroot00000000000000let projection_files = Deferred.List.map x ~f:(fun p -> _) >>| String.split ~on:'\n' ocp-indent-1.5.3/tests/passing/js-map.ml.opts000066400000000000000000000000161273277264100211030ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-model.ml000066400000000000000000000002721273277264100204460ustar00rootroot00000000000000val f : int -> int type t = | A | B let height = function | A -> 0 | B -> 1 let _ = if x then begin y end else if x then y else z type t = int -> int ocp-indent-1.5.3/tests/passing/js-model.ml.opts000066400000000000000000000000161273277264100214260ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-pipebang.ml000066400000000000000000000030541273277264100211340ustar00rootroot00000000000000let f x = x >>| fun x -> g x >>| fun x -> h x ;; let f x = x >>| fun x -> g x >>| fun x -> h x ;; let f x = x |! fun x -> g x |! fun x -> h x ;; let f x = x |! fun x -> g x |! fun x -> h x ;; let _ = (z (fun x -> x) |! Validate.of_list) (* Tuareg indents this line too far. *) let _ = (* Tuareg works correctly on this (if you drop the fun). *) (z x |! Validate.of_list) (* jli found this great one. Tuareg gets confused by the paren before List.map and indents |! way too far, under "k ^". ocp-indent should shine, since it understands the syntax better. *) let _ = List.filter_opt [ format old (fun old -> "removed: " ^ (List.map old ~f:(fun (k, v) -> k ^ "=" ^ acl_to_string v) |! String.concat ~sep:", ")) ] (* (|>) = (|!) *) let f x = x |> fun x -> g x |> fun x -> h x ;; let f x = x |> fun x -> g x |> fun x -> h x ;; let _ = (z (fun x -> x) |> Validate.of_list) (* Tuareg indents this line too far. *) let _ = (* Tuareg works correctly on this (if you drop the fun). *) (z x |> Validate.of_list) (* jli found this great one. Tuareg gets confused by the paren before List.map and indents |> way too far, under "k ^". ocp-indent should shine, since it understands the syntax better. *) let _ = List.filter_opt [ format old (fun old -> "removed: " ^ (List.map old ~f:(fun (k, v) -> k ^ "=" ^ acl_to_string v) |> String.concat ~sep:", ")) ] ocp-indent-1.5.3/tests/passing/js-pipebang.ml.opts000066400000000000000000000000161273277264100221130ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-poly.ml000066400000000000000000000003531273277264100203310ustar00rootroot00000000000000let handle_query qs ~msg_client:_ = try_with (fun () -> if _ then f >>| fun () -> `Done () else _ ) ;; if _ then _ else assert_branch_has_node branch node >>| fun () -> { t with node; floating } ;; ocp-indent-1.5.3/tests/passing/js-poly.ml.opts000066400000000000000000000000161273277264100213110ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-sexp.ml000066400000000000000000000002751273277264100203300ustar00rootroot00000000000000let () = f x [%sexp_of int] y ;; (* y *) let z = some_function [%sexp_of foo] ;; let z = some_function argument let d = print_sexp [%sexp_of unit] () ocp-indent-1.5.3/tests/passing/js-sexp.ml.opts000066400000000000000000000000161273277264100213050ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-str.ml000066400000000000000000000023301273277264100201530ustar00rootroot00000000000000(* gigantic string with weird characters that causes trouble *) TEST_UNIT = eprintf "%s\n" (remove_progress_bar "[============================================================ ] 04840 / 04841 [============================================================ ] 04841 / 04842 [======================================= ] 05010 / 07826 [======================== ] 05053 / 13052 [============================= ] 06807 / 14348 [=============================== ] 08203 / 16405 [================================= ] 09418 / 17458 [================================= ] 09566 / 17458 [================================== ] 09631 / 17458 [================================= ] 10200 / 18846 [=========================== ] 10221 / 23043 [============================= ] 11016 / 23098 make[1]: Leaving directory `/mnt/local/sda1/mstanojevic/repos/live/submissions'") let _ = x ocp-indent-1.5.3/tests/passing/js-str.ml.opts000066400000000000000000000000161273277264100211360ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-str.ml.ref000066400000000000000000000023321273277264100207300ustar00rootroot00000000000000(* gigantic string with weird characters that causes trouble *) TEST_UNIT = eprintf "%s\n" (remove_progress_bar "[============================================================ ] 04840 / 04841 [============================================================ ] 04841 / 04842 [======================================= ] 05010 / 07826 [======================== ] 05053 / 13052 [============================= ] 06807 / 14348 [=============================== ] 08203 / 16405 [================================= ] 09418 / 17458 [================================= ] 09566 / 17458 [================================== ] 09631 / 17458 [================================= ] 10200 / 18846 [=========================== ] 10221 / 23043 [============================= ] 11016 / 23098 make[1]: Leaving directory `/mnt/local/sda1/mstanojevic/repos/live/submissions'") let _ = x ocp-indent-1.5.3/tests/passing/js-test.ml000066400000000000000000000014111273277264100203210ustar00rootroot00000000000000let%test = let b = true in b (* Above, a multi-line TEST (likewise BENCH) was indented wrong only when it started on the first line. (That wasn't really a big problem.) *) (* oUnit *) module E = Example let%test_module = (module struct let%test = false let%test = let b = true in b let%test "Name_test" = let b = true in (* tricky for Tuareg *) b end) let%test_module "Name" = (module struct let%test_unit = () let%test_unit = let () = () in () let%test_unit "Name_unit" = let () = () in (* tricky for Tuareg *) () let%test_unit = let msgcount = 10_000 in (* tricky for Tuareg *) () end) let _ = printf "Hello, world!\n" ocp-indent-1.5.3/tests/passing/js-test.ml.opts000066400000000000000000000000161273277264100213050ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-try.ml000066400000000000000000000001201273277264100201540ustar00rootroot00000000000000(* nested "try" *) try try x with e -> e with e -> e (* indented too far *) ocp-indent-1.5.3/tests/passing/js-try.ml.opts000066400000000000000000000000161273277264100211440ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-type.ml000066400000000000000000000012461273277264100203310ustar00rootroot00000000000000type t = S.s (* looks like a constructor to ocp-indent, which indents too far *) type t = s (* correct, because this doesn't look like a constructor to ocp-indent *) type t = S (* correctly indented a little more, because... *) type t = | S (* we leave room for the vertical bar *) (* analogous value expressions, analogous to lists, some different from now *) let _ = [ x ; y ] let _ = [ x; y ] let _ = ( x , y ) let _ = ( x, y ) let _ = ( x , y ) let _ = [ x ; y ] let _ = ( x, y ) let _ = [ x; y ] let _ = ( x , y ) let _ = [ x ; y ] ocp-indent-1.5.3/tests/passing/js-type.ml.opts000066400000000000000000000000161273277264100213070ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/js-var.ml000066400000000000000000000000421273277264100201310ustar00rootroot00000000000000type t = | A | B of int | C ocp-indent-1.5.3/tests/passing/js-var.ml.opts000066400000000000000000000000161273277264100211160ustar00rootroot00000000000000-c JaneStreet ocp-indent-1.5.3/tests/passing/let-and.ml000066400000000000000000000002661273277264100202630ustar00rootroot00000000000000let f = fun x -> x and g = fun x -> x and h = fun x -> x let rec f : 'a. 'a -> 'a = fun x -> g x and g : 'a. 'a -> 'a = fun x -> h x and h : 'a. 'a -> 'a = fun x -> f x ocp-indent-1.5.3/tests/passing/let-open.ml000066400000000000000000000000721273277264100204550ustar00rootroot00000000000000 let _ = (* ... *) let open Option in indented_line ocp-indent-1.5.3/tests/passing/lwt.ml000066400000000000000000000004761273277264100175500ustar00rootroot00000000000000let f () = lwt x = g () in Lwt.return x let f x = match_lwt x with | A -> A | B -> B let g x = try_lwt f x finally g x let a f x = try_lwt f x with Failure _ -> () finally () (* should'nt break normal try/with imbrication *) let z f x = try try f x with Exit -> () with _ -> () ocp-indent-1.5.3/tests/passing/lwt.ml.opts000066400000000000000000000000151273277264100205210ustar00rootroot00000000000000--syntax lwt ocp-indent-1.5.3/tests/passing/macro.ml000066400000000000000000000001121273277264100200260ustar00rootroot00000000000000open Foo INCLUDE "bar" IFDEF "foo" let f x = 3 ENDIF TEST foo TEST bar ocp-indent-1.5.3/tests/passing/match_fun.ml000066400000000000000000000001561273277264100207010ustar00rootroot00000000000000let reset_cond = match states with | [ _ ] -> fun _ v _ -> e_id v | _ -> fun s v clk -> (* … *) ocp-indent-1.5.3/tests/passing/module.ml000066400000000000000000000014521273277264100202220ustar00rootroot00000000000000module M (S : S) = F.Make(struct module G = struct type t include Foo with type t := t include Bar with type t := t end end) module M = struct type t end module Update : sig val f : ('a, 'b) t -> 'a -> unit val g : ('a, 'b) t -> 'a -> unit module M : C with type k = t module G : C with type k := f type t end = struct type t = int end module M : S with type t = x and type t' = y and type t' = y = struct type t = int end module M : S with type t = x and type t' = y and type t' = y = struct type t = int end module Make: functor (M : T) -> sig val f : int -> int val g : int -> int end module Store (K: API.KEY) (V: API.VALUE) : API.STORE with module K = K and module V = V = struct module K = K ocp-indent-1.5.3/tests/passing/multiline.ml000066400000000000000000000006661273277264100207450ustar00rootroot00000000000000let _ = (* multiline-comments can be troublesome: let x = let y = f z in y indented code should be kept as is *) () let _ = (* what about multi-line comments that don't start a line ? *) w let s1 = "a b c d e f g h i j k" let s2 = "a b c d \ e f g h \ i j k\ \ l" let s3 = "a b c d \ e f g h i j k \ l m" ocp-indent-1.5.3/tests/passing/nested_variants.ml000066400000000000000000000003441273277264100221250ustar00rootroot00000000000000type tt = | A of int | B of string | C of float | D of char type tt = [ | `a of int | `blskdjf of float | `problem_cause of [ `more_brackets ] | `problematic_case of string ] ocp-indent-1.5.3/tests/passing/nesting.ml000066400000000000000000000004171273277264100204040ustar00rootroot00000000000000module M = struct let a = (((((( ) ) ) ) ) ) let a = (ff(ff(ff(ff(ff(ff( ) ) ) ) ) ) ) let a = [[[[[[ ] ] ] ] ] ] let a = [ff[ff[ff[ff[ff[ff[ ] ] ] ] ] ] ] ocp-indent-1.5.3/tests/passing/object.ml000066400000000000000000000002511273277264100201770ustar00rootroot00000000000000let x = object inherit foo method bar = _ end class foo = object method x = 2 inherit bar end class foo = object(this) inherit bar end ocp-indent-1.5.3/tests/passing/obuild.ml000066400000000000000000000002731273277264100202130ustar00rootroot00000000000000type predicate = Pred_Byte | Pred_Native | Pred_Toploop let _ = { pkg with package_version = projFile.version ; package_description = _ ; package_requires = [] } ocp-indent-1.5.3/tests/passing/obuild.ml.opts000066400000000000000000000000471273277264100211760ustar00rootroot00000000000000-c base=2,type=2,match_clause=4,with=2 ocp-indent-1.5.3/tests/passing/ocamldoc.ml000066400000000000000000000111011273277264100205060ustar00rootroot00000000000000(** From http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual029.html#htoc172 The first special comment of the file is the comment associated with the whole module.*) (** Special comments can be placed between elements and are kept by the OCamldoc tool, but are not associated to any element. @-tags in these comments are ignored.*) (*******************************************************************) (** Comments like the one above, with more than two asterisks, are ignored. *) (** The comment for function f. *) val f : int -> int -> int (** The continuation of the comment for function f. *) (** Comment for exception My_exception, even with a simple comment between the special comment and the exception.*) (* Hello, I'm a simple comment :-) *) exception My_exception of (int -> int) * int (** Comment for type weather *) type weather = | Rain of int (** The comment for construtor Rain *) | Sun (** The comment for constructor Sun *) (** Comment for type weather2 *) type weather2 = | Rain of int (** The comment for construtor Rain *) | Sun (** The comment for constructor Sun *) (** I can continue the comment for type weather2 here because there is already a comment associated to the last constructor.*) (** The comment for type my_record *) type my_record = { foo : int ; (** Comment for field foo *) bar : string ; (** Comment for field bar *) } (** Continuation of comment for type my_record *) (** Comment for foo *) val foo : string (** This comment is associated to foo and not to bar. *) val bar : string (** This comment is assciated to bar. *) (** The comment for class my_class *) class my_class : object (** A comment to describe inheritance from cl *) inherit cl (** The comment for attribute tutu *) val mutable tutu : string (** The comment for attribute toto. *) val toto : int (** This comment is not attached to titi since there is a blank line before titi, but is kept as a comment in the class. *) val titi : string (** Comment for method toto *) method toto : string (** Comment for method m *) method m : float -> int end (** The comment for the class type my_class_type *) class type my_class_type = object (** The comment for variable x. *) val mutable x : int (** The commend for method m. *) method m : int -> int end (** The comment for module Foo *) module Foo = struct (** The comment for x *) val x : int (** A special comment that is kept but not associated to any element *) end (** The comment for module type my_module_type. *) module type my_module_type = sig (** The comment for value x. *) val x : int (** The comment for module M. *) module M = struct (** The comment for value y. *) val y : int (* ... *) end end (** The comment for class my_class *) class my_class = object (** A comment to describe inheritance from cl *) inherit cl (** The comment for the instance variable tutu *) val mutable tutu = "tutu" (** The comment for toto *) val toto = 1 val titi = "titi" (** Comment for method toto *) method toto = tutu ^ "!" (** Comment for method m *) method m (f : float) = 1 end (** The comment for class type my_class_type *) class type my_class_type = object (** The comment for the instance variable x. *) val mutable x : int (** The commend for method m. *) method m : int -> int end (** The comment for module Foo *) module Foo = struct (** The comment for x *) val x : int (** A special comment in the class, but not associated to any element. *) end (** The comment for module type my_module_type. *) module type my_module_type = sig (* Comment for value x. *) val x : int (* ... *) end (** Starting bla doc *) type bla = | Hup (** The hup case *) | Hap (** The hap case *) (** Ending bla doc *) (** Starting bla doc *) type bla = | Hup (** The hup case *) | Hap (** The hap case *) (** Ending bla doc *) type hop (** Hop's documentation *) type mip = { fup : int; (** fup field *) fip : int; (** fip field *) } (** Mip's documentation *) type t = Hey | Ho (** Let's go. *) type tp = [ `Hey | `Ho ] (** Tp doc. Second line. *) (** Starting function f doc *) val f : 'a -> 'b (** Ending function f doc. *) val g : 'a -> t (** Function g doc. Second line. *) val g : 'a -> [`Hey | `Ho ] (** Let's go Second line. *) val x : unit -> unit (** Here are a couple examples of some of its many uses {v step (fun m v -> m ~foo:v) +> flag "-foo" no_arg : (foo:bool -> 'm, 'm) t v} *) ocp-indent-1.5.3/tests/passing/ocamldoc2.ml000066400000000000000000000002371273277264100206000ustar00rootroot00000000000000a (* {[ (* {v *) ]} {v v} *) b let _ = (* {[ while true do xx done (* this is totally crazy !!! *) ]} *) () ocp-indent-1.5.3/tests/passing/partial-match.ml000066400000000000000000000001071273277264100214570ustar00rootroot00000000000000let () = match x with | `A -> "A" | `B -> "B" ocp-indent-1.5.3/tests/passing/partial-match.ml.opts000066400000000000000000000000131273277264100224370ustar00rootroot00000000000000--lines 3- ocp-indent-1.5.3/tests/passing/partial.ml000066400000000000000000000004231273277264100203660ustar00rootroot00000000000000 let () = ffff; hhhhhh; fff; let (quot, _rem) = let quot_rem n k = let (d, m) = (n / k, n mod k) in if d < 0 && m > 0 then (d+1, m-k) else (d, m) in let quot n k = fst (quot_rem n k) in let rem n k = snd (quot_rem n k) in quot, rem ocp-indent-1.5.3/tests/passing/partial.ml.opts000066400000000000000000000000141273277264100213460ustar00rootroot00000000000000--lines 5-8 ocp-indent-1.5.3/tests/passing/pattern.ml000066400000000000000000000015361273277264100204150ustar00rootroot00000000000000let f = match x with | { x = 3 } -> let x = 4 in () let f = match x with | (X|Y) | (Z|U) -> 1 | K -> 2 let f = match x with | X when foo = bar -> fff | Y when f = x && g = 3 -> z let f () = match s with (* Parenthesized ident ? *) | x -> x, d (* Regular ident *) | _ -> g ;; match x with | X | Y -> 1 | X -> 2; 3 | A -> 2 ;; let f g = (* haha *) match z with | Z | B _ -> x | A (a, _, _, b) as x -> let x = f a and hr = f b in f let unwind_to = match t with KType | KModule -> true | Kblob -> false | _ -> true let f x = match x with | A | B | C -> x | z -> match z with | _ -> function | x -> x let fun_dep ulam = function | A | B | C -> () let fun_dep ulam = function |A |B|C |D -> () let _ = (match bla with bli) ocp-indent-1.5.3/tests/passing/ppx_expr_ext.ml000066400000000000000000000024541273277264100214650ustar00rootroot00000000000000let x = [%x f 3 ] let x = [%x (f 3 5) ] let x = [%x f 3 5 ] let x = [%xy f 3 5 ] let x = [%x fg 3 5 ] let x = [%x f 3 5 ] let x = [%x f 3 5 ] let x = 3 + [%f f ] let x = [%f f ] * [%f f ] + [%f f ] let x = [%f f 4 2 ] * [%f f 3 4 ] let x = [%f f 2 3 ] * [%f f 3 4 ] + [%f f 2 3 ] let x = [%f f 2 3 ] * [%f f 3 4 ] + [%f f 2 3 ] let x = [%f f 2 3 ] + [%f f 3 4 ] * [%f f 2 3 ] let x = [%f f 2 3 ] + [%f f 3 4 ] * [%f f 2 3 ] let x = [%f f 2 3 ] + [%f f 3 4 ] + [%f f 2 3 ] let x = [% f f 4 2 ] * [% f f 3 4 ] let x = [% f .u f 4 2 ] * [% f .u f 3 4 ] ocp-indent-1.5.3/tests/passing/ppx_expr_ext.ml.opts000066400000000000000000000000271273277264100224430ustar00rootroot00000000000000-c align_params=always ocp-indent-1.5.3/tests/passing/ppx_stritem_ext.ml000066400000000000000000000012711273277264100221720ustar00rootroot00000000000000let x = 3 [%% a let x = [ 3; 2; ] ] module S = sig let x = 3 [%% b let x = [ 3; 2; ] ] end [%% c let x = [ 3; 2; ] [%% d let x = [ 3; 2; ] ] ] [%% x 2 * 3 + x ] [%% x 2 + 3 * x ] [%% x 2 ] [%% x . y 2 ] [%% x .y 2 ] [%% x . y 2 ] [%% x 2 ] module S = sig let x = 3 [%% x .y 2 ] [%% x .y 2 ] [%% x .y 2 ] end [%% client open M let x = 3 module M = struct end ] [%% client let x = 3 open M module M = struct end ] [%% client module M = struct end open M let x = 3 ] ocp-indent-1.5.3/tests/passing/quotations2.ml000066400000000000000000000034641273277264100212320ustar00rootroot00000000000000open Util let header current categories pages = let aux short = let long = match Category.find short with | None -> failwith ("cannot find category " ^ short) | Some c -> c in let url = try let first = List.find (fun p -> p.Page.category = Some short && p.Page.id = 1) pages in first.Page.permalink with Not_found -> (* we are processing a blog entry or an index page *) Config.url short / "index.html" in if short = current then <:xhtml<
  • $str:long$
  • &>> else <:xhtml<
  • $str:long$
  • &>> in <:xhtml< >> let footer current categories pages = let categories = List.map (fun short -> let long = match Category.find short with | None -> failwith ("cannot find category " ^ short) | Some c -> c in short, long, List.sort Page.compare (List.filter (fun p -> p.Page.category = Some short) pages) ) categories in let aux (short, long, pages) = let pages = List.map (fun p -> if p.Page.footer then <:xhtml<
  • $str:p.Page.title$
  • >> else Xhtml.empty ) pages in <:xhtml<
    • $str:long$

    • $list:pages$
    >> in <:xhtml<
    >> ocp-indent-1.5.3/tests/passing/record-with.ml000066400000000000000000000011251273277264100211610ustar00rootroot00000000000000let a = { somerecord with a = b; c = d; } let a = { somerecord with a = b; c = d; } let z = { recofzfzfzrd with a = bli; bzeefe = k ; efgeg = a } let b = let z = { reczfzrd with a = bli; bzeefe = _; } let b = let z = { reczfzrd with a = bli; bzeefe } let lexbuf = { lexbuf with Lexing.lex_start_p = start_pos; Lexing.lex_curr_p = start_pos; } ocp-indent-1.5.3/tests/passing/record_comments.ml000066400000000000000000000003151273277264100221150ustar00rootroot00000000000000type t = { a : int ; (** blablabla *) b : int ; (** blublublu *) c : int ; (** ccc *) } let _ = [ A ; (* A *) B ; (* B *) ] type t = { x : t1; (* c1 *)(* c2 *) y : t2; } ocp-indent-1.5.3/tests/passing/records.ml000066400000000000000000000017201273277264100203740ustar00rootroot00000000000000let read_raw_gen_ic read_pixel ic l c max = let img = Index8.create c l in let greymap = { Color.max = max; Color.map = let make_grey i = {r = i; g = i; b = i} in Array.init (max + 1) make_grey} in img.Index8.colormap <- greymap; for i = 0 to l - 1 do for j = 0 to c - 1 do Index8.set img j i (read_pixel ic) done done; img;; let func_darken_only org level = let level = 255 - level in { r = if org.r > level then level else org.r; g = if org.g > level then level else org.g; b = if org.b > level then level else org.b };; let f = function | { f1 = Foo | Bar; f2 = _; f3 = Foo | Bar } -> { f1 = Foo, Bar; f2 = xxx = yyy; f3 = Foo, Bar } let _ = match a with | { kind = x } -> () | { LibIndex.kind = x } -> () let x = { kind = x }, { LibIndex.kind = x } ocp-indent-1.5.3/tests/passing/semi.ml000066400000000000000000000003121273277264100176640ustar00rootroot00000000000000let f () = print_endline "a" ; print_endline "b" let f () = toto ; blah let f () = { a = 3 ; b = 4 ; } module A = struct type x = { a: int ; b: int ; } end ocp-indent-1.5.3/tests/passing/semisemi.ml000066400000000000000000000001301273277264100205400ustar00rootroot00000000000000module M = struct let () = () ;; let f x = 3;; let () = () end ;; let () = () ocp-indent-1.5.3/tests/passing/sequence.ml000066400000000000000000000011021273277264100205350ustar00rootroot00000000000000let f = fun x -> x let f x = x let f g = fun x -> g x let f g x = g x let l1 = (a :: b :: []) let l1 = ( a :: b :: []) let l1 = a :: b :: [] let l1 = a :: b :: [] let l1 = [a; b; ] let l1 = [ a; b; ] let l1 = [ a; b; ] let l1 = [ a ; b ] let l1 = [ a ; b ] let l1 = [ a; b ; c ] let f1 = function | {k=A|B} -> true | {k=C} -> false let overflow_small = 4611686018427387904 (* max_int (63) + 1 *) let overflow_big = 46116860184273879030 ocp-indent-1.5.3/tests/passing/str_else_always.ml000066400000000000000000000012001273277264100221240ustar00rootroot00000000000000let () = if true then "bla" else if true then "bli" else "blo" let () = if true then "bla" else if true then "bli" else begin "hop" end let () = if true then "hop" else if true then "hap" else ((); "bla") let () = if x then y else k, w; z let () = if x then a else let y = x / 42 in y let () = if x then a else if y then b else begin blabla end; x let () = if x then a else match y with | A -> x | B -> y let () = if x then a else match y with | A -> x | B -> y let () = if x then a else fun x -> y ocp-indent-1.5.3/tests/passing/str_else_always.ml.opts000066400000000000000000000000261273277264100231150ustar00rootroot00000000000000-c strict_else=always ocp-indent-1.5.3/tests/passing/str_else_auto.ml000066400000000000000000000011621273277264100216030ustar00rootroot00000000000000let () = if true then "bla" else if true then "bli" else "blo" let () = if true then "bla" else if true then "bli" else begin "hop" end let () = if true then "hop" else if true then "hap" else ((); "bla") let () = if x then y else k, w; z let () = if x then a else let y = x / 42 in y let () = if x then a else if y then b else begin blabla end; x let () = if x then a else match y with | A -> x | B -> y let () = if x then a else match y with | A -> x | B -> y let () = if x then a else fun x -> y ocp-indent-1.5.3/tests/passing/str_else_auto.ml.opts000066400000000000000000000000241273277264100225630ustar00rootroot00000000000000-c strict_else=auto ocp-indent-1.5.3/tests/passing/str_else_never.ml000066400000000000000000000011501273277264100217470ustar00rootroot00000000000000let () = if true then "bla" else if true then "bli" else "blo" let () = if true then "bla" else if true then "bli" else begin "hop" end let () = if true then "hop" else if true then "hap" else ((); "bla") let () = if x then y else k, w; z let () = if x then a else let y = x / 42 in y let () = if x then a else if y then b else begin blabla end; x let () = if x then a else match y with | A -> x | B -> y let () = if x then a else match y with | A -> x | B -> y let () = if x then a else fun x -> y ocp-indent-1.5.3/tests/passing/str_else_never.ml.opts000066400000000000000000000000251273277264100227330ustar00rootroot00000000000000-c strict_else=never ocp-indent-1.5.3/tests/passing/traverse.mli000066400000000000000000000224621273277264100207450ustar00rootroot00000000000000(* Copyright © 2011 MLstate This file is part of OPA. OPA is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. OPA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with OPA. If not, see . *) (** Generic Ast Rewriter API. This module provides all usual traverse functions and some higher-level ones on any tree structure as long as we consider only one type of nodes @author Louis Gesbert @author Valentin Gatien-Baron @author Mathieu Barbin *) open TraverseInterface (* module type TRAVERSE_LIFT = *) (* sig *) (* val foldmap : ('acc -> 'expr -> 'acc * 'expr) -> 'acc -> 'code_elt -> 'acc * 'code_elt *) (* end *) (** Some Extensions *) module Utils : sig (** A generalisation of the type needed in S ('a, 'at, 'bt ,'b) sub 'a may be expressions where identifiers are strings 'b an expressions where identfiers are uniq In that case, ('a,'a,'b,'b) represents a function that deconstruct a string expression into a - list of string expression - a function that expects an ident expression list and build you the the 'original' ident expression DON'T LOOK at the types, it's too scary Instead take a look at the following example, where you build the subs_cons function for the expressions of some ast: let subs_cons e = match e with | Apply (e1,e2) -> (* (e1,e2) is a pair of expression and you are currently treating * expressions, you write exactly that: *) wrap (fun x -> Apply x) ((sub_2 sub_current sub_current) (e1,e2)) | Match pel -> (* pel is a list of pattern * expr * we just ignore the pattern since there is no expression inside them * we stop the deconstruction on the expression, since it is was we are currently deconstructing *) wrap (fun x -> Match x) (sub_list (sub_2 sub_ignore sub_current) pel) | _ -> ... *) type ('a, 'at, 'bt, 'b) sub = 'a -> ('bt list -> 'b) * 'at list val sub_2 : ('a1, 'at, 'bt, 'b1) sub -> ('a2, 'at, 'bt, 'b2) sub -> ('a1 * 'a2, 'at, 'bt, 'b1 * 'b2) sub val sub_3 : ('a1, 'at, 'bt, 'b1) sub -> ('a2, 'at, 'bt, 'b2) sub -> ('a3, 'at, 'bt, 'b3) sub -> ('a1 * 'a2 * 'a3, 'at, 'bt, 'b1 * 'b2 * 'b3) sub val sub_4 : ('a1, 'at, 'bt, 'b1) sub -> ('a2, 'at, 'bt, 'b2) sub -> ('a3, 'at, 'bt, 'b3) sub -> ('a4, 'at, 'bt, 'b4) sub -> ('a1 * 'a2 * 'a3 * 'a4, 'at, 'bt, 'b1 * 'b2 * 'b3 * 'b4) sub val sub_list : ('a, 'at, 'bt, 'b) sub -> ('a list, 'at, 'bt, 'b list) sub val sub_option : ('a, 'at, 'bt, 'b) sub -> ('a option, 'at, 'bt, 'b option) sub val sub_current : ('a, 'a, 'b, 'b) sub val sub_ignore : ('a, _, _, 'a) sub val wrap : ('a -> 'b) -> ('at list -> 'a) * 't list -> ('at list -> 'b) * 't list end (* HACK: tmp until we merge it into TRAVERSE_CORE for TraverseInterface, and rename it into TRAVERSE *) module type OLD_TRAVERSE = sig type 'p t constraint 'p = _ * _ * _ val traverse_iter : (('p t -> unit) -> 'p t -> unit) -> 'p t -> unit val traverse_map : (('p t -> 'p t) -> 'p t -> 'p t) -> 'p t -> 'p t val traverse_fold : (('a -> 'p t -> 'a) -> 'a -> 'p t -> 'a) -> 'a -> 'p t -> 'a val traverse_foldmap : (('a -> 'p t -> 'a * 'p t) -> 'a -> 'p t -> 'a * 'p t) -> 'a -> 'p t -> 'a * 'p t val traverse_exists : (('p t -> bool) -> 'p t -> bool) -> 'p t -> bool val traverse_forall : (('p t -> bool) -> 'p t -> bool) -> 'p t -> bool val traverse_fold_context_down : (('env -> 'a -> 'p t -> 'a) -> 'env -> 'a -> 'p t -> 'a) -> 'env -> 'a -> 'p t -> 'a val iter : ('p t -> unit) -> 'p t -> unit val iter_up : ('p t -> unit) -> 'p t -> unit val iter_down : ('p t -> unit) -> 'p t -> unit val map : ('p t -> 'p t) -> 'p t -> 'p t val map_up : ('p t -> 'p t) -> 'p t -> 'p t val map_down : ('p t -> 'p t) -> 'p t -> 'p t val fold : ('a -> 'p t -> 'a) -> 'a -> 'p t -> 'a val fold_up : ('a -> 'p t -> 'a) -> 'a -> 'p t -> 'a val fold_down : ('a -> 'p t -> 'a) -> 'a -> 'p t -> 'a val foldmap : ('a -> 'p t -> 'a * 'p t) -> 'a -> 'p t -> 'a * 'p t val foldmap_up : ('a -> 'p t -> 'a * 'p t) -> 'a -> 'p t -> 'a * 'p t val foldmap_down : ('a -> 'p t -> 'a * 'p t) -> 'a -> 'p t -> 'a * 'p t val exists : ('p t -> bool) -> 'p t -> bool val exists_up : ('p t -> bool) -> 'p t -> bool val exists_down : ('p t -> bool) -> 'p t -> bool val find : ('p t -> bool) -> 'p t -> 'p t option val find_up : ('p t -> bool) -> 'p t -> 'p t option val find_down : ('p t -> bool) -> 'p t -> 'p t option val findmap : ('p t -> 'a option) -> 'p t -> 'a option val findmap_up : ('p t -> 'a option) -> 'p t -> 'a option val findmap_down : ('p t -> 'a option) -> 'p t -> 'a option (** traverse all the nodes of the tree in an unspecified order *) val traverse_fold_right : (('b t -> 'a -> 'a) -> 'b t -> 'a -> 'a) -> 'b t -> 'a -> 'a (** [fold_up_combine ?combine f acc0 t] folds [f] from leaves with [acc0], combining accumulators from sub-trees with [combine] before calling [f]. Default value for combine is (fun _ b -> b) Be carefull be using this function without combine, lots of accs are lost *) val fold_up_combine : ?combine:('a -> 'a -> 'a) -> ('a -> 'b t -> 'a) -> 'a -> 'b t -> 'a (** Folds all the nodes of the tree in an unspecified order *) val fold_right_down : ('b t -> 'a -> 'a) -> 'b t -> 'a -> 'a val foldmap_up_combine : ?combine:('a -> 'a -> 'a) -> ('a -> 'b t -> 'a * 'b t) -> 'a -> 'b t -> 'a * 'b t (** Non-recursive versions, e.g. if you want to handle recursion yourself and have a default case *) val map_nonrec : ('b t -> 'b t) -> 'b t -> 'b t val fold_nonrec : ('a -> 'b t -> 'a) -> 'a -> 'b t -> 'a val foldmap_nonrec : ('a -> 'b t -> 'a * 'b t) -> 'a -> 'b t -> 'a * 'b t (** Just because we had fun writing it. Don't use as is, it's probably very slow. Applies the rewriting until fixpoint reached *) val map_down_fix : ('b t -> 'b t) -> 'b t -> 'b t (** Additional functions that let you traverse the type 'c t when they are deep into an arbitrary structure 'b as long as you provide the functions to unbuild/rebuild 'b into t lists *) type ('b, 'c) sub = ('b, 'c t, 'c t , 'b) Utils.sub val lift_iter_up : ('b,'c) sub -> ('c t -> unit) -> ('b -> unit) val lift_iter_down : ('b,'c) sub -> ('c t -> unit) -> ('b -> unit) val lift_map_up : ('b,'c) sub -> ('c t -> 'c t) -> ('b -> 'b) val lift_map_down : ('b,'c) sub -> ('c t -> 'c t) -> ('b -> 'b) (* like fold_map_up_for_real *) val lift_fold_up_combine : ('b,'c) sub -> ?combine:('a -> 'a -> 'a) -> ('a -> 'c t -> 'a) -> ('a -> 'b -> 'a) val lift_fold : ('b,'c) sub -> ('a -> 'c t -> 'a) -> ('a -> 'b -> 'a) val lift_fold_right_down : ('b,'c) sub -> ('c t -> 'a -> 'a) -> ('b -> 'a -> 'a) val lift_foldmap_up : ('b,'c) sub -> ('a -> 'c t -> 'a * 'c t) -> ('a -> 'b -> 'a * 'b) val lift_foldmap_down : ('b,'c) sub -> ('a -> 'c t -> 'a * 'c t) -> ('a -> 'b -> 'a * 'b) val lift_exists : ('b,'c) sub -> ('c t -> bool) -> ('b -> bool) end (** {6 First implementation} *) (** Functor giving you the usual traverse functions *) module Make (X : S) : OLD_TRAVERSE with type 'a t = 'a X.t (** Functor for map2, fold2, etc. *) module MakePair (Fst : S) (Snd : S) : OLD_TRAVERSE with type 'a t = 'a Fst.t * 'a Snd.t (** {6 Second implementation} *) (** For the second version (S2), you may do not want to write the optimised version of fold, map, iter in this case you can use this unoptimzed constructors, to get them from the foldmap_children function *) module Unoptimized : sig (** Simple recursion *) type ('acc, 't, 't2) foldmap = ('acc -> 't -> 'acc * 't) -> 'acc -> 't2 -> 'acc * 't2 val iter : (unit, 't, 't2) foldmap -> ('t -> unit) -> 't2 -> unit val map : (unit, 't, 't2) foldmap -> ('t -> 't) -> 't2 -> 't2 val fold : ('acc, 't, 't2) foldmap -> ('acc -> 't -> 'acc) -> 'acc -> 't2 -> 'acc (** Mutual recursion *) type ('acc, 'tA, 'tB) foldmapAB = ('acc -> 'tA -> 'acc * 'tA) -> ('acc -> 'tB -> 'acc * 'tB) -> 'acc -> 'tA -> 'acc * 'tA val iterAB : (unit, 'tA, 'tB) foldmapAB -> ('tA -> unit) -> ('tB -> unit) -> 'tA -> unit val mapAB : (unit, 'tA, 'tB) foldmapAB -> ('tA -> 'tA) -> ('tB -> 'tB) -> 'tA -> 'tA val foldAB : ('acc, 'tA, 'tB) foldmapAB -> ('acc -> 'tA -> 'acc) -> ('acc -> 'tB -> 'acc) -> 'acc -> 'tA -> 'acc end open TraverseInterface module Make2 (X : S2) : TRAVERSE with type 'a t = 'a X.t and type 'a container = 'a X.t module MakeLift1 (Y : LIFT2) (X : TRAVERSE with type 'a container = 'a Y.t and type 'a t = 'a Y.t) : TRAVERSE with type 'a t = 'a X.t and type 'a container = 'a Y.container module MakeLift2 (Y : LIFT2) (X : TRAVERSE with type 'a container = 'a Y.t) : TRAVERSE with type 'a t = 'a X.t and type 'a container = 'a Y.container (* From there, you can build Box of Boxes with MakeBox *) (* for example, for rewriting rules on a tuple of code, etc...*) (** {6 Mutual Recursive Trees} *) module MakeAB (AB : AB) : TRAVERSE_AB with type 'a tA = 'a AB.tA and type 'a tB = 'a AB.tB ocp-indent-1.5.3/tests/passing/traverse.mli.opts000066400000000000000000000000271273277264100217220ustar00rootroot00000000000000-c in=2,match_clause=4 ocp-indent-1.5.3/tests/passing/type-and.ml000066400000000000000000000001321273277264100204500ustar00rootroot00000000000000type a = | A and b = int module M = struct type s = t and t = { foo : s; } end ocp-indent-1.5.3/tests/passing/types.ml000066400000000000000000000025671273277264100201110ustar00rootroot00000000000000type ('a, 'b) t = a : 'a -> ?b : b -> unit type ('a, 'b) t = | A | B of ('a, 'b) t * 'k | C of 'a * 'b type t = Foo | Bar | Baz type t = | Foo | Bar | Baz type t = Foo | Bar | Baz type t = | Foo | Bar | Baz type t = Foo | Bar | Baz type t = { foo: int -> int; bar: 'a; } type t = { x: int; } type t = { x: int; y: int -> a:string -> ?b:(int -> string) -> unit; mutable z: int; mutable a: string -> unit A.t; } type t = { x: int ; y: int -> a:string -> ?b:(int -> string) -> unit ; mutable z: int; a: string -> unit A.t; } type t = { x: int ; y: int -> a:string -> ?b:(int -> string) -> unit ; mutable z: int; a: string -> unit A.t; } type t = { x: int ; y: int -> a:string -> ?b:(int -> string) -> unit ; mutable z: int ; mutable a: string -> unit A.t } type t = { x: int ; y: int -> a:string -> ?b:(int -> string) -> unit ; mutable z: int ; mutable a: string -> unit A.t } type t = [ | `a | `b | `c ] type t = [ `a | `b | `c ] type t = [ | `a | `b | `c ] type t = [ `a | `b | `c ] type t = [ `a | `b | `c ] type t = [ `a | `b | `c ] module M = struct type t = t0 and t' and t'' = t val v: t end ocp-indent-1.5.3/tests/passing/unit-classes.ml000066400000000000000000000042011273277264100213420ustar00rootroot00000000000000(** ocaml classes (http://caml.inria.fr/pub/docs/manual-ocaml/manual017.html) *) (* class types *) class type c = object end class type c = M.cl class type c = ['a, 'b] M.cl class type c = object ('ty) inherit cl val mutable virtual var : bool method private bar1 x ~y : bool method private virtual bar2 : 'a 'b.('a,'b) Hashtbl.t constraint 'a = 'b end (* class expressions *) class c = ['a, 'b] M.cl class c = fun a b -> object end class c = object val x = true end class c = object (_ : 'a) inherit Something.someclass as v val mutable var : bool = true val mutable virtual var2 : string method private bar1 x ~y : bool = false method private virtual bar2 : 'a 'b.('a,'b) Hashtbl.t constraint 'a = 'b initializer z end (* method specific expressions *) let e = var <- true let e = {< var = false; var2 = true; >} (* class definitions *) class cl = object val x = true end and virtual ['a, 'b] cl2 x y : object val x : bool end = fun x y -> object val x : bool = true end class cl : object end class type virtual ['a] clty = object method x : int end (* objects *) val a : < > let () = () val a : < .. > let () = () val a : < meth: int option; meth2: 'a. 'a option; meth3: 'a 'b. ('a,'b) Hashtbl.t > let () = () val a : < meth: int option; meth2: 'a. 'a option; meth3: 'a 'b. ('a,'b) Hashtbl.t; .. > let () = () (* #-types *) val a : #M.meth val a : 'a#M.meth val a : ('a,'b*'c) #M.meth (* object types *) type a = < > let () = () type a = < .. > let () = () type a = < meth: int option; meth2: 'a. 'a option; meth3: 'a 'b. ('a,'b) Hashtbl.t > let () = () type a = < meth: int option; meth2: 'a. 'a option; meth3: 'a 'b. ('a,'b) Hashtbl.t; .. > let () = () type t = < a : int; b: < a: int; b: < c:int > > > let () = () type t = < a : int; b: < a: int; b: < c: int -> int> >; c: int > let () = () type 'a t = | Bla : < x : int > t | Blo : < y : int > t ocp-indent-1.5.3/tests/passing/unit-expr.ml000066400000000000000000000042421273277264100206700ustar00rootroot00000000000000(** ocaml expressions (http://caml.inria.fr/pub/docs/manual-ocaml/expr.html) *) let e = Array.make let e = true let e = (true) let e = begin true end let e = (true: bool) let e = true, false, true let e = Some true let e = `_ true let e = true :: false :: true let e = [ true; false; true; ] let e = [| true; false; true |] let e = { f1 = true; f2 = false; f3 = true; } let e = { e with f1 = true; f2 = false; } let e = f true false true let e = !? true let e = true || false && true let e = 1 mod 1 land 1 lor 1 lxor 1 lsl 1 lsr 1 asr 1 let e = re.f1 let e = re.f1 <- true let e = a.(0) <- true let e = a.[0] <- true let e = if true then false else true let e = while true do () done let e = for x = a to b do () done let e = true; false; true let e = match true with | true -> false | false -> true let e = match true with | true -> false | false -> true let e = function | true -> false | false -> true let e = fun x ~ lbl1 ~ ( lbl2 : int ) ~lbl3: _a ? olbl1 ? (olbl2 : 'a list = []) ?olbl3: _c ?olbl4: ( _d : bool = false ) () when true -> true let e = fun x -> fun ~ lbl1 -> fun ~ ( lbl2 : int ) -> fun ~lbl3: _a -> fun ? olbl1 -> fun ? (olbl2 : 'a list = []) -> fun ?olbl3: _c when true -> fun ?olbl4: ( _d : bool = false ) -> fun () when true -> true let e x ~ lbl1 ~ ( lbl2 : int ) ~lbl3: _a ? olbl1 ? (olbl2 : 'a list = []) ?olbl3: _c ?olbl4: ( _d : bool = false ) () = true let e = try true with | Exit -> true | _ -> false let e = let rec a = true and _b = false in true let e = new foo let foo = object end let e = foo# bar1 let e = (true :> bool) let e = (true : bool :> bool) let e = assert true let e = lazy true ocp-indent-1.5.3/tests/passing/unit-extensions.ml000066400000000000000000000026771273277264100221230ustar00rootroot00000000000000(** ocaml language extensions (http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html) *) (* other integer literals *) let i = 12l + 0l let i = 12L + 0l let i = 12n + 0n (* range patterns *) let f = function | 'a'..'z' -> e1 | 'A'..'Z' | '0'..'9' -> e2 (* local modules *) let f = let module M = F(struct end) in M.f x (* recursive modules *) module rec M : S = struct ;; end and M1 : S1 = struct ;; end (* private types *) type t = private X of string | Y type t = private { f1:t1; f2: t2 } type t = private t' (* local opens *) let _ = let open F(X) in () (* record shortcuts *) let _ = let x = 1 and y = 2 in { x; y } let f = function | { x; y; _ } -> () (* locally abstract types *) let f = fun (type t) (x: t) -> () let f (type t) (x: t) = () (* first-class modules *) type m = (module M.Sig with type t = 'b) * unit let x = let m = (module M : M.Sig with type t = 'b) in let module M = (val m : M.sig with type t = 'b) in M (* module type of *) module type S = sig include module type of M end (* signature substitution *) module type S = sig include M0 with type t := t val x : unit end (* class overriding *) class cl = object inherit! cl val! v = v method! m = m end (* GADTs *) type _ t = A: int t | B: 'a t * 'b t -> ('a*'b) t ocp-indent-1.5.3/tests/passing/unit-lex.ml000066400000000000000000000032161273277264100205020ustar00rootroot00000000000000(* -*- encoding: iso-8859-1 -*- *) (** ocaml lexical conventions (http://caml.inria.fr/pub/docs/manual-ocaml/lex.html) *) (* *** literals *** *) (* identifiers *) let _id, iD', I9, _'i, A_', u', éçèæùà (* this file must be iso-8859-1 *) = _ ;; (* intergers *) let _ = -1 + 0 + 10_ + -0xAFfe_0 + 0X1_ + 0O7_0_1_2 + -0o12__ - 0B0_1_0 + -0b111_ ;; (* floats *) let _ = 0. +. 0.0 +. 0e12 +. 0.e1_ +. 999e+1 +. -9_99_E-0 +. -.12. +. 0_._e-1_2 ;; (* chars *) [ 'a'; '&'; 'Ç'; '§'; '\\'; '\"'; '\''; '\b'; '\234'; '\999'; (* wrong, but yet... *) '\xAF' ] ;; (* strings *) let _ = "'a';\n\ \ '&';\ 'Ç';\ '§';\ '\\';\ '\"';\ '\'';\ '\b';\ '\234';\ '\999'; (* wrong, but yet... *)\ '\xAF'" ;; (* naming labels *) val f : _l1 : int -> ? _' : float -> 'a let rec f ~ _l1 : int ? _' : float = f ~_l1: 0 ?_': 0e1 ;; (* prefix and infix symbols *) _ = _ <:~ _ > _ @ _ ^$ _ %% ;; !! ( ????: _ ) (* keywords *) (* don't care about indentation, just should'nt crash :) *) and as assert asr begin class constraint do done downto else end exception external false for fun function functor if in include inherit initializer land lazy let lor lsl lsr lxor match method mod module mutable new object of open or private rec sig struct then to true try type val virtual when while with ;; (* line number directives *) (* should be ignored and not indented: we may still want to indent generated code for readability *) #9999 "bla.ml\ \n\999" let _ = #9999 "bla.ml\ \n\999" 0 ocp-indent-1.5.3/tests/passing/unit-modexpr.ml000066400000000000000000000011131273277264100213620ustar00rootroot00000000000000(** ocaml module expressions (http://caml.inria.fr/pub/docs/manual-ocaml/manual019.html) *) module M = struct end module M = struct ;; end module M = functor (M1 : T1) -> functor (M2 : T2) -> struct end module M = functor (M1 : T1) -> functor (M2 : T2) -> struct end module M = functor (M1 : T1) -> functor (M2 : T2) -> struct end module M = functor (M1 : T1) -> functor (M2 : T2) -> struct end module M = F (X) (Y) module M = ( struct end : sig end ) module M : Sig = struct end module M (X1: T1) (X2: T2) = struct end ocp-indent-1.5.3/tests/passing/unit-modtypes.ml000066400000000000000000000014231273277264100215540ustar00rootroot00000000000000(** ocaml module types (http://caml.inria.fr/pub/docs/manual-ocaml/manual018.html) *) module type T = M.T module type T = sig end module type T = sig ;; end module type T = functor (M : T) -> functor (M1 : T1) -> sig end module type T = sig end with type 'a t = 'b and module M = M'.MF(X) and type t' = t'' module type T = ( sig end ) module type T = sig val v : t external x : 'a = "stub" type t = int and t2 = t exception Error of int class virtual ['a] cl : object end and cl2 : object end class type clt = object end and ['a] clt2 = object end module M : Sig module M (X) (Y): Sig module type Sig module type Sig1 = sig end open M include M end ocp-indent-1.5.3/tests/passing/unit-patterns.ml000066400000000000000000000007531273277264100215550ustar00rootroot00000000000000(** ocaml patterns (http://caml.inria.fr/pub/docs/manual-ocaml/patterns.html) *) let _ = function x -> () | _ -> () | 'a' -> () | x as y -> () | (x: 'a -> 'b) -> () | x | y -> () | Some x -> () | `Var x -> () | #ty -> () | x, y -> () | { f1 = x; f2 = y; f3 = z; _ } -> () | [ x; y; z; ] -> () | x::y :: z -> () | [| x; y; z; |] -> () | lazy w -> () ocp-indent-1.5.3/tests/passing/unit-typedefs.ml000066400000000000000000000012631273277264100215350ustar00rootroot00000000000000(** ocaml type and exception definitions (http://caml.inria.fr/pub/docs/manual-ocaml/manual016.html) *) type t type 'a t type +'_a t type -'a t type ('a, +'b, (-'c,-'d)) t type t = t2 type t = A type t = A | B of 'a | C of 'a * 'b | D of ('a) Array.t * 'b list | E of _ type t = { f1 : t1; f2 : 'a; mutable f3: t2; f4 : 'a 'b.t2; } type 'a t constraint 'a = t constraint 'b = 'a type ('a, +'b, (-'c,-'d)) t = { f1 : t1; f2 : 'a; mutable f3: t2; f4 : t1 * t2; } constraint 'a = t constraint 'b = 'a exception E exception E of 'a t * string exception E' = E ocp-indent-1.5.3/tests/passing/unit-types.ml000066400000000000000000000022151273277264100210540ustar00rootroot00000000000000(** ocaml type expressions (http://caml.inria.fr/pub/docs/manual-ocaml/types.html) *) (* variables *) val a : 'ident val a : _ (* parentheses *) val a : ( t ) (* functions *) val a : int -> int -> t -> t -> t val a : lab1: int -> lab2 : (t) -> t val a : ? lab1: ( ?_ : int -> t ) -> t (* tuples *) val a : (t1 * t2) * ( t ) (* constructed *) val a : int val a : ('a -> 'b) Array.t (* aliased *) val a : int as 'bla (* polymorphic variants *) val a : [ `_ | `_' | `_00 | `Aa of int ] val a : [ | `_ | `_' | `_00 | `Aa of int ] val a : [< `_ | `_' | `_00 | `Aa of int ] val a : [ | `_ | `_' | `_00 | `Aa of int ] val a : [< | `Bb of int & string & t | int > `a `_bbb `c `d ] (* objects *) val a : < > val a : < .. > val a : < meth: int option; meth2: 'a. 'a option; meth3: 'a 'b. ('a,'b) Hashtbl.t > val a : < meth: int option; meth2: 'a. 'a option; meth3: 'a 'b. ('a,'b) Hashtbl.t; .. > (* #-types *) val a : #M.meth val a : 'a#M.meth val a : ('a,'b*'c) #M.meth ocp-indent-1.5.3/tests/passing/unit-values.ml000066400000000000000000000020061273277264100212050ustar00rootroot00000000000000(** ocaml values (http://caml.inria.fr/pub/docs/manual-ocaml/manual010.html) *) (* base values *) let i32 = −1073741824, 1073741823 let i32_over = −1073741825, 1073741824 let i32_over_big = −10737418240, 10737418230 let i64 = -4611686018427387904, 4611686018427387903 let i64_over = -4611686018427387905, 4611686018427387904 let i64_over_big = -46116860184273879040, 46116860184273879030 let f = 4611686018427387903e-1022, 4611686018427387903e+1023 let f_over = 4611686018427387903e-1023, 4611686018427387903e+1024 (* tuples *) let _ = (1, 2, 3, 4, 5, 1, 2, 3, 4, 5 , 1, 2, 3, 4, 5) (* records *) let _ = { f1 = 12; f2 = 13; f3 = 14; f4 = 15; f5 = 14; f6 = 15; f7 = 14; f8 = 15; } let _ = { f1 = 12; f2 = 13; M_.f3 = 14; M.f4 = 15; M'.M3.f5 = 14; Mz.MM.f6 = 15; Mg.f7 = 14; Fe.f8 = 15 } ;; (* arrays *) [| 5;468; 68;46;84;684;68;4; 54;354;384;3;0;76;64;0;6; 54;354;384;3;0;76;64;0;6; 54;354;384;3;0;76;64;0;6; |] ocp-indent-1.5.3/tests/passing/variants.ml000066400000000000000000000005461273277264100205670ustar00rootroot00000000000000type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] type t = [ `aaa | `bbb | `ccc ] ocp-indent-1.5.3/tests/passing/with_2.ml000066400000000000000000000006271273277264100201340ustar00rootroot00000000000000let x = try y with | A -> _ | B -> _ let x = try y with | A -> _ | B -> _ let x = try y with A -> _ | B -> _ let x = try y with A -> _ | B -> _ let _ = let x = try y with | A -> _ | B -> _ in let x = try y with | A -> _ | B -> _ in let x = try y with A -> _ | B -> _ in let x = try y with A -> _ | B -> _ ocp-indent-1.5.3/tests/passing/with_2.ml.opts000066400000000000000000000000121273277264100211040ustar00rootroot00000000000000-c with=2 ocp-indent-1.5.3/tests/passing/with_never.ml000066400000000000000000000014321273277264100211050ustar00rootroot00000000000000let f x = match x with | `A -> "A" | `B -> "B" let f = function | `A -> "A" | `B -> "B" let f = fun x -> match x with | `A -> "A" | `B -> "B" let f = let g x = match x with | `A -> "A" | `B -> "B" in g let f = let g = function | `A -> "A" | `B -> "B" in g let f = let g = fun x -> match x with | `A -> "A" | `B -> "B" in g let z = begin match x with | X -> x end let config_converter = (fun str -> try (* just check syntax *) ignore (IndentConfig.update_from_string IndentConfig.default str); `Ok str with Invalid_argument s -> `Error s), ignore (IndentConfig.update_from_string IndentConfig.default str); `Ok str let f = try match a with B -> x with C -> y let g = try match X with | X -> X with | X -> Y ocp-indent-1.5.3/tests/passing/with_never.ml.opts000066400000000000000000000000351273277264100220670ustar00rootroot00000000000000-c with=0,strict_with=always ocp-indent-1.5.3/tests/test.sh000077500000000000000000000213341273277264100162560ustar00rootroot00000000000000#!/bin/bash -ue # # Copyright 2012-2013 OCamlPro # # All rights reserved.This file is distributed under the terms of the # GNU Lesser General Public License version 3.0 with linking # exception. # # TypeRex is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # Lesser GNU General Public License for more details. # shopt -s nullglob ROOT=$(git rev-parse --show-toplevel) OCP_INDENT="$ROOT"/ocp-indent cd $ROOT/tests UPDATE= GIT= SHOW= SHOWCMD= HTML= usegit() { printf "%-12s\t\e[34mgit %s\e[m\n" "" "$*"; git "$@"; } is_file_on_git() { [ $# -eq 1 ]; f=$1 git ls-files $f --error-unmatch >/dev/null 2>&1 } while [ $# -gt 0 ]; do case "$1" in --update|-u) UPDATE=1 ;; --git-update) if ! git diff --exit-code -- . >/dev/null; then echo -e "\e[1mWarning:\e[m unstaged changes in tests/" echo "You may want to do 'git checkout -- tests/' or"\ "'git add -u -- tests/' first." exit 1 fi UPDATE=1 GIT="usegit " HTML=1 ;; --ocp-indent) if [ $# -le 1 ]; then echo "Error: $1 needs an argument"; exit 1; fi shift; OCP_INDENT=$1 ;; --show) SHOW=1 ;; --meld) SHOW=1 SHOWCMD="meld" ;; --html) HTML=1 ;; *) cat </dev/stderr Usage: -u --update update the files according to the current results --git-update update the files and state the changes in git --ocp-indent use this ocp-indent exe --show show a diff of changed results --meld show progressions/regressions using meld --html generate an html page showing the diff of failing tests EOF exit 1 esac shift done TMP=$(mktemp -d /tmp/ocp-indent-test.XXXXX) trap "rm -rf /tmp/ocp-indent-${TMP#/tmp/ocp-indent-}" EXIT ocp-indent() { [ $# -eq 1 ] opts=$(cat $1.opts 2>/dev/null || true) "$OCP_INDENT" $opts "$1" >$TMP/$(basename $1) 2>&1 || true } reffile() { [ $# -eq 1 ] if [ -e "$1.ref" ] then echo "$1.ref" else echo "$1" fi } PASSING=("") FAILING=("") if [ -n "$GIT" ]; then PASSING+=($(git ls-files 'passing/*.ml' 'passing/*.ml[iyl]')) FAILING+=($(git ls-files 'failing/*.ml' 'failing/*.ml[iyl]')) else PASSING+=(passing/*.ml passing/*.ml[iyl]) FAILING+=(failing/*.ml failing/*.ml[iyl]) fi CHANGES=() for f in ${PASSING[@]}; do base=$(basename $f) name=${base%.*} ocp-indent $f if diff -q "$(reffile "$f")" $TMP/$base >/dev/null; then printf "%-12s\t\e[32m[PASSED]\e[m\n" $name else printf "%-12s\t\e[31m[FAILED]\e[m \e[41m\e[30m[REGRESSION]\e[m\n" $name if [ -n "$UPDATE" ]; then mkdir -p failing $GIT mv -f $f* failing/ f=failing/${f#passing/} mkdir -p failing-output cp $TMP/$base failing-output/ if [ -n "$GIT" ]; then $GIT add failing-output/$base; fi fi CHANGES+=($f) fi done for f in ${FAILING[@]}; do base=$(basename $f) name=${base%.*} ocp-indent $f if diff -q $(reffile $f) $TMP/$base >/dev/null; then printf "%-12s\t\e[32m[PASSED]\e[m \e[42m\e[30m[PROGRESSION]\e[m\n" $name if [ -n "$UPDATE" ]; then $GIT mv -f $f* passing/ $GIT rm -f failing-output/$base fi elif [ ! -e failing-output/$base ]; then printf "%-12s\t\e[33m[FAILED]\e[m \e[43m\e[30m[NEW]\e[m\n" $name cp $TMP/$base failing-output/ if [ -n "$GIT" ]; then $GIT add failing-output/$base; fi elif diff -q $TMP/$base failing-output/$base >/dev/null; then printf "%-12s\t\e[33m[FAILED]\e[m\n" $name if [ -n "$GIT" ] && ! is_file_on_git failing-output/$base; then $GIT add failing-output/$base; fi else refcount=$(diff -y --suppress-common-lines \ $(reffile $f) failing-output/$base \ |wc -l) curcount=$(diff -y --suppress-common-lines \ $(reffile $f) $TMP/$base \ |wc -l) progress=$((refcount - curcount)) printf "%-12s\t\e[33m[FAILED]\e[m \e[%dm\e[30m[CHANGE: %+d]\e[m\n" \ $name \ $(if [ $progress -gt 0 ]; then echo 42; \ elif [ $progress -eq 0 ]; then echo 43; \ else echo 41; fi) \ $progress if [ -n "$UPDATE" ]; then mkdir -p failing-output cp $TMP/$base failing-output/ if [ -n "$GIT" ]; then $GIT add failing-output/$base; fi fi CHANGES+=($f) fi done if [ -n "$SHOW" ] && [ ${#CHANGES[@]} -gt 0 ]; then if [ -z "$SHOWCMD" ]; then for f in ${CHANGES[@]}; do echo printf "\e[1m=== Showing differences in %s ===\e[m\n" $f # Custom less buggy version of colordiff -y diff -W 130 -ty $(reffile $f) $TMP/$(basename $f) \ | awk '/^.{64}[^ ].*/ { printf "%s\n",$0; next } 1' \ || true done else echo echo "Meld view:" echo "[reference] [new result] [registered]" echo "You can update reference and registered status from meld" cmd=(meld) for f in ${CHANGES[@]}; do cur=failing-output/$(basename $f) if ! [ -e $cur ]; then cur=; fi cmd+=(--diff $(reffile $f) $TMP/$(basename $f) $cur) done ${cmd[*]} fi elif [ -n "$SHOW" ]; then echo echo "No changes to show. To check the current failures use for example:" echo " meld tests/failing tests/failing-output" fi diff2html() { f1=$1; shift f2=$1; shift [ $# -eq 0 ] echo "
    " echo "

    Differences in $(basename $f1)

    " echo "" echo "" { line=0 XIFS="$IFS" IFS= while read -r l1; do read -r l2 <&3 || true class="correct" if [ "$l1" != "$l2" ]; then class="different" l1=$(sed 's/ /·/g' <<<"$l1") l2=$(sed 's/ /·/g' <<<"$l2") fi echo -n '' echo -n '' echo -n '' echo -n '' echo '' : $((line++)) done while read -r l2 <&3; do l2=$(sed 's/ /·/g' <<<"$l2") echo -n '' echo -n '' echo -n '' echo -n '' echo '' : $((line++)) done IFS="$XIFS" } <$f1 3<$f2 echo "
    ExpectedOcp-indent output
    '$line'
    '"$l1"'
    '"$l2"'
    '$line'
    '"$l2"'
    " echo "
    " } if [ -n "$HTML" ]; then VERSION=$($OCP_INDENT --version | awk '{ print $NF; exit }') if COMMITS_SINCE=$(git log --oneline $VERSION.. 2>/dev/null); then VERSION="$VERSION+$((1+$(wc -l <<<"$COMMITS_SINCE")))" fi VERSION_STRING="$VERSION ($(date +%F))" echo echo -n "Generating summary of failures tests/failing.html..." cat < failing.html Failing tests, ocp-indent version $VERSION_STRING

    Failing tests, ocp-indent version $VERSION_STRING

    EOF complete_success="1" for f in $(git ls-files 'failing/*.ml'); do complete_success= diff2html "$(reffile $f)" "failing-output/${f#failing/}" \ >>failing.html echo -n "." done if [ -n "$complete_success" ]; then echo "

    All tests pass: no currently known bugs.

    " >>failing.html fi cat <>failing.html EOF echo " done" if [ -n "$GIT" ]; then $GIT add failing.html; fi fi exit ${#CHANGES[@]} ocp-indent-1.5.3/tools/000077500000000000000000000000001273277264100147335ustar00rootroot00000000000000ocp-indent-1.5.3/tools/ocp-indent.el000066400000000000000000000103751273277264100173230ustar00rootroot00000000000000;;; ocp-indent.el --- automatic indentation with ocp-indent ;; ;; Copyright 2012-2013 OCamlPro ;; Keywords: ocaml languages ;; URL: http://www.typerex.org/ocp-indent.html ;; All rights reserved.This file is distributed under the terms of the ;; GNU Lesser General Public License version 3.0 with linking ;; exception. ;; TypeRex is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; Lesser GNU General Public License for more details. ;; ;;; Commentary: ;; Description: ;; ocp-indent is a simple tool and library to indent OCaml code. ;; Installation: ;; You need ocp-indent installed on you system to work. ;; Usage: ;; Eval this file to automatically use ocp-indent on caml/tuareg buffers. ;;; Code: (require 'cl) (defgroup ocp-indent nil "ocp-indent OCaml indenter binding configuration" :group 'languages) (defcustom ocp-indent-path "ocp-indent" "*Path to access the ocp-indent command" :group 'ocp-indent :type '(file)) (defcustom ocp-indent-config nil "*Ocp-indent config string, as for its --config option. WARNING: DEPRECATED, this will override any user or project ocp-indent configuration files" :group 'ocp-indent :type '(choice (const nil) (string))) (defcustom ocp-indent-syntax nil "*Enabled syntax extensions for ocp-indent (see option --syntax)" :group 'ocp-indent :type '(repeat string)) (defcustom ocp-indent-allow-tabs nil "*Allow indent-tabs-mode in ocaml buffers. Not recommended, won't work well." :group 'ocp-indent :type '(bool)) (defun ocp-in-indentation-p () "Tests whether all characters between beginning of line and point are blanks." (save-excursion (skip-chars-backward " \t") (bolp))) (defun ocp-indent-args (start-line end-line) (append (list "--numeric" "--lines" (format "%d-%d" start-line end-line)) (if ocp-indent-config (list "--config" ocp-indent-config) nil) (reduce (lambda (acc syn) (list* "--syntax" syn acc)) ocp-indent-syntax :initial-value nil))) (defun ocp-indent-file-to-string (file) (replace-regexp-in-string "\n$" "" (with-temp-buffer (insert-file-contents file) (buffer-string)))) (defun ocp-indent-region (start end) (interactive "r") (let* ((start-line (line-number-at-pos start)) (end-line (line-number-at-pos end)) (errfile (expand-file-name (make-temp-name "ocp-indent-error") temporary-file-directory)) (indents-str (with-output-to-string (if (/= 0 (apply 'call-process-region (point-min) (point-max) ocp-indent-path nil (list standard-output errfile) nil (ocp-indent-args start-line end-line))) (error "Can't indent: %s returned failure" ocp-indent-path)))) (indents (mapcar 'string-to-number (split-string indents-str)))) (when (file-exists-p errfile) (message (ocp-indent-file-to-string errfile)) (delete-file errfile)) (save-excursion (goto-char start) (mapcar #'(lambda (indent) (indent-line-to indent) (forward-line)) indents)) (when (ocp-in-indentation-p) (back-to-indentation)))) (defun ocp-indent-line () (interactive nil) (ocp-indent-region (point) (point))) (defun ocp-indent-buffer () (interactive nil) (ocp-indent-region 0 (buffer-size))) ;;;###autoload (defun ocp-setup-indent () (interactive nil) (unless (and (buffer-file-name) (string= (file-name-extension (buffer-file-name)) "mly")) (unless ocp-indent-allow-tabs (set 'indent-tabs-mode nil)) (when (string= (file-name-extension (buffer-file-name)) "mll") (set (make-local-variable 'ocp-indent-syntax) (cons "mll" ocp-indent-syntax))) (set (make-local-variable 'indent-line-function) #'ocp-indent-line) (set (make-local-variable 'indent-region-function) #'ocp-indent-region))) ;;;###autoload (defun ocp-indent-caml-mode-setup () (ocp-setup-indent) (local-unset-key "\t")) ;; caml-mode rebinds TAB ! (add-hook 'tuareg-mode-hook 'ocp-setup-indent t) (add-hook 'caml-mode-hook 'ocp-indent-caml-mode-setup t) (provide 'ocp-indent) ;;; ocp-indent.el ends here ocp-indent-1.5.3/tools/ocp-indent.vim000066400000000000000000000026471273277264100175210ustar00rootroot00000000000000" Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif let b:did_indent = 1 setlocal expandtab setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0;;,0>\],0\|\],0>},0\|,0},0\],0) setlocal nolisp setlocal nosmartindent setlocal indentexpr=GetOcpIndent(v:lnum) " Comment formatting if !exists("no_ocaml_comments") if (has("comments")) setlocal comments=sr:(*,mb:*,ex:*) setlocal fo+=cqor endif endif " Only define the function once. if exists("*GetOcpIndent") finish endif " Indents are cached for the current buffer; they are only re-used when " indenting lines in sequence and the buffer was unchanged. let s:indents = [] let s:buffer = -1 let s:tick = -1 let s:lnum = -1 function! GetOcpIndent(lnum) if s:buffer == bufnr('') && s:tick == b:changedtick && s:lnum < a:lnum && match(getline(s:lnum + 1, a:lnum - 1),'.') == -1 " Only use cache if there are only blank lines in-between call remove(s:indents, 0, a:lnum - s:lnum - 1) else " Compute indentation from current line on let cmdline = "ocp-indent --numeric --indent-empty --lines " . a:lnum . '-' let s:indents = split(system(cmdline, getline('1','$'))) let s:buffer = bufnr('') let s:tick = b:changedtick endif let s:lnum = a:lnum return s:indents[0] endfunction ocp-indent-1.5.3/tools/tuareg-indent000077500000000000000000000054651273277264100174410ustar00rootroot00000000000000#!/bin/bash -ue # # Copyright 2012-2013 OCamlPro # # All rights reserved.This file is distributed under the terms of the # GNU Lesser General Public License version 3.0 with linking # exception. # # TypeRex is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # Lesser GNU General Public License for more details. # ocp-config-to-tuareg() { while [ $# -gt 0 ]; do case $1 in -c) shift local c="normal,$1" c=$(sed 's/normal/base=2,type=2,in=0,with=0,match_clause=2/' <<<"$c") c=$(sed 's/JaneStreet/base=2,type=0,in=0,with=0,match_clause=2/' <<<"$c") awk 'BEGIN { RS=","; FS="=" } { print $1,$2 }' <<<"$c" | { while read var val; do case "$var" in "base") echo "(setq tuareg-default-indent $val)";; "type") echo "(setq tuareg-type-indent $val)";; "in") echo "(setq tuareg-in-indent $val)";; "with") echo "(setq tuareg-with-indent $val)";; "match_clause") echo "(setq tuareg-match-clause-indent $((val-1)))";; "") ;; *) echo "Error: config option not understood by tuareg conversion: '$var'" >&2 esac done } ;; *) echo "Error: config parameter not understood by tuareg conversion: '$1'" >&2 esac shift done } tuareg-indent() { local f=$1; shift local config=$(ocp-config-to-tuareg $*) # At Jane Street, and perhaps other sites, Tuareg is found via the # user's ~/.emacs, rather than in a standard location in /usr. We # may also wish to compare against standard or custom user config. if [ -n "${TUAREG_INDENT_USE_USER_DOT_EMACS+set}" ]; then local tuareg=${TUAREG_INDENT_USE_USER_DOT_EMACS:-$HOME/.emacs} else local tuareg=$( ls /usr/share/emacs*/site-lisp/tuareg-mode/tuareg.elc 2>/dev/null \ || ls /usr/share/emacs/site-lisp/tuareg-mode/tuareg.el ) fi emacs $f -Q -batch --eval ' (progn (load-file "'"$tuareg"'") (tuareg-mode) '"$config"' (setq indent-tabs-mode nil) (indent-region (point-min) (point-max)) (set-visited-file-name "/dev/stdout") (save-buffer 0)) ' 2>/dev/null || true } # CR-soon pszilagyi: This will whitespace-split individual arguments. args= while [ $# -gt 1 ]; do args="$args $1"; shift; done file=$1 tuareg-indent "$file" $args ocp-indent-1.5.3/uninstall.sh000077500000000000000000000126161273277264100161510ustar00rootroot00000000000000#!/bin/bash if [ -e "$1/bin/ocp-indent" ]; then rm -f "$1/bin/ocp-indent" else echo "Warning: $1/bin/ocp-indent doesn't exist" fi if [ -e "$1/lib/ocp-indent/META" ]; then rm -f "$1/lib/ocp-indent/META" else echo "Warning: $1/lib/ocp-indent/META doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/ocp-indent.lib.a" ]; then rm -f "$1/lib/ocp-indent/lib/ocp-indent.lib.a" else echo "Warning: $1/lib/ocp-indent/lib/ocp-indent.lib.a doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/ocp-indent.lib.cma" ]; then rm -f "$1/lib/ocp-indent/lib/ocp-indent.lib.cma" else echo "Warning: $1/lib/ocp-indent/lib/ocp-indent.lib.cma doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/ocp-indent.lib.cmxa" ]; then rm -f "$1/lib/ocp-indent/lib/ocp-indent.lib.cmxa" else echo "Warning: $1/lib/ocp-indent/lib/ocp-indent.lib.cmxa doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/indentConfig.cmi" ]; then rm -f "$1/lib/ocp-indent/lib/indentConfig.cmi" else echo "Warning: $1/lib/ocp-indent/lib/indentConfig.cmi doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/indentConfig.cmti" ]; then rm -f "$1/lib/ocp-indent/lib/indentConfig.cmti" fi if [ -e "$1/lib/ocp-indent/lib/indentBlock.cmi" ]; then rm -f "$1/lib/ocp-indent/lib/indentBlock.cmi" else echo "Warning: $1/lib/ocp-indent/lib/indentBlock.cmi doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/indentBlock.cmti" ]; then rm -f "$1/lib/ocp-indent/lib/indentBlock.cmti" fi if [ -e "$1/lib/ocp-indent/lib/indentPrinter.cmi" ]; then rm -f "$1/lib/ocp-indent/lib/indentPrinter.cmi" else echo "Warning: $1/lib/ocp-indent/lib/indentPrinter.cmi doesn't exist" fi if [ -e "$1/lib/ocp-indent/lib/indentPrinter.cmti" ]; then rm -f "$1/lib/ocp-indent/lib/indentPrinter.cmti" fi if [ -e "$1/lib/ocp-indent/utils/ocp-indent.utils.a" ]; then rm -f "$1/lib/ocp-indent/utils/ocp-indent.utils.a" else echo "Warning: $1/lib/ocp-indent/utils/ocp-indent.utils.a doesn't exist" fi if [ -e "$1/lib/ocp-indent/utils/ocp-indent.utils.cma" ]; then rm -f "$1/lib/ocp-indent/utils/ocp-indent.utils.cma" else echo "Warning: $1/lib/ocp-indent/utils/ocp-indent.utils.cma doesn't exist" fi if [ -e "$1/lib/ocp-indent/utils/ocp-indent.utils.cmxa" ]; then rm -f "$1/lib/ocp-indent/utils/ocp-indent.utils.cmxa" else echo "Warning: $1/lib/ocp-indent/utils/ocp-indent.utils.cmxa doesn't exist" fi if [ -e "$1/lib/ocp-indent/utils/nstream.cmi" ]; then rm -f "$1/lib/ocp-indent/utils/nstream.cmi" else echo "Warning: $1/lib/ocp-indent/utils/nstream.cmi doesn't exist" fi if [ -e "$1/lib/ocp-indent/utils/nstream.cmti" ]; then rm -f "$1/lib/ocp-indent/utils/nstream.cmti" fi if [ -e "$1/lib/ocp-indent/lexer/ocp-indent.lexer.a" ]; then rm -f "$1/lib/ocp-indent/lexer/ocp-indent.lexer.a" else echo "Warning: $1/lib/ocp-indent/lexer/ocp-indent.lexer.a doesn't exist" fi if [ -e "$1/lib/ocp-indent/lexer/ocp-indent.lexer.cma" ]; then rm -f "$1/lib/ocp-indent/lexer/ocp-indent.lexer.cma" else echo "Warning: $1/lib/ocp-indent/lexer/ocp-indent.lexer.cma doesn't exist" fi if [ -e "$1/lib/ocp-indent/lexer/ocp-indent.lexer.cmxa" ]; then rm -f "$1/lib/ocp-indent/lexer/ocp-indent.lexer.cmxa" else echo "Warning: $1/lib/ocp-indent/lexer/ocp-indent.lexer.cmxa doesn't exist" fi if [ -e "$1/lib/ocp-indent/lexer/approx_tokens.cmi" ]; then rm -f "$1/lib/ocp-indent/lexer/approx_tokens.cmi" else echo "Warning: $1/lib/ocp-indent/lexer/approx_tokens.cmi doesn't exist" fi if [ -e "$1/lib/ocp-indent/lexer/approx_tokens.cmt" ]; then rm -f "$1/lib/ocp-indent/lexer/approx_tokens.cmt" fi if [ -e "$1/lib/ocp-indent/lexer/approx_lexer.cmi" ]; then rm -f "$1/lib/ocp-indent/lexer/approx_lexer.cmi" else echo "Warning: $1/lib/ocp-indent/lexer/approx_lexer.cmi doesn't exist" fi if [ -e "$1/lib/ocp-indent/lexer/approx_lexer.cmt" ]; then rm -f "$1/lib/ocp-indent/lexer/approx_lexer.cmt" fi if [ -e "$1/man/man1/ocp-indent.1" ]; then rm -f "$1/man/man1/ocp-indent.1" else echo "Warning: $1/man/man1/ocp-indent.1 doesn't exist" fi if [ -e "$1/share/ocp-indent/vim/indent/ocaml.vim" ]; then rm -f "$1/share/ocp-indent/vim/indent/ocaml.vim" else echo "Warning: $1/share/ocp-indent/vim/indent/ocaml.vim doesn't exist" fi if [ -e "$1/share/emacs/site-lisp/ocp-indent.el" ]; then rm -f "$1/share/emacs/site-lisp/ocp-indent.el" else echo "Warning: $1/share/emacs/site-lisp/ocp-indent.el doesn't exist" fi if [ -d "$1/share/ocp-indent/vim/indent" ] then rmdir -p "$1/share/ocp-indent/vim/indent" 2>/dev/null fi if [ -d "$1/share/emacs/site-lisp" ] then rmdir -p "$1/share/emacs/site-lisp" 2>/dev/null fi if [ -d "$1/man/man1" ] then rmdir -p "$1/man/man1" 2>/dev/null fi if [ -d "$1/lib/ocp-indent/utils" ] then rmdir -p "$1/lib/ocp-indent/utils" 2>/dev/null fi if [ -d "$1/lib/ocp-indent/lib" ] then rmdir -p "$1/lib/ocp-indent/lib" 2>/dev/null fi if [ -d "$1/lib/ocp-indent/lexer" ] then rmdir -p "$1/lib/ocp-indent/lexer" 2>/dev/null fi if [ -d "$1/lib/ocp-indent" ] then rmdir -p "$1/lib/ocp-indent" 2>/dev/null fi if [ -d "$1/bin" ] then rmdir -p "$1/bin" 2>/dev/null fi if [ -d "$1/lib/ocp-indent" ] then rmdir -p "$1/lib/ocp-indent" 2>/dev/null || echo "Warning: could not remove directory $1/lib/ocp-indent" fi if [ -d "$1/share/ocp-indent" ] then rmdir -p "$1/share/ocp-indent" 2>/dev/null || echo "Warning: could not remove directory $1/share/ocp-indent" fi if [ -d "$1/etc/ocp-indent" ] then rmdir -p "$1/etc/ocp-indent" 2>/dev/null || echo "Warning: could not remove directory $1/etc/ocp-indent" fi if [ -d "$1/doc/ocp-indent" ] then rmdir -p "$1/doc/ocp-indent" 2>/dev/null || echo "Warning: could not remove directory $1/doc/ocp-indent" fi ocp-indent-1.5.3/version.ocp.in000066400000000000000000000005521273277264100163720ustar00rootroot00000000000000version = "@PACKAGE_VERSION@" copyright = [ "OCamlPro 2012-2013" "Copyright 2011 Jun Furuse" ] authors = [ "Louis Gesbert " "Thomas Gazagnaire " "Pierre Chambart " "Jun Furuse " ] license = [ "LGPL-3 with OCaml linking exception" ]