diff --git a/ANNOUNCE b/ANNOUNCE index 82df2ba9e..4954664b5 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,7 +1,7 @@ 1 Announcement ************** -The GNUstep Base Library, version 1.20.1, is now available. +The GNUstep Base Library, version 1.14.0, is now available. 1.1 What is the GNUstep Base Library? ===================================== @@ -18,20 +18,27 @@ portion of the OpenStep standard (the Foundation library). There is more information available at the GNUstep homepage at `http://www.gnustep.org'. -1.2 Noteworthy changes in version `1.20.1' +1.2 Noteworthy changes in version `1.14.0' ========================================== -This is a stable bugfix release. There are no major changes or binary -incompatibilities, but this release does include an update of timezone -handling to include the latest zone information. +Many portability (particularly for ms-windows) and MacOS-X +compatibility fixes. New MacOS-X classes and incorporation of +NSAffineTransform and NSSpellServer which were formerly in the gui +library. Improved performance of amssively multithreaded programs. 1.3 Where can you get it? How can you compile it? ================================================== -The gnustep-base-1.20.1.tar.gz distribution file has been placed at +The gnustep-base-1.14.0.tar.gz distribution file has been placed at `ftp://ftp.gnustep.org/pub/gnustep/core'. Please log bug reports on the GNUstep project page `http://savannah.gnu.org/bugs/?group=gnustep' or send bug reports to . + Copyright (C) 2005 Free Software Foundation + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. + diff --git a/COPYINGv3 b/COPYINGv3 deleted file mode 100644 index a737dcfed..000000000 --- a/COPYINGv3 +++ /dev/null @@ -1,675 +0,0 @@ - - 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 -. diff --git a/ChangeLog b/ChangeLog index 2cfeeba4c..4cd7ab629 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6260 +1,3 @@ -2010-09-24 Richard Frith-Macdonald - - * Source/NSCharacterSet.m: Build using the faster but more memory - hungry implementation. Backported change from trunk. - * Source/NSSocketPort.m: - * Source/NSSortDescriptor.m: - * Source/NSMessagePort.m: - * Source/NSNumber.m: - * Source/GSString.m: - * Source/NSHost.m: - * Source/NSDate.m: - * Source/GSValue.m: - Backport method argument type fixes from trunk - -2010-09-10 Richard Frith-Macdonald - - * Source/NSString.m: backport fixes for initialisation from URL. - * Version 1.20.2 release - -2010-09-08 Richard Frith-Macdonald - - * Headers/Foundation/NSObject.h: - * Source/NSObject.m: - Remove old TypedStream methods - * Source/NSFileManager.m: - Warn if filesystem support is not available. - -2010-09-07 Eric Wasylishen - - * Headers/Additions/GNUstepBase/preface.h.in: Remove include of - objc/sarray.h - -2010-09-04 Niels Grewe - - * config/config.non-fragile-ivars.m: Remove useless include of - objc-common.g (__has_feature is a built-in clang macro). - -2010-08-30 Richard Frith-Macdonald - - * Source/NSThread.m: try to make inter-thread notification via - pipe more robust. - * Source/NSTask.m: make windows thread waiting for task into an - NSThread so that any thread-dependent code can work. - -2010-08-25 Jonathan Gillaspie - - * Source/Objective2/sync.m: Removed weak declarations - -2010-08-24 Wolfgang Lux - - * Source/GSFileHandle.m (-initWithStandardError, - -initWithStandardInput, -initWithStandardOutput): Restore lost - assignments which ensure that only one file handle exists for each - of the standard channels. This fixes a bug where a run loop might - unexpectedly stop watching the standard channels. - -2010-08-23 Riccardo Mottola (patch by Yavor Doganov) - - * configure.ac: Include pthread.h in check program - * configure: Regenerate - -2010-08-20 Richard Frith-Macdonald - - * Source/ObjectiveC2/runtime.c: Made objc_disposeClassPair() a no-op - if the class pair is already registered .. to prevent it from causing - crashes. Made objc_registerClassPair() log error if there is already - a class of the name. - * Source/ObjectiveC2/sync.m: Replace with Greg's implementation - (reported as working though I haven't tested it). - -2010-08-19 Richard Frith-Macdonald - - * configure.ac: Check alignment of pthread types - * configure: Regenerate - * Headers/Additions/GNUstepBase/GSConfig.h.in: Record alignment - -2010-08-18 Richard Frith-Macdonald - - * Source/NSNumber.m: Modifications to permit generation of NIBs that - OSX can read again ... functionality was lost in recent rewrite. - -2010-08-17 Richard Frith-Macdonald - - * Source/NSObject.m: - * Source/NSDistantObject.m: - Return nil from (methodSignatureForSelector:) if the selector is null. - * Source/NSObjcRuntime.m: - Register new selector as needed. - -2010-08-17 Wolfgang Lux - - * Source/NSNotificationQueue.m: remove_from_queue_no_release() - Add assertions instead of existing hack when removing an item - from a corrupted list. - -2010-08-17 Richard Frith-Macdonald - - * Source/NSNotificationQueue.m: notify() .. buffer notifications - and remove from list before posting them. - Prevents re-entrancy problems where another call to notify() could - post (and remove from the list) notifications. - -2010-08-12 Nicola Pero - - * Resources/Languages/Locale.aliases: Added many languages which - were missing from the list. Data taken from - gettext-0.18.1.1/gettext-tools/doc/ISO_639 and - gettext-0.18.1.1/gettext-tools/doc/ISO_639-2. - -2010-08-10 Richard Frith-Macdonald - - * Source/NSTask.m: thread-safety fix. - -2010-08-06 Doug Simons - - * Source/NSCalendarDate.m: Fix to AM/PM parsing to recognize - 12 AM as midnight, not noon. When format calls for a time zone, - return nil if no time zone is given (the same as Cocoa). - -2010-07-26 Nicola Pero - - * Documentation/GNUmakefile (REF_DOC_INSTALL_DIR): Use - GNUSTEP_DOC, not GNUSTEP_DOCUMENTATION, which has been deprecated - for over 3 years. - * Documentation/Makefile.postamble (after-uninstall): Rewritten to - be more accurate. - -2010-07-26 Nicola Pero - - * Source/NSBundle.m ([+_addFrameworkFromClass:]): Added support - for class lists of frameworks with a relative path. If the - framework path is relative, convert it to absolute by prepending - the launch directory to it, since that must be how the dynamic - linker located the framework to load it. - -2010-07-19 Richard Frith-Macdonald - - * Source/NSPathUtilities.m: User domain handling improvements. - Match gnustep-make in allowing absolute paths to be specified for the - user domain directories rather than always treating user domain paths - as being within the user's home directory. - Also, add support for simple field substitution into the path: - '%u' --> user name - '%i' --> user id - '%%' --> '%' - * Documentation/Base.gsdoc: Document the new behavior. - -2010-07-17 Quentin Mathe - - * Tools/autogsdoc.m: - * Tools/AGSParser.m: - Added the ability to generate paragraph markup. Turned off by default. - For each paragraph break ('\n\n' sequence) and when no incompatible - elements exist in the scanned paragraph,

tags can be automatically - inserted (more explanations in -canWrapWithParagraphMarkup: doc). - -2010-03-27 Niels Grewe - - Implement NSNetService and NSNetServiceBrowser on top of the - avahi-client API. Both classes are now abstract superclasses of the - concrete implementations based on the mDNSResponder or avahi-client - APIs. The API to be used can be configured with the - --with-zeroconf-api=API (mdns, avahi, or any) configure-switch. If both - APIs are available, the avahi API will be preferred. - -2010-07-12 Richard Frith-Macdonald - - * Tools/gdomap.c: backport bugfix and diagnostics - -2010-07-02 Richard Frith-Macdonald - - * Backport bugfixes from trunk ... - Fix error in NSBundle lookup of localized resources - Fix unimplemented methods and lack of range checks in keyed archving. - Fix NSURL for keyed coding. - Fix NSZombie handling of -release - Fix class of mutable sets when coding - Fix problem with glibc strerror_r - -2010-06-20 Richard Frith-Macdonald - - * Version 1.20.1 - -2010-06-19 Richard Frith-Macdonald - - * Source/NSUserDefaults.m: Remove inappropriate warning (when library - used without resources). - -2010-06-16 Sergey Golovin - - * Source/NSTimeZone.m: find timezone from localtime file when it's - a copy rather than a link to a file whose name is a timezone name. - -2010-06-16 Richard Frith-Macdonald - - * configure.ac: better control over constant string class - * configure: regenerate - Don't allow build if compiler doesn't let us set the constant string - class ... unless explicitly overridden (add warning). - Explicitly deprecate ffcall - -2010-06-15 Richard Frith-Macdonald - - * Source/NSInvocation: For portability, use NSPageSize() to find - size for page alignment. - * Source/NSString.m: Raise exception on pul pointer passed to - +stringWithCString:encoding: as per OSX. - * Source/Additions/GSXML.m: Fix minor memory leak - * Source/NSArray.m: ([-valueForKey:]) for for @count - -2010-06-15 Riccardo Mottola - - * Source/NSInvocation: - Protect page-aligned and unprotect before freeing. - -2010-06-13 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Fix indirect through null pointer. - -2010-06-12 Richard Frith-Macdonald - - * Source/NSNumber.m: Fix breakage of +numberWith... in subclasses. - -2010-06-12 Yavor Doganov - - * Source/NSZone.m: - * Source/GSPThread.h: - * Source/objc-load.h: - * Source/objc-load.m: - * Source/NSException.m: - * Source/ObjectiveC2/sync.m: - * Source/NSString.m: - * Source/NSDecimalNumber.m: - * Source/NSDecimal.m: - * Source/NSLock.m: - * configure.ac: Use autoconf AC_USE_SYSTEM_EXTENSIONS - * configure: Regenerate - * Headers/Additions/GNUstepBase/config.h.in: Regenerate - Simplification of source code by using autoconf to enable extensions - for Unix98 thread handling etc. - -2010-06-10 Riccardo Mottola - - * Source/ObjectiveC2/sync.m: Attempt of fixing test for - defining _XOPEN_SOURCE again - -2010-06-10 Richard Frith-Macdonald - - * Source/NSSocketPortNameServer.m: Improve automated gdomap startup log - * configure.ac: Don't install gdomap setuid by default. - * configure: regenerate - -2010-06-10 Richard Frith-Macdonald - - * Source/NSString.m: Raise exception if a null pointer is passed to - +stringWithUTF8String: for compatibility with OSX. - * Source/Additions/GSMime.m: Alter hash and isEqual implementations - for headers and document so that copies are equal to the original - and can be stored and looked up in maps. - -2010-06-09 David Wetzel - - * Source/Additions/GSXML.m: - check for NULL string - stringWithUTF8String: raises on OSX if you feed it with a NULL string. - -2010-06-09 Richard Frith-Macdonald - - * configure.ac: Check for gcrypt library for TLS - * configure: Regenerate - * Headers/Additions/GNUstepBase/GSConfig.h.in: Remove unused declaration - * Source/NSProcessInfo.m: log and exit rather than raising exception on - failure to call internal method to set up argv/envp. - * Source/Additions/GSMime.m: Rewrite header parsing to avoid copying - email body unnecessarily. Also attempt to parse multipart body - without copying too much. - -2010-06-09 Yavor Doganov - - *Source/ObjectiveC2/sync.m: Fix test for defining _XOPEN_SOURCE - -2010-06-08 Richard Frith-Macdonald - - * Source/NSPropertyList.m: When encoding OSX binary property list, - try to differentiate between integer and float items which have the - same numeric value (bug #30040). - -2010-06-08 Richard Frith-Macdonald - - * Source/NSURL.m: - Return nil for -path if initialised with empty string ... OSX compat. - -2010-06-08 Richard Frith-Macdonald - - * Source/GSFFIInvocation.m: - Further fixup to earlier invocation breakage ... my previous attempt - didn't cover all cases. - -2010-06-08 Richard Frith-Macdonald - - * Source/GSFFIInvocation.m: - * Source/cifframe.h: - * Source/cifframe.m: - Removed distinction between GC and non-GC code. - -2010-06-07 Richard Frith-Macdonald - - * Source/GSInvocation.h: - * Source/GSFFIInvocation.m: - * Source/NSInvocation.m: - * Source/cifframe.h: - * Source/cifframe.m: - Rework memory management for frame used in FFI invocation so that - the memory has a retain count and multiple invocations can use the - same frame since it looks like the way FFI works, if you cache the - method implementation of a proxy, the same frame memory is re-used - in multiple invocations. - -2010-06-07 Richard Frith-Macdonald - - * Source/GSFFIInvocation.m: Fix breakage caused by David's changes. - * Source/ObjectiveC2/runtime.m: Fix handling of nul arguments in - class_sespondsToSelector(). - -2010-06-05 Richard Frith-Macdonald - - * Tools/Makefile.postamble: Fix breakage of instalation of gdomap - (was installing setuid to wrong user ID!). - -2010-06-02 Richard Frith-Macdonald - - * Source/NSTimeZone.m: revert change of order of sources for zone - info since tzname does not appear to be more reliable than filename. - Allof timezone to be specified as an abbreviation rather than a name. - -2010-06-02 Nicola Pero - - * configure.ac: Added --disable-setuid-gdomap option to disable - installing gdomap as setuid. - * configure: Regenerated. - * config.mak.in (GNUSTEP_INSTALL_GDOMAP_AS_SETUID): New variable. - * Tools/Makefile.postamble: - (after-install): Instal gdomap as setuid only if - GNUSTEP_INSTALL_GDOMAP_AS_SETUID is set to 'yes'. Updated - messages for the changes and generally tidied messages up. - -2010-06-01 Richard Frith-Macdonald - - * Source/NSTimeZone.m: add diagnostic to report the source of the - timezone name when we can't create the local timezone. - Use tzset()/tzname in preference to the name of the default timezone - file ... in case of evil systems where the file has the wrong name. - -2010-06-01 Richard Frith-Macdonald - - * Source/Additions/NSPropertyList+GNUstepBase.m: - New category to replace property list write functionality no longer - present in OSX. - * base.make.in: Link with base additions library on OSX - -2010-05-30 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: ([+encodingFromCharset:]) - Experimental extension to support NSStringEncoding symbolic constants - in string form, in addition to more common characterset names - (primarily for gdl2/gsweb). - -2010-05-30 Richard Frith-Macdonald - - * Source/NSString.m: - * Source/Additions/NSString+GNUstepBase.m: - * Headers/Foundation/NSString.h: - * Headers/Additions/GNUstepBase/NSString+GNUstepBase.h: - Revert last change ... there's no such method as +encodingNamed: - in OSX/OpenStep, so it definitely shouldn't be in NSString.[hm] - I think we can debate whether to add it to the additions library, - though I'm not sure that it's actually a generally useful addition - (if I understand correctly, it's used only in gdl2/gsweb and ought - probably to be a category there ... assuming that there's really - no existing/standard mechanism to do the job). - -2010-05-30 David Wetzel - - * Source/NSString.m - * Source/Additions/NSString+GNUstepBase.m - * Headers/Foundation/NSString.h - * Headers/Additions/GNUstepBase/NSString+GNUstepBase.h - added encodingNamed: - -2010-05-30 Richard Frith-Macdonald - - * Source/NSObject.h: - Floating point fix for openbsd suggested by Sebastian Reitenbach - -2010-05-30 Wolfgang Lux - - * Source/NSAttributedString.m (-initWithCoder:, -encodeWithCoder:): - Fix keyed archiving and unarchiving of (mutable) attributed - strings with multiple attribute ranges. - -2010-05-30 Richard Frith-Macdonald - - * NSTimeZones/NSTimeZones.tar: Update to latest zone info. - -2010-05-29 Richard Frith-Macdonald - - * Source/NSData.m: Attempted fix for bug #29920 - -2010-05-29 Richard Frith-Macdonald - - * Source/NSConcreteHashTable.m: - * Source/NSHashTable.m: In ([-allObjects]) fix buf overrun (bug #29980). - * Source/NSXMLParser.m: Fix off-by-one error handling whitespace. - * Headers/Additions/GNUstepBase/GSMime.h: Revert xml charset method. - * Source/NSURL.m: Allow a URL made from an empty string (OSX compat). - -2010-05-28 Quentin Mathe - - * Source/NSKeyValueCoding.m: Added missing support to ValueForKey() as - described in Apple Key-Value-Coding guide. -isKey is now treated as a - KVC-compliant getter, and _isKey and isKey as KVC-compliant ivars. - -2010-05-25 Richard Frith-Macdonald - - * Source/NSPropertyList.m: ([-parser:foundCharacters:]) don't trim - the supplied string ... we need to retain whitespace around entities - in value test. If inside a element, treat ignorable - whitespace as normal whitespace. - * Source/NSXMLParser.m: Add support for ignorable whitespace so that - it doesn't get handed to the delegate as normal characters. - -2010-05-22 Richard Frith-Macdonald - - * Headers/Foundation/NSObjCRuntime.h: - Remove include of stdint.h ... already included by GSConfig.h - * Source/ObjectiveC2/runtime.h: - Revert 'guarding' of stdint.h inclusion to get things to compile - again ... we *require* stdint.h to be present. - I guess on any system old enough not to have it, the solution - would be to generate and install our own version. - -2010-05-21 Riccardo Mottola - - * Source/ObjectiveC2/runtime.h: - correctly import config.h - -2010-05-21 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSMime.h: Expose xml charset method. - * Source/NSXMLParser.m: Determine correct charset when parsing. - -2010-05-21 Riccardo Mottola - - * Source/inet_pton.c - Source/ObjectiveC2/runtime.h - Headers/Foundation/NSObjCRuntime.h: - Guarded stdint.h inclusion. - -2010-05-19 Richard Frith-Macdonald - - * Source/Additions/GSObjCRuntime.m: GSObjCMethodNames() fix for - bug #29910 - -2010-05-10 Adam Fedor - - * Fix typos, clarify unstable release documentation - -2010-05-08 Adam Fedor - - * Unstable Version 1.21.0 - -2010-05-08 Adam Fedor - - * Version 1.20.0 - -2010-05-06 Richard Frith-Macdonald - - * Tools/gdomap.c: Limit config files to containing a thousand entries - for safety/security. - -2010-05-05 Richard Frith-Macdonald - - * Source/GSHTTPURLHandle.m: - * Source/NSURLProtocol.m: - Fix for bug #29764 ... add percent escapes to the path when generating - the URI in the HTTP request. - -2010-05-05 Richard Frith-Macdonald - - * Source/Tools/gdomap.c: security updates. - * Tools/Makefile.postamble: make warning messages a bit clearer and - more informative about gdomap being best started at system boot. - -2010-05-03 Richard Frith-Macdonald - - * Headers/Foundation/NSString.h, - * Source/NSString.m: Add 10.4 write methods. - Fixes part of bug report #29736. - -2010-05-02 Fred Kiefer - - * Headers/Foundation/NSString.h, - * Source/NSString.m: Add a few missing 10.4 initWithContentsOfXXX: - methods. Fixes part of bug report #29736. - -2010-05-01 Wolfgang Lux - - * Source/Additions/GSObjCRuntime.m (GSObjCAllSubclassesOfClass): - Fix bug in previous change that made GSObjCAllSubclassesOfClass - return all superclasses instead of all subclasses. - -2010-04-30 Richard Frith-Macdonald - - * Source/Additions/GSObjCRuntime.m: - Attempt fix for bug #29720 - -2010-04-26 Wolfgang Lux - - * Source/NSObject.m (GSAtomicIncrement, GSAtomicDecrement): Use - local labels in PowerPC assembler code to avoid a compile error - when this code is inlined more than once. In addition, use the - optimized assembler definitions also on PowerPC machines running - Darwin/Mac OS X. - -2010-04-23 Richard Frith-Macdonald - - * Source/Additions/NSFileHandle+GNUstepBase.m: fix to only build on OSX - -2010-04-22 David Wetzel - - * Source/Additions/Unicode.m: replace objc_malloc with NSZoneMalloc - and objc_free with NSZoneFree - - * Source/Additions/NSFileHandle+GNUstepBase.m: should work with ipv6 - (The old code does fail on Snow Leopard, even with ipv4 addresses.) - - * Source/Additions/GSXML.m: added GSObjCRuntime.h - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - replace objc_malloc with NSZoneMalloc and objc_free with NSZoneFree - - -2010-04-21 Richard Frith-Macdonald - - * Source/NSBundle.m: ([mainBundle]) Fix error determining whether - the bundle is an app or not ... was breaking lookup of tool resources. - -2010-04-19 Richard Frith-Macdonald - - * Source/cifframe.m (cifframe_type): Fix the cached information - for the NSRange type. Was causing incorrect forwarding of NSRange - arguments on 64bit systems. - -2010-04-18 Nicola Pero - - Fixed inefficiencies in building the SSL bundle. - * SSL/Makefile.postable: Do not create GNUSTEP_TARGET_DIR/config.h - from config.h; do not depend on config.status. - * SSL/Makefile.preamble: Corresponding updates to includes. - -2010-04-18 Nicola Pero - - Fixed bug 25356 ("make ignoring installation domain configuration - on windows"). - * configure.ac: Moved the path configuration here so that it is - executed at the right time. Removed duplicated code for all the - path config options. (AC_CONFIG_SUBDIRS): Removed - Source/pathconfig. - * configure: Regenerated. - * config.mak.in: Merged code from - Source/pathconfig/pathconfig.mak.in. - * Source/pathconfig: Removed. - * GNUmakefile: Do not include - Source/pathconfig/pathconfig.mak. - * Documentation/GNUmakefile: Same change. - * NSTimeZones/GNUmakefile: Same change. - * Source/GNUmakefile: Same change. - * SSL/GNUmakefile: Same change. - * Tools/GNUmakefile: Same change. - * Source/Makefile.postamble (after-distclean): Do not remove - files in pathconfig/. - * Source/NSPathUtilities.m: Do not include pathconfig.h. - * GNUmakefile: Include config.mak after common.make. - - * configure.ac: Exit immediately if GNUSTEP_MAKEFILES can not be - determined. - * configure.ac: Fixed determining GNUSTEP_LOCAL_HEADERS and - GNUSTEP_LOCAL_LIBRARIES when adding them to CPPFLAGS and LDFLAGS. - Add GNUSTEP_NETWORK_HEADERS and GNUSTEP_NETWORK_LIBRARIES as well. - -2010-04-18 Nicola Pero - - * configure.ac (AC_CONFIG_SUBDIRS): Fixed list of subdirs by - removing Source/mframe, which no longer exists. - * configure: Regenerated. - -2010-04-16 Richard Frith-Macdonald - - * Source/NSThread.m: Fix unregistering of threads to properly clean - up and deallocate, avoiding descriptor and memory leak. - -2010-04-15 Richard Frith-Macdonald - - * Source/NSConnection.m: when decoding a pointer to an object, - autorelease the object to avoid a leak. - -2010-04-14 Richard Frith-Macdonald - - * Source/ObjectiveC2/runtime.c: work around buggy objc_skip_argspec() - * Source/NSConnection.m: work around buggy objc_skip_argspec() - * Source/NSObjCRuntime.m: Fix NSGetSizeAndAlignment() so it's OSX - compatible and can be used to replace objc_skip_argspec() (as that - function calls objc_skip_offset() which can skip a character too far). - -2010-04-13 Richard Frith-Macdonald - - * Source/NSArray.m: ([-initWithContentsOfFile:]) added ugly OSX - compatibility hack ... return the mutable array deserialized from - the property list rather than an instance of the same class as - the receiver. The original GNUstep behavior made more sense. - -2010-04-13 Richard Frith-Macdonald - - * Source/NSNotificationQueue.m: Fix error traversing queue. - Reverse direction of links in queue to be intuitive/consistent - with other linked lists. - -2010-04-12 Nicola Pero - - * configure.ac: Rewritten test for -Wdeclaration-after-statement - to be more accurate. - * configure: Regenerated. - -2010-04-12 Richard Frith-Macdonald - - * Source/NSObject.m: - * Headers/Foundation/NSObject.h: Document behavior of +load and - +initialize to preserve information I'm sure I once knew but had - forgotten. Obscure details. - -2010-04-07 Doug Simons - - * Source/NSPathUtilities.m: Prefer USERPROFILE for the - NSHomeDirectory() on Windows if HOMEPATH is set to '\'. - -2010-04-07 Richard Frith-Macdonald - - * configure.ac: Fix for bug #29291 based on suggestion by Niels Grewe - * Source/GSFileHandle.m: Fix possible descriptor leak. - -2010-04-06 Wolfgang Lux - - * Source/cifframe.m (cifframe_type): Fix the defunct test for the - standard structure types. The failure to detect those types was - causing a substantial space leak in some gui applications. - -2010-03-29 Richard Frith-Macdonald - - * config/config.ffi.c: add test for libffi functionality - * configure.ac: use new test - * configure: regenerate - Greg had the good idea of testing libffi version to make sure it - works ... unfortunately I couldn't see an easy way to test the - version, so I added a test for functionality adapted from the - test case I made for the libffi people to demonstrate a bug in - passing floats on 64bit intel. - -2010-03-28 Richard Frith-Macdonald - - * Source/NSDecimalNumber.m: override getter methods of superclass - -2010-03-27 Richard Frith-Macdonald - - * Headers/Foundation/NSException.h: - Fix typos in last change (spotted by Eddie McCreary). - -2010-03-03 Doug Simons - - * Source/ObjectiveC2/sync.m: Avoid crash on Windows. - -2010-03-25 Riccardo Mottola - - * Source/GSPThread.h - * Source/NSZone.m - * Source/ObjectiveC2/sync.m - * Source/NSLock.m: - change defines for GNU/HURD - -2010-03-23 Riccardo Mottola - - * Source/NSObject.m: Atomic increment and decrement functions for mips - -2010-03-19 Richard Frith-Macdonald - - * config/config.reuseaddr.c: - * Examples/nsconnection_client.m: - * Examples/nsconnection_server.m: - * Headers/Additions/GNUstepBase/GSConfig.h.in: - * Headers/Additions/GNUstepBase/GSFileHandle.h: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - * Headers/Additions/GNUstepBase/preface.h.in: - * Headers/Foundation/NSPort.h: - * Headers/Foundation/NSRunLoop.h: - * Source/Additions/NSError+GNUstepBase.m: - * Source/Additions/NSTask+GNUstepBase.m: - * Source/cifframe.h: - * Source/GSFileHandle.m: - * Source/GSHTTPURLHandle.m: - * Source/GSNetwork.h: - * Source/GSPortPrivate.h: - * Source/GSPrivate.h: - * Source/GSRunLoopCtxt.h: - * Source/GSRunLoopWatcher.m: - * Source/GSSocketStream.m: - * Source/GSStream.m: - * Source/NSBundle.m: - * Source/NSCalendarDate.m: - * Source/NSConnection.m: - * Source/NSData.m: - * Source/NSDebug.m: - * Source/NSException.m: - * Source/NSFileManager.m: - * Source/NSHost.m: - * Source/NSInvocation.m: - * Source/NSLog.m: - * Source/NSObject.m: - * Source/NSPage.m: - * Source/NSPathUtilities.m: - * Source/NSPipe.m: - * Source/NSProcessInfo.m: - * Source/NSSocketPort.m: - * Source/NSSocketPortNameServer.m: - * Source/NSString.m: - * Source/NSTask.m: - * Source/NSThread.m: - * Source/NSTimeZone.m: - * Source/NSURL.m: - * Source/NSUserDefaults.m: - * Source/objc-load.m: - * Source/ObjectiveC2/blocks_runtime.m: - * SSL/GSSSLHandle.m: - * Tools/gdnc.m: - * Tools/gdomap.c: - * Tools/gspath.m: - Use __MINGW__ rather than __MINGW32__ for windows tests. - -2010-03-18 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: - * Headers/Additions/GNUstepBase/GSMime.h: - GSMimeSMTPClient code to send emails now working ... but still very - experimental. - -2010-03-18 Richard Frith-Macdonald - - * configure.ac: - * config.mak.in: - * Source/ObjectiveC2/GNUmakefile: - Only build objc synchronisation compatibility code if it is not - already in runtime. - -2010-03-17 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: - Added preliminary/experimental code for SMTP send. - -2010-03-17 Richard Frith-Macdonald - - * configure: - * configure.ac: - * Headers/Additions/GNUstepBase/GSConfig.h.in: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - Add experimental --enable-mixedabi configure option for building - with the nonfragile abi, but able to link with other code which - is built with the fragile abi. - -2010-03-17 Richard Frith-Macdonald - - * Source/NSConnection.m: Fix for memory leak ... autorelease - objects returned by method in remote process because the invocation - won't do it for us (we call -setReturnValue: which will have the - invocation retain the object, so when it releases it again later - the retain count is the same as at the point when we decoded the - object, and another release is needed). - I'm not certain this fix is right, but it seems ok. - -2010-03-13 Yavor Doganov (tiny change) - - * Source/NSCalendarDate.m (outputValueWithFormat) - ([-initWithString:calendarFormat:locale:]): Recognize %k as - conversion format specifier. - ([-descriptionWithCalendarFormat:locale:]): Update docstring. - -2010-03-17 Anibal Rindisbacher - - * Headers/Additions/GNUstep/GNUstep.h: Tidy up casts - -2010-03-16 Vincent Richomme - - * Source/Additions/NSFileHandle+GNUstepBase.m: - * Tools/gdomap.c: - Minor tweaks porting to mingw64 - -2010-03-16 Richard Frith-Macdonald - - * Source/NSCharacterSet.m: Optimise for cases when huge ranges of - characters are added to a set (as suggested by Fred). - -2010-03-15 Adam Fedor - - Source/Additions/NSFileHandle+GNUstepBase.m: Define INADDR_NONE - for Solaris. - -2010-03-15 Fred Kiefer - - * Source/NSString.m (-initWithCoder:): Handle format used for - XIB encoding. - -2010-03-14 Adam Fedor - - * Source/NSHTTPCookie.m (+requestHeaderFieldsWithCookies:): - Correct format syntax. - -2010-03-13 Richard Frith-Macdonald - - * configure.ac: Note use of nonfragile abi - * configure: regenerate - * Headers/Additions/GNUstepBase/GSConfig.h.in: save nonfragile abi state - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - Fix check for nonfragile-abi state, and raise an error if the current - compile doesn't atch the state used to build the base library. - -2010-03-12 Richard Frith-Macdonald - - * Source/NSKeyedArchiver.m: - Create _+clsMap lazily so it's there for subclasses even if the - initialiser was not called. - -2010-03-11 12:14-EST Gregory John Casamento - - * Source/GNUmakefile: Remove reference to synchonization.m. - * Source/synchronization.m: Remove, since ObjectiveC2 has been - merged. - -2010-03-11 Richard Frith-Macdonald - - * configure: - * config.mak.in: - * NSCharacterSets/GNUmakefile: - * Source/unix/Makefile.preamble: - * Source/win32/Makefile.preamble: - * Source/ObjectiveC2/Makefile.preamble: - * Source/Additions/Makefile.preamble: - * Source/Makefile.preamble: - * SSL/Makefile.preamble: - * configure.ac: - * Documentation/manual/GNUmakefile: - * Resources/GNUmakefile: - * Examples/Makefile.preamble: - * Examples/GNUmakefile: - * Tools/Makefile.preamble: - * Tools/make_strings/GNUmakefile.preamble: - Improve setting of warning flags. - -2010-03-11 Richard Frith-Macdonald - - * Source/NSException.m: - * configure.ac: - * configure: - * Headers/Foundation/NSException.h: - * Headers/Additions/GNUstepBase/GSConfig.h.in: - Improve checks for native-objc-exception support and try to ensure that - user code is build with the same settings as base. - -2010-03-10 Adam Fedor - - * Source/NSURLProtocol.m ([_NSHTTPURLProtocol -stream:stream:event]): - Add default Content-Type to POST methods if none is present. - -2010-03-09 Adam Fedor - - * Source/NSHTTPCookie.m: Finish off implementation - * Source/HSHTTPCookieStorage.m: Finish off implementation. - -2010-03-10 Riccardo Mottola - - * /Source/ObjectiveC2/sync.m, - * /Source/NSZone.h, - * /Source/GSPThread.h : use proper _XOPEN_SOURCE - instead of __USE_UNIX98 to enable needed thread features on glibc - -2010-03-08 Roland Schwingel - - * Source/NSFileManager.m: implement fileSystemNumber for mswindows. - -2010-03-08 Richard Frith-Macdonald - - * Source/NSObject.m: - * Source/Additions/GSObjCRuntime.m: - * Documentation/Base.gsdoc: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Add GNUSTEP_BEHAVIOR_DEBUG enovironment variable to turn on logging - of the use of behaviors/overrides of class methds by a list of - methods from another class. - -2010-03-08 Richard Frith-Macdonald - - * Source/GSArray.m: Re-remove [GSMutableArray count] (GSMutableArray - uses the GSArray implementation). - * Source/GSDictionary.m: - * Source/GSCountedSet.m: - * Source/GSSet.m: - Add the same sort of NSUInteger fixups that Fred added to GSArray.m - * Headers/Additions/GNUstepBase/GSUnion.h: - Add support for NSInteger and NSUInteger (so GSCountedSet can use them). - -2010-03-07 Fred Kiefer - - * Source/GSArray.m: Re-add [GSMutableArray count]. Change all - method parameters from int or unsigned to NSUInteger to match - super classes. - -2010-03-07 Richard Frith-Macdonald - - * Source/Additions/GSObjCRuntime.m: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Add function to add 'overrides' as a form of programmatically - controlled category similar to behaviors, giving an app control - over the order in which methods are added to a class. - -2010-03-05 Richard Frith-Macdonald - - * Source/Additions/GSCompatibility.h: - * Source/Additions/GSCompatibility.m: - * Source/Additions/GSNextRuntime.m: - Remove obsolete OSX compatibility files. - -2010-03-05 Richard Frith-Macdonald - - * Source/GSArray.m: - * Source/GSDictionary.m: - * Source/NSURLProtocol.m: - * Source/NSNotificationCenter.m: - * Source/GSAttributedString.m: - * Source/NSURL.m: - * Source/NSObject.m: - * Source/NSString.m: - * Source/Additions/NSAttributedString+GNUstepBase.m: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/GSString.m: - * Source/NSData.m: - * Source/GSValue.m: - * Source/NSValue.m: - * Source/NSArchiver.m: - * Source/NSURLConnection.m: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Remove reference to GSObjCZone and use -zone instead. - -2010-03-05 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - * Source/Additions/GSObjCRuntime.m: - Old 'experimental/work-in-progress' functions mostly removed ... - GSAllocMethodList() GSAppendMethodToList() GSRemoveMethodFromList() - GSMethodListForSelector() GSMethodFromList() GSAddMethodList() - GSRemoveMethodList() - Other functions rewritten in terms of the new runtime API and marked - as deprecated if they add nothing. - -2010-03-04 Richard Frith-Macdonald - - * Source/NSKeyValueObserving.m: use class_addMethod() to add setters - to replacement class. - -2010-03-03 Richard Frith-Macdonald - - * Source/NSDate.m: Fix last change to conform to coding standards. - * Source/NSCalendarDate.m: Fix last change to avoid attempts to - access beyond the end of the format string. - -2010-03-03 Richard Frith-Macdonald - - * Source/ObjectiveC2/runtime.c: Fix class data copying functions to - match OSX. - * Source/Additions/GSObjCRuntime.m: Implement adding classes using - new runtime functions. - -2010-03-03 Doug Simons - - * Source/NSDate.m: Fix natural language date parsing to handle AM/PM. - * Source/NSCalendarDate.m: Fix to %I (12-hour clock) to show midnight - hour as 12, not 00. Skip over field widths while parsing in init. - -2010-03-03 Richard Frith-Macdonald - - * Source/ObjectiveC2/runtime.c: Bugfixes for getting superclass and - for adding ivars to a class. - * Source/Additions/GSObjCRuntime.m: Rewrite class creation code in - terms of the new runtime api. - -2010-03-01 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/behavior.h: - * Source/Additions/behavior.m: - * Source/Additions/GNUmakefile: - Remove obsolete, unused, and long deprecated code. - The functinality is still present in GSObjCRuntime.[hm] - -2010-03-01 Richard Frith-Macdonald - - * Headers/Foundation/NSObjCRuntime.h: - * Source/NSObjCRuntime.m: - Fix NSGetSizeAndAlignment() update argument types to match lates OSX - -2010-02-28 Richard Frith-Macdonald - - Update header files with further changes for non-fragile-abi. - Also fixup some GSObjCRuntime.m functions for using the new runtime - API. - -2010-02-28 Thomas Gamper - - * runtime.c: - Backport another one of David's fixes for @synchronize(class), all - necessary flags now are set in objc_allocateMetaClass. - -2010-02-27 Richard Frith-Macdonald - - * runtime.c: - * sync.m: - * runtime.h: - Backport David's fixes for @synchronize(class), suitably modified to - build with older compilers. - -2010-02-27 Richard Frith-Macdonald - - * Source/NSObject.m: ([methodSignatureForSelector:]) remote the check - (and exception) to see if the sel types are the same as the signature - types, since this method is used precisesly when we think we may have - a selector with the wrong type information (eg we are using KVC and - generated the selector name to access an ivar and the runtime gave us - a selector with the type infor for accessing an ivar of another class). - Should fix bug #29015 - -2010-02-26 Richard Frith-Macdonald - - * Source/NSBundle.m: Apply suggested fix for bug #29012 - -2010-02-26 Richard Frith-Macdonald - - * Source/NSOperation.m: - * Source/GSInternal.h: - * Source/NSConnection.m: - * Headers/Foundation/NSConnection.h: - * Headers/Foundation/NSOperation.h: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - Rework hiding of instance variables for big classes (lots of ivars) - where we expect the class lifetime to be long enough that it makes - sense to hod the ivars in a private subclass. - -2010-02-26 Richard Frith-Macdonald - - * Source/NSNetServices.m: - * Source/NSURLHandle.m: - * Source/NSMethodSignature.m: - * Source/NSInvocation.m: - * Source/NSURL.m: - * Source/Additions/Makefile.preamble: - * Source/Additions/NSObject+GNUstepBase.m: - * Source/Additions/GSFunctions.m: - * Source/Additions/NSAttributedString+GNUstepBase.m: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/NSConnection.m: - * Source/NSLock.m: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Alterations to build additions with NO_GNUSTEP defined ... after all, - they should be able to build like that on OSX with the Apple Foundation. - -2010-02-25 Richard Frith-Macdonald - - * Source/NSIndexPath.m: - * Source/NSTimeZone.m: - * Source/NSURLCredential.m: - * Source/GSSocketStream.m: - * Source/NSURLHandle.m: - * Source/NSTimer.m: - * Source/NSScanner.m: - * Source/NSDistributedNotificationCenter.m: - * Source/NSSocketPort.m: - * Source/NSAttributedString.m: - * Source/NSRunLoop.m: - * Source/NSMethodSignature.m: - * Source/GSRunLoopWatcher.m: - * Source/GSArray.m: - * Source/GSFFCallInvocation.m: - * Source/NSKeyValueMutableSet.m: - * Source/GSStream.m: - * Source/NSKeyedArchiver.m: - * Source/unix/NSStream.m: - * Source/NSKeyedUnarchiver.m: - * Source/NSDistributedLock.m: - * Source/NSKeyValueObserving.m: - * Source/GSHTTPURLHandle.m: - * Source/NSURLCredentialStorage.m: - * Source/NSPort.m: - * Source/GSFFIInvocation.m: - * Source/NSMessagePort.m: - * Source/GSDictionary.m: - * Source/win32/GSFileHandle.m: - * Source/win32/NSMessagePort.m: - * Source/win32/NSStream.m: - * Source/GSCountedSet.m: - * Source/NSUnarchiver.m: - * Source/NSInvocation.m: - * Source/NSURLProtocol.m: - * Source/GSAttributedString.m: - * Source/NSKeyValueMutableArray.m: - * Source/NSException.m: - * Source/NSCopyObject.m: - * Source/NSURL.m: - * Source/NSObject.m: - * Source/NSString.m: - * Source/Additions/NSFileHandle+GNUstepBase.m: - * Source/Additions/GCDictionary.m: - * Source/Additions/GCArray.m: - * Source/Additions/GSXML.m: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/Additions/GSLock.m: - * Source/GSSet.m: - * Source/NSNotification.m: - * Source/NSNumber.m: - * Source/GSString.m: - * Source/NSConnection.m: - * Source/NSAutoreleasePool.m: - * Source/NSThread.m: - * Source/NSData.m: - * Source/NSHost.m: - * Source/NSDate.m: - * Source/GSValue.m: - * Source/NSValue.m: - * Source/NSCountedSet.m: - * Source/GSFileHandle.m: - * Source/NSLock.m: - * Source/NSSet.m: - * Source/NSCharacterSet.m: - * SSL/GSSSLHandle.m: - Always DESTROY(self) rather than RELEASE(self) so that the pointer - is nil if/when another method is called from the method where self - was potentially deallocated. This is so that the libobjc2 runtime - doesn't try dereferencing self when it points to a deallocated - object. - -2010-02-25 Richard Frith-Macdonald - - * configure.ac: - * configure: - * Headers/Additions/GNUstepBase/config.h.in: - * Source/NSString.m: - Update printf handling for very latest glibc - -2010-02-25 Richard Frith-Macdonald - - * configure.ac: Add test for socklen_t type - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * Source/GSNetwork.h: - * Source/NSSocketPort.m: Fix for socklen_t - * Source/NSMapTable.m: - * Source/GSHTTPURLHandle.m: - * Source/NSConcreteMapTable.m: - * Source/NSConcreteHashTable.m: - * Headers/Foundation/NSHashTable.h: - * Headers/Foundation/NSMapTable.h: - Use NSUInteger values for OSX API compatibility - -2010-02-25 Richard Frith-Macdonald - - * Source/ObjectiveC2/runtime.c: - * Source/ObjectiveC2/blocks_runtime.m: - Avoid compiler warnings. - -2010-02-25 Richard Frith-Macdonald - - * Source/NSAssertionHandler.m: - * Source/NSObject.m: - * Source/Additions/NSDebug+GNUstepBase.m: - * Source/Additions/GSMime.m: - * Source/Additions/NSObject+GNUstepBase.m: - * Headers/Foundation/NSObject.h: - * Headers/Additions/GNUstepBase/NSObject+GNUstepBase.h: - Remove a few old deprecated methods and move others to the - additions library. - Make GSMime build on OSX - -2010-02-23 Riccardo Mottola - - * Source/ObjectiveC2/runtime.h: provide gcc-style macros - * Source/ObjectiveC2/sync.m: removed c99-ism - -2010-02-23 Fred Kiefer - - * Source/NSNumber.m: Autorelease the values returned by the - numberWithXXX: methods. - -2010-02-22 Wolfgang Lux - - * Source/NSSpellServer.m (-isWordInUserDictionaries:caseSensitive:): - Make sure word is checked against the current list of ignored - words regardless of whether the user (already) has a set of - learned words in the current language. - -2010-02-22 Wolfgang Lux - - * Source/Additions/Unicode.m (GSToUnicode): Fix my own bug fix to - avoid potential null pointer dereferences, as that fix could lead - to attempts to free() memory on the stack. - -2010-02-22 Richard Frith-Macdonald - - * Source/NSIndexPath.m: - * Source/NSPortCoder.m: - * Source/NSCalendarDate.m: - * Source/NSPropertyList.m: - * Source/GSConcreteValueTemplate.m: - * Source/NSScanner.m: - * Source/GSFFCallInvocation.m: - * Source/NSKeyValueObserving.m: - * Source/NSSortDescriptor.m: - * Source/GSFFIInvocation.m: - * Source/NSUnarchiver.m: - * Source/NSInvocation.m: - * Source/NSFileManager.m: - * Source/NSString.m: - * Source/NSObject.m: - * Source/NSConcreteMapTable.m: - * Source/Additions/GSObjCRuntime.m: - * Source/GSSet.m: - * Source/GSString.m: - * Source/NSConnection.m: - * Source/NSAutoreleasePool.m: - * Source/NSData.m: - * Source/NSDate.m: - * Source/NSProxy.m: - * Source/NSObjCRuntime.m: - * Source/NSProtocolChecker.m: - * Source/GSValue.m: - * Source/NSSerializer.m: - * Source/NSCountedSet.m: - * Source/NSSet.m: - * Source/NSDistantObject.m: - * Source/NSArchiver.m: - * Source/NSCharacterSet.m: - * Source/NSConcreteHashTable.m: - * Headers/Additions/GNUstepBase/NSDebug+GNUstepBase.h: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Deprecate some GS... runtime wrappers in favour of using the new - ObjC2 API where we have emulation for systems which are actually - usig the old API. Work in progress. - -2010-02-21 Richard Frith-Macdonald - - * Source/GSString.m: Fix incorrectly initialized zone ivar. - Foixes bug #28939 - -2010-02-20 Richard Frith-Macdonald - - * Headers/Foundation/NSURL.h: - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSCalendarDate.h: - * Headers/Foundation/NSBundle.h: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSAttributedString.h: - * Headers/Foundation/NSUserDefaults.h: - * Headers/Foundation/NSThread.h: - * Headers/Foundation/NSData.h: - * Headers/Foundation/NSArray.h: - * Headers/Foundation/NSDebug.h: - * Headers/Foundation/NSFileHandle.h: - * Headers/Foundation/NSValue.h: - * Headers/Foundation/NSLock.h: - * Headers/Foundation/NSTask.h: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Modified the sense of the 'NO_GNUSTEP' preprocessor constant slightly. - It is now always defined (GSVersionMacros.h defines it to zero if it - was not defined externally). A sbefore, defining it to 1 should prevent - the inclusion of GNUstep specific headers. - This change should make it easy for us to change the default behavior - at a later date. - -2010-02-20 Richard Frith-Macdonald - - * Source/Makefile.postamble: - * Source/GNUmakefile: - * configure.ac: - * configure: - * Headers/Additions/GNUstepBase/GSConfig.h.in: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Make runtime.h objc2 compatibility header available in installed - headers if we are using objc2 compatibility in base. - -2010-02-19 Richard Frith-Macdonald - - * Source/NSConcreteNumber.h: Remove unused file - * Source/NSNumberMethods.h: - * Source/NSNumber.m: - * Source/GSNumberTypes.h: - Updates to match OSX behavior. - -2010-02-19 Richard Frith-Macdonald - - * configure.ac: Add check for ObjC2 support in runtime. - * config.mak.in: define OBJC2RUNTIME to yes or no - * configure: regenerate - * Source/GNUmakefile: Build/link ObjectiveC2 compat code if needed - * Source/ObjectiveC2/Availability.h: - * Source/ObjectiveC2/runtime.c: - * Source/ObjectiveC2/GNUmakefile: - * Source/ObjectiveC2/properties.m: - * Source/ObjectiveC2/sync.m: - * Source/ObjectiveC2/blocks_runtime.m: - Attempt to build in ObjectiveC2 compatibility functions when we don't - have an ObjC2 runtime. - -2010-02-19 Richard Frith-Macdonald - - Simplify header imports with common headers handled in the correct - order. - -2010-02-18 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/NSDebug+GNUstepBase.h: - * Headers/Additions/GNUstepBase/NSThread+GNUstepBase.h: - * Source/Additions/NSDebug+GNUstepBase.m: - * Source/Additions/NSThread+GNUstepBase.m: - * Headers/Additions/GNUstepBase/Additions.h: - * Headers/Foundation/Foundation.h: - * Headers/Foundation/NSDebug.h: - * Headers/Foundation/NSThread.h: - * Source/Additions/GNUmakefile: - * Source/DocMakefile: - * Source/GNUmakefile: - * Source/NSDebug.m: - * Source/NSOperation.m: - Move some gnustep specific extensions into additions library so they - can be used to port apps to OSX in future (when the additions library - builds on OSX again). - -2010-02-18 Richard Frith-Macdonald - - * SSL/configure.ac: Check for latest thread ID callback - * SSL/configure: regenerate - * SSL/GSSSLHandle.m: Add thread-safety support callbacks. - -2010-02-18 Richard Frith-Macdonald - - * Source/GNUmakefile: - * Headers/Foundation/NSURL.h: - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSCalendarDate.h: - * Headers/Foundation/NSBundle.h: - * Headers/Foundation/Foundation.h.install: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSAttributedString.h: - * Headers/Foundation/NSData.h: - * Headers/Foundation/NSArray.h: - * Headers/Foundation/NSFileHandle.h: - * Headers/Foundation/NSValue.h: - * Headers/Foundation/NSLock.h: - * Headers/Foundation/NSTask.h: - * Tools/GNUmakefile: - Have standard foundation headers include any corresponding GNUstep - extension headers unless NO_GNUSTEP is defined (building code with - strict OSX compatibility) or GNUSTEP_BASE_INTERNAL is defined - (building the base library etc itsself, and needing to ensure we - don't accidentally include installed headers from a previous version). - -2010-02-18 Richard Frith-Macdonald - - * Source/NSSpellServer.m: - * Source/NSMethodSignature.m: - * Source/NSString.m: - * Headers/Foundation/NSSpellServer.h: - * Headers/Foundation/NSObjCRuntime.h: - Fix minor 64bit compatribility errors spotted by Fred. - -2010-02-18 Richard Frith-Macdonald - - * configure.ac: remove obsolete checks for integer limits constants - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * configure: regenerate - * Source/NSScanner.m: - * Source/NSNumber.m: - * Source/GSFormat.m: - New code to define LLONG_MAX,LLONG_MIN,ULLONG_MAX in terms of - __LONG_LONG_MAX__ where they are not found in the normal location. - -2010-02-16 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSXML.h: - * Source/Additions/GSXML.m: new method to allow an additional DTD - directory to be set for the parser. - * Tools/autogsdoc.m: Add flag to allow command line setting of extra - DTD directory. - * Source/DocMakefile: Set extra DTD directory to the Tools directory - so that gsdoc DTDs can be found even when they haven't been installed. - -2010-02-16 Niels Grewe - - * Source/Additions/GSXML.m: - Modify to use default catalog when GNUstep specific information - cannot be found. - -2010-02-16 Richard Frith-Macdonald - - * Source/NSDistantObject.m: - Cache method signatures to avoid asking remote end for them - repeatedly. - -2010-02-16 Wolfgang Lux - - * Source/Additions/Unicode.m (GSToUnicode): Fix bug where - GSToUnicode attempted to read from a null pointer. - -2010-02-15 Richard Frith-Macdonald - - Various reorganisation tweaks. - Enable NSInteger/NSUInteger/CGFloat support at last. - -2010-02-15 Fred Kiefer - - * Source/NSAttributedString.m: Implement keyed decoding for - multiple attributes correctly. - Based on code by Nikolaus Schaller . - -2010-02-14 David Chisnall - - Rewrote NSNumber implementation. - -2010-02-14 Richard Frith-Macdonald - - Major change merge back of 'reorg' branch into trunk. - The gross changes are: - 1. reorganisation of categories for additional non OSX methods into - separate files in the Additions library. - 2. changes to headers to hide instance variables if we are using - the non-fragile-abi with clang. - 3. additions of a void* instance variable for future expansion to - almost all classes (avoid the fragile ivar issue). - 4. various code changes to support the nonfragile-abi (the use of - @defs is no longer allowed). - NB. This revision breaks binary compatibility ... all code using base - needs to be rebuilt. However, future releases of the base library - should all maintain abi compatibility with the first release based - on these changes (at least, as far as class instance size issues - are concerned). - -2010-02-12 Richard Frith-Macdonald - - * configure.ac: Remove a couple of obsolete tests and add a couple for - new runtime features. - * config/config.objc_condition_timed_wait.c: remove - * config/config.non-fragile-ivars.m: add - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: regenerate - -2010-02-11 Nicola Pero - - * Source/Makefile.postamble: Removed obsolete manual dependency - rules. Dependencies of object files on header files are - automatically computed by gnustep-make, so these rules were - superfluous. - * Source/GNUmakefile: Compile Additions as a subproject before the - two libraries that are built on top of it. This will prevent - problems when libraries from the same GNUmakefile are built in - parallel. - * Source/GNUmakefile (GNUmakefile.local): Do not try including - this non-existing file. - * Examples/GNUmakefile: Same change. - * NSTimeZones/GNUmakefile: Same change. - * Resources/GNUmakefile: Same change. - * SSL/GNUmakefile: Same change. - * Tools/GNUmakefile: Same change. - -2010-02-11 07:37-EST Gregory John Casamento - - * install.sh: Removed configure. - -2010-02-09 Riccardo Mottola - - * Source/NSOperation.m: Move declaration upwards to fix compile error. - -2010-02-09 Richard Frith-Macdonald - - * Source/GSAttributedString.m: - * Source/Additions/GSCategories.m: - * Headers/Foundation/NSString.h: - * Headers/Additions/GNUstepBase/GSCategories.h: - Re-instated the immutableProxy mathod, but as a clean category on - NSMutableString in the additions library. - Use for the -string method of NSAttributedString - -2010-02-08 Richard Frith-Macdonald - - * Source/NSAttributedString.m: minor cosmetic change - * Source/GSAttributedString.m: Re-introduce proxy for -string - and comment to try to avoid it being accidentally removed again. - * Source/GSString.m: Fixups to work properly with string proxies. - * Source/NSException.m: Re-instate correct behavior and make the - comment about it more emphatic. - -2010-02-08 Jonathan Gillaspie - - * Source/NSException.m - * Removed redundant call to _NSFoundationUncaughtExceptionHandler - and added else blocks to allow a set uncaught exception handler - to NOT exit if capable of recovering. - -2010-02-08 Richard Frith-Macdonald - - * Headers/Foundation/NSOperation.h: - * Source/NSOperation.m: - Complete implementation of NSOperationQueue (OSX 10.6 apart from the - methods using objc2 blocks). - -2010-02-06 Richard Frith-Macdonald - - * Headers/Foundation/NSOperation.h: - * Source/NSOperation.m: - Partial implementation of NSOperationQueue (OSX Leopard functionality - plus a little of Snow Leopard). - -2010-02-05 Riccardo Mottola - - * Headers/Additions/GNUstepBase/GSIMap.h: fixed c99-ism - * Headers/Additions/GNUstepBase/GSBlocks.h : provide gcc 2.95 - variadic macro - -2010-02-04 Richard Frith-Macdonald - - * Headers/Foundation/NSOperation.h: - * Source/NSOperation.m: - Implement and document the NSOperation class. - As OSX 10.6 minus the objc2 specific 'block' methods. - -2010-02-04 Richard Frith-Macdonald - - * Source/NSLock.m: cleanup indentation etc, and apply fix suggested - by David Ayers - -2010-02-04 Jonathan Gillaspie - - * Source/NSLock.m: - ([lockWhenCondition:beforeDate:]) - Switched to use timeIntervalSince1970. - added a loop to lockWhenCondition since pthread_cond_timedwait can - return to delay expiring. Hold the lock on a delayed acquire - (and YES return). - ([tryLockWhenCondition:]) No longer reports a deadlock when we - already have the lock, now just returns NO. - -2010-02-03 Richard Frith-Macdonald - - * Source/NSThread.m: - Don't use usleep() on windows .. it performas a busy wait so the - Sleep() function is better. - -2010-02-01 Richard Frith-Macdonald - - * Source/NSAutoreleasePool.m: - * Source/NSThread.m: - Tweaks to try and get default thread correctly terminated on exit. - -2010-01-30 Fred Kiefer - - * Source/NSPropertyList.m (GSBinaryPLParser -rootObject, - -initWithData:mutability:): Get root index from the binary - property list data and use this to return the root object. - -2010-01-24 Richard Frith-Macdonald - - * configure.ac: Option for using libbfd for stack traces - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * Source/NSException.m: Re-instate code for using libbfd to provide - symbolic stack traces (because the backtrace_symbols function doesn't - work on most platforms). Add warning about the fact that this alters - the license of the library. - -2010-01-23 Niels Grewe - - * Source/GSFFCallInvocation.m: - * Source/NSZone.m: - * Source/Additions/GSObjCRuntime.m: - * Source/Additions/GCObject.m: - * Source/synchronization.m: - * Source/GSPThread.h: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - Updates for switch to using pthreads - -2010-01-21 Eric Wasylishen - - * Headers/Foundation/NSObjCRuntime.h: define CGFLOAT_DEFINED when - defining CGFloat. - Also check that NSINTEGER_DEFINED and CGFLOAT_DEFINED are undefined - before defining NSInterger and CGFloat. - -2010-01-21 16:20-EST Gregory John Casamento - - * install.sh: Add --with-installation-domain=SYSTEM to the script - to allow automated build on Windows. - -2010-01-20 Richard Frith-Macdonald - - * Source/NSTask.m: - Always remove task from controlling terminal, not just when using - pseudo-terminals. This is compatible with OSX behavior - (testcase added to the testsuite). - Also remove some redundant/duplicate code - -2010-01-11 Quentin Mathe - - * Source/NSFormatter.m (-copyWithZone:, -initWithCoder:, - -encodeWithCoder:): Removed the subclass responsibility, - in order to have subclasses automatically coding and copying - compliant as Cocoa does. - You can also now safely call [super copyWithZone:/initWithCoder:] in a - subclass. - -2010-01-11 Richard Frith-Macdonald - - * Source/NSMapTable.m: - * Source/NSHashTable.m: - * Source/NSPropertyList.m: - * Source/GSStream.m: - * Source/NSURLResponse.m: - * Source/NSPointerArray.m: - * Source/Additions/GSMime.m: - * Source/NSURLRequest.m: - Fix mistaken strategy for avoiding clang warnings. - -2010-01-11 Fred Kiefer - - * Source/NSConcreteMapTable.m (NSCreateMapTableWithZone): Set the - concreteClass, when this isn't already set. - -2010-01-10 Richard Frith-Macdonald - - * Source/NSMapTable.m: - * Source/NSHashTable.m: - * Source/NSPropertyList.m: - * Source/NSScanner.m: - * Source/GSArray.m: - * Source/GSStream.m: - * Source/NSPredicate.m: - * Source/GSHTTPURLHandle.m: - * Source/NSURLResponse.m: - * Source/NSPointerArray.m: - * Source/Additions/GSCategories.m: - * Source/Additions/GSMime.m: - * Source/NSData.m: - * Source/NSSerializer.m: - * Source/NSURLRequest.m: - * Source/GSFormat.m: - * Source/NSXMLParser.m: - * SSL/GSSSLHandle.m: - * Tools/sfparse.m: - * Tools/gdnc.m: - * Tools/gdomap.c: - * Tools/pl.m: - * config/config.loadtest.m: - Tweaks towards making base build/work better with clang - -2010-01-09 Richard Frith-Macdonald - - * Source/NSCharacterSetData.h: - * NSCharacterSets/newlineCharSet.dat: - Add VT ad FF as newline characters for OSX compatibility as suggested - by Eric. - -2010-01-09 Richard Frith-Macdonald - - * configure.ac: - * Source/NSException.m: - * Headers/Additions/GNUstepBase/config.h.in: - * config/config.unexpected.m: - * config/config.set_unexpected.m: - * configure: - Modified to suppport native exceptions with libobjc2 which is missing - the objc_set_unexpected() function and just uses direct assignment of - a function pointer. - -2010-01-05 Eric Wasylishen - - * Headers/Foundation/NSCharacterSet.h - * Source/NSCharacterSet.m - * Source/NSCharacterSetData.h: - Implement +[NSCharacterSet newlineCharacterSet]. This includes - rebuilding NSCharacterSetData as described in the mkcharsets - README. - Note that the Apple docs count 0x000B (vertical tab) and 0x000C - (form feed) as newline characters, and include them in - newlineCharacterSet and whitespaceAndNewlineCharacterSet, while - GNUstep does not at the moment. - -2009-12-29 David Chisnall - - * Source/GSDictionary.m - * Source/NSDictionary.m - * Headers/Foundation/NSDictionary.h - Added fast enumeration support to GSDictionary, and GSMutableSet. - * Source/GSSet.m - * Source/GSCountedSet.m - * Source/NSSet.m - * Headers/Foundation/NSSet.h - Added fast enumeration support to GSSet, GSMutableSet, and GSCountedSet - * Headers/Additions/GNUstepBase/GSIMap.h - Added function for implementing fast enumeration with GSIMaps. - -2009-12-27 David Chisnall - - * Source/NSArray.m - * Headers/Foundation/NSArray.h - Added some block method implementations. - - * Headers/Foundation/NSObjCRuntime.h - Added constants for enumeration. - - -2009-12-27 David Chisnall - - * Source/GSFastEnumeration.h: Added macros implementing for..in loops. - -2009-12-27 David Chisnall - - * Headers/Additions/GNUstepBase/GSBlocks.h: Added block macros. - -2009-12-23 Wolfgang Lux - - * Source/NSUndoManager.m (_canCoalesceUndoWithTarget:selector:object): - Auxiliary method to support coalescing undo operations in - NSTextView. - -2009-12-22 17:15-EST Gregory John Casamento - - * Source/NSObject.m: Conditionally compile weak attribute for - Windows since it is not supported by the win32 linker. - -2009-12-20 David Chisnall - - * Source/NSObject.m: Set block superclass. - -2009-12-19 13:53-EST Gregory John Casamento - - * Source/GNUmakefile: Add synchronization.m to GNU_MFILES - and correct some formatting. - * Source/synchronization.m: Fix @synchronize support on - Windows. The __weak__ attribute doesn't work on Windows. - -2009-12-11 01:44-EST Gregory John Casamento - - * Source/synchronization.m: Corrected header text. - -2009-12-07 Richard Frith-Macdonald - - * Source/GSString.m: Use -hash from GSString rather than from NSString - to optimise hashing. Fix string comparison error as pointed out by - Doug Simons. - -2009-12-02 Richard Frith-Macdonald - - * Source/NSMessagePortNameServer.m: - * Source/NSMessagePort.m: - On initialisation, remove any old ports/names for the current process - idntifier. Also remove ports/names for processes which don't exist. - Avoids any possibility of nameserver confusion between two processes - with the same ID. - -2009-12-01 Richard Frith-Macdonald - - * Source/NSMessagePortNameServer.m: Tolerate '*' host name. - * Source/NSConnection.m: Clarify documentation slightly. - * NSSocketPort.m: - * win32/GSFileHandle.m: - Fixup missing notification changes. - -2009-11-27 Richard Frith-Macdonald - - * Source/NSNotificationQueue.m: Rewrite queue handling to attempt to - fix bug #28104 by posting notifications matching the current run loop - mode and leaving others queued. - Also, change the meanining of a nil modes argument when enqueing a - notification to match OSX and assume NSDefaultRunLoopMode. - * Source/Additions/GSXML.m: Fix minor sax callback bug. - * Source/NSConnection.m: Don't send a response packet if the method - is oneway void return type and has no output parameters. - -2009-11-27 Richard Frith-Macdonald - - * Source/NSPropertyList.m: When serializing 'xml' style property lists - call -description to ensure that dictionary keys are strings since no - other option is permitted in the dtd. - -2009-11-27 Richard Frith-Macdonald - - * Source/NSNotificationQueue.m: - * Source/NSRunLoop.m: - * Source/unix/GSRunLoopCtxt.m: - * Source/win32/GSRunLoopCtxt.m: - * Source/GSPrivate.h: - Pass current runloop mode to notification functions. Next we need - to add code to use this information. - -2009-11-26 Richard Frith-Macdonald - - * Source/NSPropertyList.m: Revert last change, which broke XML - generation by placing illegal character entities in the output. - Fix menu position problem by adding missing code to unescape - the \U escapes we put in the output when we read back in again. - NB. should check that we use character entities for all legal - characters and only use the escape mechanism for *really* illegal - ones (such as the menu location key). - -2009-11-26 Wolfgang Lux - - * Source/NSPropertyList.m (XString): Write out proper XML encoding - for control characters. Fixes a bug where menu positions in GUI - programs would appear not persistent. - -2009-11-24 Richard Frith-Macdonald - - * Source/GSFFIInvocation.m: make better guess when forward2 is not - available in runtime. - -2009-11-23 Richard Frith-Macdonald - - * Source/NSObject.m: Remove spurious semicolons - * Source/NSConnection.m: autogsdoc ignore confusing section - * Source/NSLock.m: autogsdoc ignore (just use header) - * Tools/AGSParser.m: add feature to ignore sections - * Tools/autogsdoc.m: document new ignore markup - -2009-11-04 Richard Frith-Macdonald - - * Source/NSAutoreleasePool.m: ([-drain]) Copy undocumented OSX behavior - calling -release (suggested by Christopher James Elphinstone Chandler). - -2009-10-26 Adam Fedor - - * Source/Makefile.postamble: Add flag filter for - libgnustep-base-entry.m (for GCC 4.4 on MinGW). - -2009-10-20 Wolfgang Lux - - * Source/NSObject.m (NSIncrementExtraRefCount): Properly release - allocation lock. - -2009-10-12 Richard Frith-Macdonald - - * Source/NSProcessInfo.m: - * Headers/Foundation/NSProcessInfo.h: - * Tools/gspath.m: - * Tools/plmerge.m: - * Tools/xmlparse.m: - * Tools/sfparse.m: - * Tools/plparse.m: - * Tools/pldes.m: - * Tools/defaults.m: - * Tools/plget.m: - * Tools/pl2link.m: - * Tools/gdnc.m: - * Tools/plser.m: - * Tools/autogsdoc.m: - * Tools/HTMLLinker.m: - * Tools/cvtenc.m: - Add function for easy process initialisation when the automatic - mechanisms don't work (eg calling ObjC code from within a C or C++ - application). - -2009-10-11 Eric Wasylishen - - * Source/NSKeyValueObserving.m: add setters for common structures. - -2009-10-10 Richard Frith-Macdonald - - * Headers/Foundation/NSString.h: - * Source/NSString.m: - * Source/GSString.m: - Remove obsolete immutable proxy method. - * Source/NSIndexPath.m: - * Source/NSDistributedNotificationCenter.m: - * Source/NSAttributedString.m: - * Source/GSArray.m: - * Source/GSFFCallInvocation.m: - * Source/GSFFIInvocation.m: - * Source/GSAttributedString.m: - * Source/NSConnection.m: - * Source/NSThread.m: - Replace unnecessary calls to NSDeallocateObject(). - -2009-10-07 Adam Fedor - - * configure.ac: Add librt for sched_yield on solaris. - -2009-10-05 Richard Frith-Macdonald - - * configure.ac: enable ffcall if ffi is disabled - * configure: Regenerate - * Source/mframe:delete - * Source/mframe.m: delete - * Source/GSInvocation.h: - * Source/GNUmakefile: - * Source/NSMethodSignature.m: - * Source/GSFFCallInvocation.m: - * Source/NSKeyValueObserving.m: - * Source/GSFFIInvocation.m: - * Source/NSInvocation.m: - * Source/cifframe.m: - * Source/NSConnection.m: - * Source/callframe.m: - * Source/NSDistantObject.m: - * Headers/Foundation/NSMethodSignature.h: - * Headers/Foundation/NSInvocation.h: - Update for removal of mframe code. - -2009-10-04 Richard Frith-Macdonald - - * Source/GNUmakefile: - * Source/NSMethodSignature.m: - * Source/GSFFCallInvocation.m: - * Source/mframe/mframe.head: - * Source/GSFFIInvocation.m: - * Source/NSInvocation.m: - * Source/cifframe.h: - * Source/mframe.m: - * Source/cifframe.m: - * Source/NSConnection.m: - * Source/callframe.h: - * Source/NSObjCRuntime.m: - * Source/callframe.m: - * Headers/Additions/GNUstepBase/DistributedObjects.h: - * Headers/Additions/GNUstepBase/preface.h.in: - Remove lots of obsolete code as part of the ong term process of - scrapping the old mframe stuff. - -2009-10-04 Richard Frith-Macdonald - - * Source/cifframe.h: Remove unused code - * Source/cifframe.m: ditto - * Source/callframe.h: ditto - * Source/callframe.m: ditto - * Source/NSConnection.m: Use NSInvocation functionality directly - rather than duplicated versions of the code in ffi/ffcall/mframe - specific files. Should simplify things and make maintenance easier. - -2009-10-03 Richard Frith-Macdonald - - * Source/GSInvocation.h: - * Source/GSFFIInvocation.m: - * Source/NSInvocation.m: - Fix to always store return value in memory owned by the GSFFIInvocation - object. Fix for bug #27233 - -2009-10-03 Richard Frith-Macdonald - - * Source/NSConnection.m: - Don't allow the root object of a connection to be released simply - because the remote proxy is released ... the connection itsself - may have been retained at the remote end, and the code there may - call the -rootProxy method and start sending messages to it again. - Fix for bug #27128 - -2009-10-01 Richard Frith-Macdonald - - * Source/NSPortCoder.m: - * Source/NSKeyedArchiver.m: - * Source/NSConcreteMapTable.m: - * Source/NSConnection.m: - * Source/NSSerializer.m: - * Source/NSArchiver.m: - * Source/NSConcreteHashTable.m: - * Headers/Additions/GNUstepBase/GSIMap.h: - Explicitly specify types present in GSIUnion - -2009-09-30 Richard Frith-Macdonald - - * Source/NSLock.m: Fix BOOL methods to return YES or NO. - * Source/win32/GSFileHandle.m: Implement nul device handle. - * Source/NSTask.m: Try to avoid annoying colsole window with mingw32 - * Source/GSLocale.m: Try to handle locale setup in non-utf8 locales. - -2009-09-27 Richard Frith-Macdonald - - * Source\win32\GSFileHandle.m: - * Source\win32\NSMessagePort.m: - * Source\win32\GSRunLoopCtxt.m: - * Source\win32\NSStream.m: - * Source\win32\NSMessagePortNameServer.m: - * Source\NSPipe.m: - * Source\NSTask.m: - Fixes to try and improve subtask handling on windows. - 1. change scheme to create all handles as not inheritable, and - just make the handles we want the child to have inheritable while - we are launching the child. - 2. peek the data on pipes and refrain from notifying about data - availability if the pipe doesn't really have data. This is horrid and - means we poll pipes ... I guess we really need to be doing async - reads instead ... perhaps someone can do that based on the code in - Source/win32/NSMessagePort.m which already does it. - -2009-09-23 Richard Frith-Macdonald - - * Source/NSURL.m: OSX compatibility tweaks ... allows initialisation - using a string containing a simple path without any scheme. - -2009-09-17 Richard Frith-Macdonald - - * Source/NSIndexSet.m: - ([-shiftIndexesStartingAtIndex:by:]) fix to properly merge index - ranges when shifting left. - -2009-09-15 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSMime.h: - * Source/Additions/GSMime.m: - Add new -excess method to return any excess data left over from parsing. - Previously the code just used to NSLog() this data as a warning. - -2009-09-14 Richard Frith-Macdonald - - * Source/NSCalendarDate.m: Workaround for bug in some linux SMP systems - * Source/NSConnection.m: fix for bug #27446 - -2009-09-12 Richard Frith-Macdonald - - * Source/NSCalendarDate.m: Add optional diagnostics to detect system - time changes and warn about them. - * Source/NSException.m: Clean up to match coding standards. - Fix uninitialised variable bug. - * Source/NSObject.m: clean up and fix missing dealloc. - * Headers/Foundation/NSURLCredential.h: - * Headers/Foundation/NSHTTPCookieStorage.h: - * Headers/Foundation/NSException.h: - * Headers/Foundation/NSValueTransformer.h: - * Headers/Foundation/NSURLAuthenticationChallenge.h: - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSStream.h: - * Headers/Foundation/NSThread.h: - * Headers/Foundation/NSHTTPCookie.h: - * Headers/Foundation/NSURLError.h: - * Headers/Foundation/NSURLProtectionSpace.h: - * Headers/Foundation/NSURLDownload.h: - * Headers/Foundation/NSKeyValueObserving.h: - * Headers/Foundation/NSURLRequest.h: - * Headers/Foundation/NSURLCredentialStorage.h: - * Headers/Foundation/NSInvocation.h: - * Headers/Foundation/NSURLResponse.h: - * Headers/Foundation/NSURLConnection.h: - * Headers/Foundation/NSIndexPath.h: - * Headers/Foundation/NSURLProtocol.h: - * Headers/Foundation/NSURLCache.h: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - Fix up errors in version of feature addition to GNUstep. Some - GNUstep version constants had leading zeros so they were interpreted - as octal rather than decimal. - -2009-09-11 David Chisnall - - * Source/NSException.m: - *Headers/Foundation/NSException.h: - - Rewrote exception callstack generation to use the backtrace() and - backtrace_symbols() code. Implemented the -callStackSymbols method from - 10.5 using this. For this to be enabled, the configure script will - require a small modification, which Gregory will add later. - -2009-09-10 David Chisnall - - * Source/GSFFIInvocation.m: - * Source/NSObject.m: - * Headers/Foundation/NSObject.h: - Added implementations of the hooks provided by the new runtime. This - brings NSObject up to feature-parity with the OS X 10.5 implementation - when using the new runtime and up to feature-parity with the 10.6 - implementation if you are using the new runtime and compiling with - clang. - - Also removes the objc_mutex_wibble stuff from NSObject in favour of just - using NSLocks (which, with the new implementation, are now faster than - using objc_mutex_stuff). - -2009-09-10 Richard Frith-Macdonald - - * Source/NSRunLoop.m: ([-limitDateForMode:]) on OSX it seems that only - one timer fires each time this method is invoked ... so I rewrote this - method to only fire one timer (excluding the private housekeeping one). - Changing to only fire one timer actually allows the code to be simpler - so it's a good update in its own right, not just a OSX compatibility - tweak. I also made incrementing repeated timers a bit more robust, - checking that they provide a valid increment time interval and - removing them from the loop if they don't. - * Source/NSTimer.m: slightly tidy/clarify initialisation code and - documentation. - -2009-09-08 Richard Frith-Macdonald - - * configure.ac: - * configure: - * config.mak.in: - * Source/GNUmakefile: - Attempt to tidy up config now that pthreads are mandatory. - * Source/NSThread.m: - Fix various bugs related to thread exit, Prevent crashes at program - termination ...nastily obvious on mingw. - * Source/Additions/GSLock.m: - Remove -dealloc implementations which called -finalize, since the - superclass implementationd does that too, and finalizing twice is - a bad, bad thing. - -2009-09-07 Richard Frith-Macdonald - - * Headers/Foundation/NSConnection.h: - * Source/NSConnection.m: - Remove ivars from public header. - Improve debug by reporting the connections's registered name and/or - the name of the remote port it is connecting to. - -2009-09-07 Richard Frith-Macdonald - - * Source/NSRunLoop.m: - * Source/GSRunLoopCtxt.h: - Add some logging to help debug problems where code is adding too - many events into a run loop. - -2009-09-06 Richard Frith-Macdonald - - * Source/NSLock.m: Fix the ([-tryLock]) and [(-lockBeforeDate:]) - implementations for NSLock and NSCondictionLock to return NO for - recursive locking. Fix to only initialise mutex attributes once - (to avoid leaking a set of attributes with every lock created on - platforms where attributes need to be destroyed when no longer used). - Reorganise to make it easy to replace method implementations. - Fix for bug #25444 ... OSX compatibility change. - -2009-09-06 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Fix for rare problem if someone changes the - system time backwards. - * configure.ac: Check for pthread.h and type sizes. Insist on having - pthread.h in order to build, now that it is a requirement. - * configure: Regenerate - * Headers/Additions/GNUstepBase/GSConfig.h.in: Declare abstract types. - * Source/NSLock.m: including pthread.h - * Headers/Foundation/NSLock.h: Avoid including pthread.h - Basically, insist on finding pthread.h at configure time, and get size - of essential types so we can avoid exposing them directly in our - public headers. This should discourage developers from using things - they shouldn't, but it does not solve the issue that copies of the base - library built with different pthread implementations on the same - platform may have binary incompatible NSLock classes (with respect to - subclassing as the pthread specific ivars differ in size). However - this is *really* unlikely to be an issue in practice. - -2009-09-05 David Chisnall - - * Source/NSEnumeration.m: Added enumeration mutation callback. - -2009-09-03 Richard Frith-Macdonald - - * Source/NSLock.m: Fix a few variable declarations to work with older - compilers. Fix indentation/whitespace for coding standards consistency. - * Source/NSURLProtocol.m: Fix attempt to use deallocated stream. - -2009-09-01 David Chisnall - - * Source/NSLock.m - * Headers/Foundation/NSLock.h - Completely rewritten implementations of NSLock.h classes. These are now - faster, more complete, OS X-compatible, and most importantly actually - work. The old ones, for example, called functions that were not - implemented on Windows. - * Source/NSThread.m - Call pthread functions directly in NSThread instead of via the libobjc - abstraction layer. Also fixed a few issues, such as GC not being - initialized properly for NSThread subclasses that override -main - (Javaism supported by OS X) and tidies up the code in several places, - removing premature optimizations, especially those that introduce a - test for an unlikely case at the start of a method and thus slow - everything down. - - As a result of this change, GNUstep now depends on an implementation of - POSIX threads. This is included as standard on all modern UNIX systems, - and as an option on less-modern UNIX systems and non-UNIX systems, - including Windows. If you are building GNUstep on Windows, - please install the pthreads-win32 package, available from: - - http://sourceware.org/pthreads-win32/ - - PLEASE TEST THIS! There may be some code that depended on the old - behaviour. I have been running the new NSLock implementation on FreeBSD - for a few weeks without issue; please report to me any problems that you - have on your platform. - -2009-09-01 Richard Frith-Macdonald - - * Version: bump to 1.19.3 - * Documentation/news.texi: update - * Documentation/ReleaseNotes.gsdoc: update - Make 1.19.3 release. - -2009-09-01 Richard Frith-Macdonald - - * Headers/Foundation/NSCache.h: - * Source/NSCache.m: - Great additions... tweaked with whitespace changes to conform to - coding standards, addition of copyright headers, addition of standard - prevention of multiple inclusion, include changes to build independant - of any existing installation. - -2009-08-31 David Chisnall - - * Headers/Foundation/NSCache.h: - * Headers/Foundation/Foundation.h: - * Source/NSCache.m: - * Source/GNUmakefile: - Added NSCache implementation. - -2009-08-31 Richard Frith-Macdonald - - * Source/NSMessagePort.m: - * Source/NSSocketPort.m: - * Source/NSConnection.m: - Improve -description to include the registered names (if any) of ports. - Include full port description in connection description. - -2009-08-30 David Chisnall - - * Headers/Foundation/NSObject.h: Added NSDicardableContent protocol from - Snow Leopard. - -2009-08-27 Richard Frith-Macdonald - - * Source/Additions/GSCategories.m: - * Source/Additions/GSCompatibility.m: - Move -fullPath to correct place to build on OSX - -2009-08-27 Richard Frith-Macdonald - - * Source/NSAttributedString.m: ([-string]) was returning proxy to - mutable string ... bad if calling code does not expect it. - -2009-08-26 Richard Frith-Macdonald - - * Headers/Foundation/NSURL.h: - * Headers/Additions/GNUstepBase/GSCategories.h: - * Source/NSURL.m: - * Source/Additions/GSCategories.m: - Add new -fulPath method to do what -path used to do, because for OSX - compatibility the -path method now returns a path without any - trailing slash, making it impossible to reconsitute a URL string - from its individual parts :-( - * Source/GSHTTPURLHandle.m: - * Source/NSURLProtocol.m: - Use the new -fullPath method to build the request line sent to the - remote web server. - -2009-08-25 Richard Frith-Macdonald - - * Version: bump to 1.19.2 - * Documentation/news.texi: update - * Documentation/ReleaseNotes.gsdoc: update - * Source/DocMakefile: Avoid warning about WINAPI - * Source/NSURLDownload.m: Documentation cleanups - * Source/NSFileManager.m: ditto - * Source/Additions/GSCategories.m: ditto - * Source/Additions/GSMime.m: ditto - * Source/NSURLConnection.m: ditto - * Headers/Foundation/NSTimeZone.h: ditto - * Headers/Foundation/NSURLDownload.h: ditto - Make 1.19.2 release - -2009-08-24 Richard Frith-Macdonald - - * Source/NSString.m: - * Source/GSString.m: - * Headers/Foundation/NSString.h: - Tweak boolValue behavior to better match OSX and document exact - behavior. - -2009-08-23 Richard Frith-Macdonald - - * Source/win32/GSFileHandle.m: Fix for write in background on windows - if a write is not already in progress, do it immediately because - winsock won't tell us when we can write. Also, improve the test to - see if a handle is a socket, as the previous code was not working for - incoming connections, resulting in a busy poll rather than a blocking - poll, and thus loading the system unnecessarily. - -2009-08-21 Riccardo Mottola - - * Source/NSConnection.m: Joined split-line string constant - -2009-08-21 Doug Simons - - * Source/NSUserDefaults.m: Remove one of the locks in +userLanguages - to avoid a deadlock. - Patch applied by: Gregory Casamento - -2009-08-21 Doug Simons - - * Source/NSUserDefaults.m: Changes to bulletproof NSUserDefaults from - deadlocks when it is accessed by more than one thread. - Patch applied by: Gregory Casamento - -2009-08-19 Eric Wasylishen - - * Source/Additions/GSObjCRuntime.m: - Behave consistently with MacOS-X when a getter or setter method - returns a type of data which is not supported by KVC. - -2009-08-15 David Chisnall - - * Source/NSObject: - - Tweaked NSObject to use atomic ops with LLVM as well as gcc (this - probably isn't actually needed) - - Fixed SIGFPE problem on FreeBSD using proper interfaces instead of - an asm hack. - * Removes various mframe things from being compiled when ffcall/libffi - is used (mframe.m, NSConnection.m, NSInvocation.m) - * Turned a nested function in make_strings.m into a macro. - -2009-08-12 Richard Frith-Macdonald - - * Source/NSData.m: Remove some redundant methods and add checks for - attempts to use a null pointer to set bytes in the data. - * Source/NSCharacterSet.m: Save mem with index set rather than - bitmap set - -2009-08-11 Fred Kiefer - - * Source/NSAttributedString.m: Fix keyeded encodgin decoding for - both NSAttributedString and NSMutableAttributedString. - -2009-08-11 Richard Frith-Macdonald - - * Source/NSData.m: Fix memory leak introduced with GC changes. - * Source/Additions/GSMime.m: Use memmove() as fix for bug #27224 - -2009-08-10 Richard Frith-Macdonald - - * Source/NSData.m: Fix memory leak introduced with GC changes. - -2009-08-05 Richard Frith-Macdonald - - * Source/NSFileManager.m: - * Headers/Foundation/NSFileManager.h: - Updated comments/documentation to say that directory enumeration order - is undefined. - -2009-08-04 Richard Frith-Macdonald - - * Tools/AGSHtml.m: Escape non-ascii characters etc in author. - -2009-08-04 Richard Frith-Macdonald - - * Source/NSPropertyList.m: Fix for handling empty key values in - XML property lists. - -2009-08-03 Richard Frith-Macdonald - - * Source/NSObject.m: Fix error in memory allocation debug when - swizzling a class. - -2009-07-30 Quentin Mathe - - * Headers/Foundation/Foundation.h: Included NSKeyValueObserving.h. - -2009-07-28 Richard Frith-Macdonald - - * Source/NSConnection.m: Correct the text in exception when attempting - to read a response on an invalidated connection. - * Source/Additions/GSMime.m: - Fixup incorrect declaration of method in wrong class implementation. - -2009-07-27 David Ayers - - * Source/Additions/GSCompatibility.m ([-boolValue]): Only compile - for OS X Versions below 10.5 and sync implementation with -base. - Reported by: Georg Fleischmann - -2009-07-23 Richard Frith-Macdonald - - * GSHTTPURLHandle.m: - * NSURLProtocol.m: - Include the port in the 'Host' header if it's specified in the URL. - -2009-07-21 Richard Frith-Macdonald - - * Source/GSInternal.h: New macros for CLANG/non-fragile ivar compat. - * Source/NSOperation.m: Use new macros. - -2009-07-17 Richard Frith-Macdonald - - * Source/NSOperation.m: Fix includes and text of comments at start - of document. - -2009-07-16 Richard Frith-Macdonald - - * Headers/Foundation/NSOperation.h: - * Source/NSOperation.m: - Various changes for maintainability and coding standards ... nothing - which should effect functionality. - -2009-07-14 20:02-EDT Gregory John Casamento - - * Headers/Foundation/NSOperation.h - * Source/NSOperation.m: Added initial implementation of - NSOperationQueue. - -2009-07-13 14:15-EDT Gregory John Casamento - - * Headers/Foundation/Foundation.h - * Headers/Foundation/NSOperation.h - * Source/GNUmakefile - * Source/NSOperation.m: Initial implementation of NSOperation - class. - -2009-07-11 Richard Frith-Macdonald - - * Source/NSConcreteMapTable.m: Add some comments. - * Source/NSConcreteHashTable.m: Dito - * Headers/Additions/GNUstepBase/GSIMap.h: Make explicit that fields in - enumerator are all big enough to hold pointers. - -2009-07-04 Richard Frith-Macdonald - - * Source/NSProcessInfo.m: Add daignostic check. - * Source/NSSocketPort.m: Make sure socklen_t is defined. - Shoudl fix bug #26856 - -2009-06-30 Wolfgang Lux - - * configure.ac: - * configure: - * config/config.poll-dev.c: Add test to configure to avoid using - the broken poll implementation on Mac OS X 10.4 and later, which - does not support devices. - -2009-06-24 Richard Frith-Macdonald - - * Source/NSXMLParser.m: ([-parse]) don't split whitespace strings - at newline. - -2009-06-19 Richard Frith-Macdonald - - * Source/win32/GSRunLoopCtxt.m: Fix error sending received event - handle to watcher. Had broken TCP/IP ports. - -2009-06-19 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Fix incorrect attempt to free memory - we shouldn't. Should fix bug #26843 - -2009-06-16 Richard Frith-Macdonald - - * Source/win32/NSMessagePort.m: Don't use NSLog() to report error - when writing to mailslot ... it's usually just that the remote - end has terminated, so invalidating the port silently is better. - * Source/GSFileHandle.m: Adjust code to deal with fstat() returning - a failure on windows if the descriptor is a pipe/socket. - -2009-06-13 Richard Frith-Macdonald - - * Headers/Foundation/NSKeyedArchiver.h: - * Headers/Foundation/NSArchiver.h: - Fix error cleaning up a define. - -2009-06-12 Richard Frith-Macdonald - - * Source/NSDistributedNotificationCenter.m: add explicit size casts - to avoid compiler warnings. - * Source/NSUserDefaults.m: Save defaults in xml format and add some - error checking. - * Source/NSPropertyList.m: tolerate NSNumber values used as dictionary - keys, by using their string representation. - -2009-06-09 Richard Frith-Macdonald - - * SSL/Source/GSSSLHandle.m: Disable v2 by default due to - security issues. GSPermitSSLv2 user default can enable it again. - -2009-06-08 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Optimise somewhat for converting - from unicode (UTF-2) to UTF-8 - * Source/GSString.m: Optimise 8 bit string equality tests a little. - -2009-06-06 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Optimise case where we are converting - from unicode to latin1 or ascii. - * Source/GSString.m: Optimise -hash method of NXConstantString too. - -2009-06-06 Wolfgang Lux - - * Source/GSFFIInvocation.m - (-initWithCallback:returnp:values:frame:signature:): Fix bug - #26419 by removing bogus code which was used on targets where - MFRAME_STRUCT_BYREF is defined. - -2009-06-06 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: When converting from a characterset - to unicode, and we know that there is a one to one correspondence - between the characterset values and unicode values, shift the - buffer sizing outsize the loop through the characters to avoid - unnecessary checks for the end of the buffer in each iteration. - Optimisation suggested by Fred Kiefer - -2009-06-05 18:12-EDT Gregory John Casamento - - * Source/NSDistantObject.m: NSProxy subclasses must override -init - or an exception will be thrown. This change calls the forwarding - mechanism to invoke -init on the remote object. - Patch by David Chisnall - -2009-06-04 Georg Fleischmann - - * Source/Additions/unicode/nextstep.h: Fixups for encoding mapping. - -2009-06-02 Wolfgang Lux - - * Source/NSUndoManager.m (-undo, -redo): Call -_begin instead of - -beginUndoGrouping to avoid creation of a spurious top-level group - while performing undo or redo operations, which was causing the - recorded actions to be dropped silently. - - * Source/NSUndoManager.m (-beginUndoGrouping): Post - NSUndoManagerCheckpointNotification also during undo as on OS X. - - * Source/NSUndoManager.m (-endUndoGrouping): Post - NSUndoManagerWillCloseUndoGroupNotification before changing the - group so that clients see the same grouping level as on OS X. - -2009-05-29 Riccardo Mottola - - * Source/NSObject.m: Atomic increment and decrement functions for m68k - -2009-05-29 Nicola Pero - - * GNUmakefile: Use $(warning ...) instead of $(info ...) since - $(info ...) exists only in GNU make >= 3.81. - * NSCharacterSets/GNUmakefile: Same change. - * Source/GNUmakefile: Same change. - * SSL/GNUmakefile: Same change. - * Documentation/GNUmakefile: Same change. - * Resources/GNUmakefile: Same change. - * NSTimeZones/GNUmakefile: Same change. - * Examples/GNUmakefile: Same change. - * Tools/GNUmakefile: Same change. - -2009-05-27 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Updates to match latest MacOS-X behavior. - The +new and -init methods now return nil. - Timers are now treated like input sources for purposes of deciding - whether the loop will block and whether performerds will execute. - * Source/NSTimer.m: Updates to match latest MacOS-X behavior. - The +new and -init methods now return nil. - -2009-05-24 Richard Frith-Macdonald - - * Source/NSThread.m: Use lock to prevent race condition setting up - runloop info for thread. - -2009-05-23 Richard Frith-Macdonald - - * Source/NSKeyValueObserving.m: - Permit setters which return values. - -2009-05-22 Richard Frith-Macdonald - - * Source/NSFileManager.m: - * Source/NSBundle.m: - Try to get the path right for loading dynamic library code on windows - when NSExecutable doesn't have the .dll path extension. - -2009-05-16 Doug Simons - - * Source/NSCalendarDate.m: - Implement field widths for numeric fields in a date format for - MacOS-X compatibility. - -2009-05-16 Richard Frith-Macdonald - - * Source/NSURL.m: Add support for file URLs on mswindows. The path - may be of the form C:\... rather than /... (and the colon might be - a vertical bar). - Also makefile fixes for bug #26446 - -2009-05-11 Adam Fedor - - * Source/NSXMLParser.m: Fix include location - -2009-05-10 Adam Fedor - - * Version 1.19.1 - -2009-05-06 Adam Fedor - - * Documentation/news.texi, Documentation/releasenotes.texi: Update. - -2009-05-04 Fred Kiefer - - * Source/NSObject.m: Correct asm for PPC. - Patch by Eric Wasylishen - * Source/NSObject.m: Add support for new gcc atomic build - ins. Currently still disabled. - Patch by David Chisnall - -2009-05-04 Richard Frith-Macdonald - - * NSCharacterSets/GNUmakefile: - * Source/GNUmakefile: - * SSL/GNUmakefile: - * Documentation/GNUmakefile: - * Resources/GNUmakefile: - * Examples/GNUmakefile: - * NSTimeZones/GNUmakefile: - * GNUmakefile: - * Tools/GNUmakefile: - Add help info for the case when gnustep-config can't tell us the - location of the makefiles. - -2009-05-03 Riccardo Mottola - - * Source/NSURLProtocol.m: Removed c99-ism - -2009-05-03 Richard Frith-Macdonald - - * Source/GNUmakefile.postamble: remove generated files from pathconfig - subdirectory on distclean. - -2009-04-27 Richard Frith-Macdonald - - * Source/NSCalendarDate.m: Fix bug #26360 plus optimise a little. - * Source/NSURL.m: Send over DO bycopy as default. - -2009-04-27 Richard Frith-Macdonald - - * Headers/Foundation/NSData.h: - * Source/NSData.m: - Implement new MacOS-X methods for writing data (no support for - returning NSError objects yet). - -2009-04-26 Richard Frith-Macdonald - - * Source/GSFTPURLHandle.m: Implement full support for multiline - responses. Fix for bug #26348 - -2009-04-26 Richard Frith-Macdonald - - * Headers/Foundation/NSTimeZone.h: - * Headers/Foundation/NSPropertyList.h: - * Headers/Foundation/NSZone.h: - * Source/NSHashTable.m: - * Source/NSZone.m: - * Source/NSDecimal.m: - Fix errors generating documentation. - -2009-04-26 Richard Frith-Macdonald - - * Source/NSFileManager.m: ([changeFileAttributes:atPath:]) optimise - to avoid unnecessary creation of NSNumber objects as suggested by - Greg. - -2009-04-25 Richard Frith-Macdonald - - * Source/NSFileManager.m: Reinstate incorrectly reverted changes. - Fix actual bug in Fred's patched version ... some code incorrectly - returning an integer when it should return an NSNumber. - -2009-04-25 08:35-EDT Gregory John Casamento - - * Source/NSFileManager.m: Partial reversion of previous patch. - The calls in the method changeAttribues:atPath: to the GSAttrDictionary - which is used there were erroneously changed to assume an NSNumber. - This was causing a crash in various applications. - -2009-04-24 Fred Morcos - - * Headers/Foundation/NSFileManager.h: - * Source/NSFileManager.m: - Fix -fileOwnerAccountID and -fileGroupOwnerAccountID to return the - correct type. Also fix return type of HFS methods (though these are - Apple filesystem specific and do nothing in GNUstep). - -2009-04-19 Richard Frith-Macdonald - - * Source/NSHashTable.m: - * Source/NSConcreteHashTable.m: - * Source/NSMapTable.m: - * Source/NSConcreteMapTable.m: - * Headers/Additions/GNUstepBase/GSIMap.h: - Changes for GC zeroing weak pointers. Implement enumeration stuff for - new classes. Add code to support subclassing. - -2009-04-18 Richard Frith-Macdonald - - * Source/NSArray.m: Implement the - ([countByEnumeratingWithState:objects:count:]) method. - -2009-04-18 10:15-EDT Gregory John Casamento - - * Source/GSURLPrivate.h: Addition of private method to NSURLProtocol - category. - * Source/NSURLConnection.m: Changes to use the new method and to correct - bug #26107. Patch by: doug@riverrock.org - * Source/NSURLProtocol.m: Addition of static method to look up class - which can handle the given connection protocol. - Patch by: doug@riverrock.org - -2009-04-16 Richard Frith-Macdonald - - * Headers/Foundation/NSHasTable.h: new OSX 10.5 API - * Source/NSHashTable.m: New abstract class - * Source/NSConcreteHashTable.m: concrete implementation - * Source/NSKeyValueObserving.m: Fix incorrect hash table references. - -2009-04-13 Richard Frith-Macdonald - - * Source/GSString.m: Change placeholder string initialisation so that, - in a GC world, it checks to see if the buffer passed to it is - collectable and forces a copy if it isn't. This prevents memory leaks - when a malloc'ed buffer is passed to the initialiser. - -2009-04-11 Richard Frith-Macdonald - - * Source/GSPrivate.h: New private functions. - * Source/NSObject.m: Add function to swizzle isa pointer safely. - * Source/NSZone.m: Add function to check for collectable memory. - * Source/NSData.m: Add finalisation for shared memory and mapped - files. Add finalized subclasses to deal with memory which must be - freed when the NSData is collected. - -2009-04-11 01:12-EDT Gregory John Casamento - - * Source/NSLock.m: Move the warning to a debug log. - -2009-04-10 Richard Frith-Macdonald - - * Source/cifframe.m: - * Source/callrame.m: - Update for GC to use scanned memory to hold pointers we got from - the stack so that memory will persist as long as the invocation - needs it. - -2009-04-10 Richard Frith-Macdonald - - * Source/GSPrivate.h: - * Source/NSString.m: - * Source/NSObject.m: - * Source/GSString.m: - * Source/NSZone.m: - GC tweaks ... Improve realloc when in gc world. - -2009-04-03 Adam Fedor - - * Source/NSObject.m: Revert previous patch (David to fix up later). - -2009-03-31 Richard Frith-Macdonald - - * Headers/Foundation/NSInvocation.h: - * Source/NSInvocation.m: - Remove unused private method pointed out by David Chisnall. - -2009-03-31 Richard Frith-Macdonald - - * Headers/Foundation/NSDebug.h: - * Source/mframe.m: - * Source/NSObject.m: - Cleanups for building with other compilers as suggested/provided - by David Chisnall. - -2009-03-29 Richard Frith-Macdonald - - * Source/NSString.m: Fix error in parsing root of UNC path - -2009-03-28 Fred Kiefer - - * Source/NSSocketPort.m (-receivedEvent:...forMode:): Fix usage of - ET_WDESC for MINGW32. - -2009-03-24 Richard Frith-Macdonald - - * Source/GSSocketStream.h: - * Source/GSSocketStream.m: - Avoid unnecessary memory allocation. - Use weak pointers to break finalisation cycles. - * Source/NSZone.m: Use GC debug unless built with 'debug=no' - Allocate memory ignoring pointers into the allocated data. - -2009-03-21 Richard Frith-Macdonald - - * configure.ac: - * configure: - * Headers/Additions/GNUstepBase/config.h.in: - * Source/NSDebug.m: - Try using sigsetjmp for dealing with signals during stack trace, - in case it helps work arouns bugs in signal handling. - -2009-03-21 Richard Frith-Macdonald - - * Source/NSMessagePort.m: - * Source/NSSocketPort.m: - Fix to treat exceptional (out of band) event as meaning a readable - rather than a writable descriptor. - -2009-03-20 Richard Frith-Macdonald - - * Source/NSURLCredential.m: - * Source/NSURLAuthenticationChallenge.m: - * Source/NSURLDownload.m: - * Source/NSURLCredentialStorage.m: - * Source/NSURLResponse.m: - * Source/NSURLProtocol.m: - * Source/NSURLCache.m: - * Source/NSHTTPCookieStorage.m: - * Source/NSCachedURLResponse.m: - * Source/NSHTTPCookie.m: - * Source/NSURLProtectionSpace.m: - * Source/GSHTTPAuthentication.m: - * Source/NSURLRequest.m: - * Source/NSXMLParser.m: - * Source/NSURLConnection.m: - Fix some errors in header comments. - -2009-03-18 Richard Frith-Macdonald - - * Source/NSNotificationQueue.m: Fix dealloc bug pointed out by - Larry Campbell. - -2009-03-18 Richard Frith-Macdonald - - * Source\win32\GSFileHandle.m: - * Source\win32\NSMessagePort.m: - * Source\win32\NSMessagePortNameServer.m: - * Source\NSConcreteMapTable.m: - * Source\Additions\GSCompatibility.m: - * Source\Additions\GSCategories.m: - * Source\NSData.m: - Fixes for windows and changes to GC code, plus changes for old - compilers which don't support anonymous unions, plus improvement - to error reporting on windows, plus fix to correctly rename - protected files if possible. - -2009-03-16 Richard Frith-Macdonald - - * Source/NSConcretePointerFunctions.h: Minor GC tweaks - * Source/NSMessagePortNameServer.m: Fix map table declaration - * Source/NSKeyedUnarchiver.m: ditto - * Source/NSKeyValueObserving.m: ditto - * Source/NSObject.m: ditto - * Source/GNUmakefile: Add NSConcreteMapTable.m - * Source/NSConcreteMapTable.m: New file for new class - * Source/NSMapTable.m: Change to be an abstract class - * Headers/Foundation/NSMapTable.h: Add new MacOS-X 10.5 API - * Headers/Additions/GNUstepBase/GSIMap.h: Some changes for - new map table API. - -2009-03-12 Bernard Cafferelli - - * configure.ac: Add --disable-zeroconf option to control whether - NSNetServices (and a dependency on libdns_sd) is enabled. - -2009-03-10 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSIArray.h: - * Source/NSNotificationCenter.m: - * Source/NSRunLoop.m: - * Source/NSZone.m: - Various small GC bugfixes to get more of testsuite passing. - -2009-03-09 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSIArray.h: - * Headers/Additions/GNUstepBase/GSIMap.h: - * Headers/Foundation/NSZone.h: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/Additions/Unicode.m: - * Source/GSAttributedString.m: - * Source/GSCountedSet.m: - * Source/GSDictionary.m: - * Source/GSPrivate.h: - * Source/GSSet.m: - * Source/NSArchiver.m: - * Source/NSConnection.m: - * Source/NSHashTable.m: - * Source/NSKeyedArchiver.m: - * Source/NSKeyedUnarchiver.m: - * Source/NSMapTable.m: - * Source/NSNotificationCenter.m: - * Source/NSPortCoder.m: - * Source/NSRunLoop.m: - * Source/NSSerializer.m: - * Source/NSURL.m: - * Source/NSZone.m: - * Source/unix/GSRunLoopCtxt.m: - * Source/win32/GSRunLoopCtxt.m: - More moves towards OSX 10.5 GC compatibility. - With GC add some use of typed memory and remove the old - GNUstep specific GSAtomicMallocZone() from public API. - Still needs new NSHashTable and NSMaptable implementations. - -2009-03-08 Richard Frith-Macdonald - - * Source/GSSocketStream.m: - * Source/GSStream.m: - * Source/NSConnection.m: - * Source/NSKeyedArchiver.m: - * Source/NSKeyedUnarchiver.m: - * Source/NSObject.m: - * Source/NSPort.m: - * Source/NSXMLParser.m: - GC tweaks to use new API. - -2009-03-06 Richard Frith-Macdonald - - * Source/NSObject.m: Remove unused code for holding reference counts - in an external map. - -2009-03-02 Richard Frith-Macdonald - - * Source/GSHTTPURLHandle.m: Implement new mechanism for handling - SOAP responses with HTTP status 500. Interim measure lntil the - NSURLConnection family of class is more complete. - -2009-03-01 Fred Kiefer - - * Source/NSBundle.m (-localizedStringForKey:value:table): Correct - output when NSShowNonLocalizedStrings is YES. - -2009-02-28 Richard Frith-Macdonald - - * Source/NSURLProtocol.m: - Fix for retry with authentication based on patch by Philippe Roussel - -2009-02-27 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: - Fix for bug #25720 as suggested by Michael Johnston - -2009-02-26 Richard Frith-Macdonald - - * Source/NSCharacterSetData.h: - * Source/GSRunLoopWatcher.h: - * Source/GSRunLoopWatcher.m: - * Source/GSRunLoopCtxt.h: - Add missing copyright/license comments. - -2009-02-25 Richard Frith-Macdonald - - * Source/NSUndoManager.m: Revert last change (to match OSX 10.5) - Also rework a little to recreate undocumented OSX behavior of - implicitly creating a top-level undo group if -beginUndoGroup - is called for a manager configured with groupByEvent. - -2009-02-23 Richard Frith-Macdonald - - * Source/NSIndexPath.m: - * Source/GSSocketStream.h: - * Source/NSTimeZone.m: - * Source/NSNetServices.m: - * Source/NSURLCredential.m: - * Source/GSSocketStream.m: - * Source/NSURLAuthenticationChallenge.m: - * Source/NSCalendarDate.m: - * Source/NSPropertyList.m: - * Source/GSConcreteValueTemplate.m: - * Source/NSAffineTransform.m: - * Source/NSConcretePointerFunctions.h: - * Source/NSPathUtilities.m: - * Source/NSScanner.m: - * Source/NSProcessInfo.m: - * Source/NSDistributedNotificationCenter.m: - * Source/NSNotificationQueue.m: - * Source/NSGeometry.m: - * Source/NSConcretePointerFunctions.m: - * Source/NSRunLoop.m: - * Source/NSAttributedString.m: - * Source/NSUndoManager.m: - * Source/NSMethodSignature.m: - * Source/NSUserDefaults.m: - * Source/NSArray.m: - * Source/GSStream.h: - * Source/GSStream.m: - * Source/NSKeyedArchiver.m: - * Source/NSDebug.m: - * Source/unix/NSStream.m: - * Source/NSKeyedUnarchiver.m: - * Source/NSURLDownload.m: - * Source/NSPredicate.m: - * Source/NSAssertionHandler.m: - * Source/NSZone.m: - * Source/NSPort.m: - * Source/GSPrivate.h: - * Source/win32/NSStream.m: - * Source/NSInvocation.m: - * Source/NSFileManager.m: - * Source/NSURLResponse.m: - * Source/NSURLCache.m: - * Source/NSCoder.m: - * Source/NSException.m: - * Source/NSCopyObject.m: - * Source/NSURL.m: - * Source/NSString.m: - * Source/NSObject.m: - * Source/NSDecimalNumber.m: - * Source/cifframe.m: - * Source/Additions/GCArray.m: - * Source/Additions/GSXML.m: - * Source/Additions/GCDictionary.m: - * Source/Additions/GSCategories.m: - * Source/Additions/GSMime.m: - * Source/NSNumber.m: - * Source/NSDecimal.m: - * Source/GSString.m: - * Source/NSThread.m: - * Source/NSHTTPCookie.m: - * Source/NSData.m: - * Source/NSProxy.m: - * Source/NSURLProtectionSpace.m: - * Source/NSError.m: - * Source/NSDictionary.m: - * Source/NSURLRequest.m: - * Source/NSValue.m: - * Source/NSCountedSet.m: - * Source/NSIndexSet.m: - * Source/GSFileHandle.m: - * Source/NSLock.m: - * Source/NSSet.m: - * Source/NSArchiver.m: - * Source/NSXMLParser.m: - * Source/GSURLPrivate.h: - * Headers/Foundation/NSTimeZone.h: - * Headers/Foundation/NSNetServices.h: - * Headers/Foundation/NSCoder.h: - * Headers/Foundation/NSException.h: - * Headers/Foundation/NSHTTPCookieStorage.h: - * Headers/Foundation/NSURLAuthenticationChallenge.h: - * Headers/Foundation/NSCompoundPredicate.h: - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSSpellServer.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSCalendarDate.h: - * Headers/Foundation/NSDecimalNumber.h: - * Headers/Foundation/NSURLHandle.h: - * Headers/Foundation/NSPropertyList.h: - * Headers/Foundation/NSAffineTransform.h: - * Headers/Foundation/NSPathUtilities.h: - * Headers/Foundation/NSScanner.h: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSDistributedNotificationCenter.h: - * Headers/Foundation/NSStream.h: - * Headers/Foundation/NSComparisonPredicate.h: - * Headers/Foundation/NSGeometry.h: - * Headers/Foundation/NSNotificationQueue.h: - * Headers/Foundation/NSRunLoop.h: - * Headers/Foundation/NSDecimal.h: - * Headers/Foundation/NSAttributedString.h: - * Headers/Foundation/NSUndoManager.h: - * Headers/Foundation/NSMethodSignature.h: - * Headers/Foundation/NSUserDefaults.h: - * Headers/Foundation/NSThread.h: - * Headers/Foundation/NSData.h: - * Headers/Foundation/NSHTTPCookie.h: - * Headers/Foundation/NSArray.h: - * Headers/Foundation/NSObjCRuntime.h: - * Headers/Foundation/NSProxy.h: - * Headers/Foundation/NSURLProtectionSpace.h: - * Headers/Foundation/NSKeyedArchiver.h: - * Headers/Foundation/NSDebug.h: - * Headers/Foundation/NSError.h: - * Headers/Foundation/NSURLDownload.h: - * Headers/Foundation/NSKeyValueObserving.h: - * Headers/Foundation/NSDictionary.h: - * Headers/Foundation/NSURLRequest.h: - * Headers/Foundation/NSZone.h: - * Headers/Foundation/NSValue.h: - * Headers/Foundation/NSIndexSet.h: - * Headers/Foundation/NSPort.h: - * Headers/Foundation/NSLock.h: - * Headers/Foundation/NSSet.h: - * Headers/Foundation/NSExpression.h: - * Headers/Foundation/NSInvocation.h: - * Headers/Foundation/NSFileManager.h: - * Headers/Foundation/NSXMLParser.h: - * Headers/Foundation/NSURLResponse.h: - * Headers/Foundation/NSIndexPath.h: - * Headers/Foundation/NSURLCache.h: - * Headers/Additions/GNUstepBase/GSXML.h: - * Headers/Additions/GNUstepBase/GSCategories.h: - * Headers/Additions/GNUstepBase/GSMime.h: - * Headers/Additions/GNUstepBase/GSFileHandle.h: - * Tools/gdnc.h: - * Tools/gdnc.m: - Conversion of everything to use the new MacOS-X 10.5 API where return - values and arguments use the NSInteger, NSUInteger, and CGFloat types. - For now, as suggesed by David, the proper 10.5 behavior is turned off - and those types are equivalent to the types used by the old API. - Edit Headers/Foundation/NSObjCRuntime.h to turn on the new behavior - where the integer types are the same size as a pointer, and the float - type is actually a double on 64bit processors. - -2009-02-23 Richard Frith-Macdonald - - * Source/NSPortCoder.m: - make float and double interchangable to cope with MacOS-X 10.5 - API which can use either for CGFloat. - -2009-02-23 Richard Frith-Macdonald - - * Headers/Foundation/NSGeometry.h: - * Source/NSGeometry.m: - Inspired by Matt Rice's comments on NSEqualRects(), moved the - equality testing functions from the header to the implementation - file and added conditionally compiled code to allow us to do a - fuzzy equality test. Still need to decide whether this is actually - the correct thing to do though. - -2009-02-22 Richard Frith-Macdonald - - * Source/NSUnarchiver.m: - make float and double interchangable to cope with MacOS-X 10.5 - API which can use either for CGFloat. - * Source/NSXMLParser.m: optimize sloppy parser somewhat. - -2009-02-21 Richard Frith-Macdonald - - * Source/mframe/i386/linux: - * Source/mframe/i386/sysv4.2MP: - * Source/mframe/i386/linux-gnu: - * Source/mframe/i386/sysv4.2uw2.1.3: - * Source/mframe/i386/freebsd: - * Source/mframe/i386/openbsd: - * Source/mframe/i386/generic: - Update/fix macro to build method signature information. - -2009-02-20 Richard Frith-Macdonald - - * configure.ac: Add checks for backtrace() function - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * configure: regenerate - * Source/NSDebug.m: Use backtrace() to get stack if possible ... - it's more reliable than gcc's __builtin_frame_address() function. - * Source/cifframe.m: Allocate a slightly larger buffer when - processing invocations ... somehow this fixes a write outside - allocated memory by the ffi library on my 64bit debian system. - -2009-02-17 Richard Frith-Macdonald - - * Source/NSUndoManager.m: Don't post checkpoint notification when - beginning top level group. Fix for #25607 - -2009-02-16 Adam Fedor - - * configure.ac: Look in LOCAL for headers/libs - - * Headers/Foundation/NSObjCRuntime.h: Define NSINTEGER_DEFINED. - * Headers/Additions/GNUstepBase/GSCategories.h, - Headers/Additions/GNUstepBase/GSUnion.h: Additional definitions to compile - with apple-apple-apple. - -2009-02-16 Richard Frith-Macdonald - - * Source/pathconfig/configure.ac: Warn if gnustep-config not found. - * Source/pathconfig/configure: regenerate - * Headers/Foundation/NSPointerArray.h: Add more comments. - -2009-02-15 Richard Frith-Macdonald - - * Source/NSPointerArray.m: Initial implementation. Untested. - No coding/decoding support. - -2009-02-14 Richard Frith-Macdonald - - * Source/NSPointerFunctions.m: Add some more functions to be set by - options. - -2009-02-12 Richard Frith-Macdonald - - * Source/NSPortCoder.m: Use scanned memory to hold array - * Source/NSKeyedUnarchiver.m: ditto - * Source/NSFileManager.m: ditto - -2009-02-11 Richard Frith-Macdonald - - * Source/NSUnarchiver.m: - * Source/NSString.m: - * Source/Additions/GSMime.m: - * Source/NSData.m: - * Source/GSHTTPAuthentication.m: - * Source/NSSerializer.m: - * Source/unix/GSRunLoopCtxt.m: - * Source/win32/GSRunLoopCtxt.m: - Various changes to use unscanned collectable memory with GC. - -2009-02-11 Richard Frith-Macdonald - - * Source/NSNotificationCenter.m: Fix bug removing observations for - collected observers. - * Headers/Foundation/NSGarbageCollector.h: - * Source/NSGarbageCollector.m: - * Source/NSObject.m: - Update the behavior of the -zone method to match MacOS-X 10.5 and - always return the default zone when used with GC. - -2009-02-10 Richard Frith-Macdonald - - * Source/NSConcretePointerFunctions.h: - * Source/NSConcretePointerFunctions.m: - * Source/NSPointerFunctions.m: - * Source/NSPointerArray.m: - * Source/GNUmakefile: - Partial implementation of concrete pointer functions class. - -2009-02-09 Xavier Glattard - - * Headers/Foundation/NSPredicate.h: - * Source/NSPredicate.m: Declare and implement two new methods for - filtering NSSet: - * [-filterUsingPredicate:] - * [+filteredSetUsingPredicate:] - -2009-02-09 Richard Frith-Macdonald - - * Source/win32/NSMessagePortNameServer.m: Fix GC error on windows - as reported by Ly Liyi - * configure.ac: Check for new GC_allow_register_threads() function. - * Source/NSThread.m: Attempt to fix thread registration for GC. - * Source/NSObject.m: Initialise finalize on mingw as well as unix. - * Source/NSZone.m: Remove unnecessary casts. - -2009-02-09 Matt Rice - - * Headers/Foundation/NSZone.h (GSMakeWeakPointer): Rename class - variable to theClass for objc++. - -2009-02-09 Richard Frith-Macdonald - - * Source/NSArray.m: Implement new methods for inserting and replacing - objects at indexes in an NSIndexSet. - * Headers/Foundation/NSObject.h: Minor whitespace fix - * Source/NSNetServices.m: Mark unimplemented method. - * Headers/Foundation/NSXMLDocument.h: new class - * Headers/Foundation/NSXMLNode.h: new class - * Headers/Foundation/NSXMLNodeOptions.h: new class - * Headers/Foundation/NSXMLDTD.h: new class - * Headers/Foundation/NSXMLDTDNode.h: new class - * Headers/Foundation/NSXMLElement.h: new class - * Headers/Foundation/Foundation.h: Add new class headers - * Source/NSXMLDocument.m: skeleton of class - * Source/NSXMLDTD.m: skeleton of class - * Source/NSXMLNode.m: skeleton of class - * Source/NSXMLDTDNode.m: skeleton of class - * Source/NSXMLElement.m: skeleton of class - * Source/NSXMLPrivate.h: Private header for all NSXMLNode based stuff. - * Source/GNUmakefile: Add new NSXML classes - * Source/DocMakefile: ditto - Mostly, add the (unimplemented) XML classes introduced in the latest - version of MacOS-X. Currently the classes are unimplemented method - stubs, but the idea is to wrap libxml2 in a similar way to that in - which GSXML does it. - NB. The current ivar layout is reverse engineered from MacOS-X on the - assumption that we will try to be extremely compatible and use the - same (inferred) mechanism of having the libxml2 tree be the master - data and only using the objc ivars to cache information when we - retrieve it in the form of NSStrings etc. Maybe we will chose to - do something different later. - -2009-02-09 Richard Frith-Macdonald - - * Source/Additions/GSObjCRuntime.m: Correct error comparing method - signatures. Fixes bug #25520 - -2009-02-04 Richard Frith-Macdonald - - * Source/NSBundle.m: Use pointerValue rather than - nonretainedObjectValue to hold classes ... because the garbage - collector might collect the latter, and we really just need to - hold references to classes without sending messages to them. - * Headers/Additions/GNUstepBase/GSIArray.h: Alterations for noe - Apple GC API - * Source/NSIndexSet.m: Use scanned memory for arrays. - -2009-02-04 15:00-EST Gregory John Casamento - - * Source/NSUnarchiver.m: Correct issue with printing class name - when the unarchiver can't find the class. - -2009-02-04 Richard Frith-Macdonald - - * Source/NSMapTable.m: - * Source/NSHashTable.m: - * Source/NSPortCoder.m: - * Source/NSKeyedArchiver.m: - * Source/NSGarbageCollector.m: - * Source/NSZone.m: - * Source/GSDictionary.m: - * Source/GSCountedSet.m: - * Source/GSAttributedString.m: - * Source/NSNotificationCenter.m: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/GSSet.m: - * Source/NSConnection.m: - * Source/NSSerializer.m: - * Source/NSArchiver.m: - * Headers/Foundation/NSZone.h: - * Headers/Additions/GNUstepBase/GSIMap.h: - Scrap GSScannedMallocZone().. not really needed. - -2009-02-04 Richard Frith-Macdonald - - * Source/NSURLProtocol.m: Add some diagnostics and ensure that - delegates are removed from streams. - * Source/NSURLConnection.m: Add diagnostics for redirect. - * Source/GSStream.m: Set delegate to nil after failure. - -2009-02-04 David Chisnall - - * Source/GSArray.m: Further fast enumeration bugfixes. - * Source/GSEnumerator.m: ditto. - -2009-02-03 Richard Frith-Macdonald - - * Source/NSZone.m: Restore binary compatibility with earlier code. - Thanks to David Chisnall for the idea. - -2009-01-30 Richard Frith-Macdonald - - * Source/NSURL.m: For file URL, make relative path absolute. - * Source/GSHTTPURLHandle.m: - * Source/Additions/GSMime.m: - Change HTTP status code to be an NSNumber rather than NSString - for MacOS-X compatibility - -2009-01-30 Richard Frith-Macdonald - - * Documentation/readme.texi: - * README: Remove reference to Testing - * Examples/nsconnection_server.m: - * Examples/diningPhilosophers.m: - * Examples/nsconnection_client.m: - * Examples/nsconnection.m: Transferred from Testing - * Testing: removed - Removed Testing subdirectory. Now that locking tests are in the - testsuite all the code here is probably obsolete. If we find any - cases where that's not the case, we should recover anything we - need from svn and add it to the testsuite. - -2009-01-30 Richard Frith-Macdonald - - * Source/NSLock.m: Fixed last change to match MacOS-X behavior. - -2009-01-29 17:49-EST Gregory John Casamento - - * Source/NSLock.m: Change to correct documented/tested and observed - inconsistency between Cocoa (and OpenStep) and GNUstep. - Reinstatement of correction for bug #25307. Testing on both OpenStep - and on Cocoa clearly illustrates that throwing an exception in this - case was incorrect. It now emits a warning when the lock is attempted - again, but does not throw an exception. - * Testing/locktest/locktest.m: Change to test to correctly test - [NSConditionLock lock] - -2009-01-28 21:48-EST Gregory John Casamento - - * Testing/locktest/GNUmakefile - * Testing/locktest/GNUmakefile.preamble - * Testing/locktest/locktest.1 - * Testing/locktest/LockTestInfo.plist - * Testing/locktest/locktest.m - * Testing/locktest/locktest_Prefix.pch - * Testing/locktest/locktest.xcodeproj/project.pbxproj - * Testing/locktest/PC.project: Test which confirms the behavior - observed on Mac OS X/Cocoa. - -2009-01-28 Richard Frith-Macdonald - - * Source/NSEnumerator.m: Fix bug in fast enumeration code. - * Source/GSArray.m: Fix bug in array insertion introduced by last - patch. - -2009-01-28 David Chisnall - - * Headers/Foundation/NSEnumerator.h: - * Source/NSEnumerator.m: - * Source/GSArray.m: - * Source/GSprivate.h: - Add Apple's fast enumeration protocol. - -2009-01-28 Richard Frith-Macdonald - - * Source/NSException.m: Fix problem preventing stack traccces from - being generated. - -2009-01-27 Richard Frith-Macdonald - - * Source/NSValue.m: ([valueWithNonretainedObject:]) zero the reference - when the object is collected. - -2009-01-25 Richard Frith-Macdonald - - * Source/NSURL.m: Compatibility tweaks for a few MacOS-X oddities... - Initialise file URLs with a host of 'localhost' even though they - should really have none. - Return paths without a trailing slash, even when they were set - with one. - -2009-01-25 Richard Frith-Macdonald - - * Source/NSString.m: Fix for bug #25400 - * Tools/gdnc.m: Fix failure to log exception (bug #25396) - * Tools/gdomap.c: Use snprintf for paranoid double check - of data in log buffer. - -2009-01-23 Riccardo Mottola - - * Source/NSPointerFunctions.m, - * Headers/Foundation/NSPointerFunctions.h: Fix return pointer type - -2009-01-23 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GNUstep.h: - Optimise retain/release management macros for the case where they - are dealing with none-nil values. - * Headers/Additions/GNUstepBase/GSIMap.h: - Some changes moving towards use of typed memory for gc. - * Headers/Foundation/NSPointerArray.h: New class header. - * Source/NSPointerArray.m: Skeletal (non-working) implementation - -2009-01-22 Richard Frith-Macdonald - - * Source/GSHTTPURLHandle.m: - Improve debug logging by including the address of the actual - handle concerned so that you can see which handle is doing what - when there are multiple handles in use. - * Source/NSGarbageCollector.m: Implement last methods. - * Headers/Foundation/NSGarbageCollector.h: Improve documentation. - * Source/NSAutoreleasePool.m: ([-drain[) Implemented. - * Headers/Foundation/NSAutoreleasePool.m: ([-drain]) fix comment. - * Source/NSPointerFunctions.m: New class implementation - * Headers/Foundation/NSPointerFunctions.h: Fix some declarations - * Headers/Foundation/Foundation.h: Include NSPointerFunctions.h - * Source/GNUmakefile: Build and install NSPointerFunctions - -2009-01-21 Richard Frith-Macdonald - - * Source/NSUserDefaults.m: ([setObject:forKey:]) copy the object - rather than just retaining it. Fixes bug #23570 - -2009-01-20 Richard Frith-Macdonald - - * Documentation/manual/ExceptionHandling.texi: Fix error in - example of use of NS_VALUERETURN spotted by David Chisnall. - -2009-01-20 Richard Frith-Macdonald - - * Source/NSKeyValueObserving.m: Automtically remove collected observers - In a garbage collecting environment. - * Headers/Foundation/NSZone.h: - * Source/NSZone.m: - Add new functions for handling weak pointers. This allows all code - which uses the boehm garbage collector header to be localised in - NSZone.m and NSGarbageCollector.m - * Source/NSNotificationCenter.m: - Update to use new functions. - * Source/Additions/GSInsensitiveDictionary.m: - Fix to use scanned memory in a garbage collecting environment. - -2009-01-19 Richard Frith-Macdonald - - * configure.ac: Add options from pathconfig - * configure: regenerate - -2009-01-19 Richard Frith-Macdonald - - * Headers/Foundation/NSZone.h: - * Source/NSZone.m: - Add NSAllocateCollectable() and NSReallocateCollectable() functions. - Move inline stuff from header to source fle so that GC differences - are hidden. Change behavior under GC so that the default malloc - zone is non-collectable (as under MacOS-X). - * Headers/Additions/GNUstepBase/GSIMap.h: - Use scanned collectable memory for map. - * Source/Additions/GSObjCRuntime.m: - Use NSAllocateCollectable() for fast buffer. - * Source/GSArray.m: - * Source/GSCountedSet.m: - * Source/GSDictionary.m: - * Source/GSSet.m: - * Source/NSArchiver.m: - * Source/NSConnection.m: - * Source/NSHashTable.m: - * Source/NSKeyedArchiver.m: - * Source/NSMapTable.m: - * Source/NSNotificationCenter.m: - * Source/NSObject.m: - * Source/NSPortCoder.m: - * Source/NSSerializer.m: - * Source/NSPropertyList.m: - Use scanned collectable memory in places where we allocate memory to - hold pointers. This change is needed because of the switch to have - the default zone use unscanned uncollectable memory as in MacOS-X. - These changes probably just scratch the surface ... we need to review - all memory allocation as, anywhere we allocate memory now will need - to be done differently under GC. This does mean that all existing - code needs more work to port to GC than it otherwise would. On the - other hand, a switch to GC is really quite a major design change. - -2009-01-17 Wolfgang Lux - - * Source/unix/GSRunLoopCtxt.m (+awakenedBefore): Fix typo. - -2009-01-17 Richard Frith-Macdonald - - * Source/NSLock.m: Revert last change. - The Cocoa documentation actually says nothing about exceptions either - way. I recall there was some discussion about lock behavior a few - years ago, which concluded that the GNUstep behavior was the best - available ... it returns NO if the lock is unavailable, but raises an - exception if you try to lock the lock twice from the same thread, - since locking twice from the same thread is almost guaranteed to be - a programming error. - If we want to remove this check, we need to do it consistently for - all locks and document the new behavior. - -2009-01-16 17:26-EST Gregory John Casamento - - * Source/NSLock.m: Correction for bug #25307. According to Cocoa - documentation, NSConditionLock should return NO, if the lock is - unavailable. No exception should be thrown. - -2009-01-16 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Revert temporary hack to work around bug in - NSAnimation, hopefully fixed in NSAnimation now. - -2009-01-15 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Cleaned up a little and added hack as a temporary - fix for #25327, though I'm suspecting that the actual problme is in the - NSAnimation code. - -2009-01-15 Richard Frith-Macdonald - - * Source/NSRunLoop.m: - * Source/unix/GSRunLoopCtxt.m: - * Source/GSRunLoopCtxt.h: - * Source/win32/GSRunLoopCtxt.m: - Introduce new method to quickly check for notification of methods - to perform in the current loop. - -2009-01-14 Richard Frith-Macdonald - - * Source/NSGarbageCollector.m: Avoid compiler warning - * Source/pathconfig/pathconfig.mak.in: Fix syntax error in warning - * Headers/Additions/GNUstepBase/GSCategories.h: remove obsolete methods - * GNUmakefile: Fix order of includes - * Source/GSArray.m: Remove unused line from last change - * Source/NSNotificationCenter.m: Remove unused line - -2009-01-13 18:35-EST Gregory John Casamento - - * Source/GSArray.m - * Source/NSNotificationCenter.m: Quick fixes for two compiler - errors introduced by previous change. - -2009-01-13 Richard Frith-Macdonald - - * Source/NSGarbageCollector.m: Mark the two unimplemented methods. - * Source/NSNotificationCenter.m: Automatically remove observers if - they are collected by the GC system. - * Source/NSThread.m: Make the GC system aware of each thread if poss. - * Source/GSArray.m: Don't use inline array class with GC. - * configure.ac: Add check for GC_register_my_thread - -2009-01-12 Richard Frith-Macdonald - - * Source/GNUmakefile: - * Headers/Foundation/NSGarbageCollector.h: - * Source/NSGarbageCollector.m: - * Headers/Foundation/Foundation.h: - Add new MacOS-X class. - -2009-01-12 Richard Frith-Macdonald - - * Source/NSSocketPort.m: - * Source/NSRunLoop.m: - * Source/NSMessagePort.m: - * Source/NSNotificationCenter.m: - * Source/GSAttributedString.m: - * Source/NSObject.m: - * Source/Additions/GSLock.m: - * Source/NSConnection.m: - * Source/GSFileHandle.m: - * Source/NSLock.m: - * Source/NSDistantObject.m: - * Source/NSTask.m: - * SSL/GSSSLHandle.m: - * Documentation/Base.ispell: - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSNotification.h: - * Headers/Foundation/NSRunLoop.h: - * Headers/Foundation/NSPort.h: - * Headers/Foundation/NSLock.h: - * Headers/Foundation/NSTask.h: - * Headers/Additions/GNUstepBase/GSFileHandle.h: - Change GC finalization API to match MacOS-X ... abandon libFoundation - compatibility in GC behavior. - -2009-01-12 Richard Frith-Macdonald - - * Source/NSIndexPath.m: - * Source/NSSocketPortNameServer.m: - * Source/NSTimeZone.m: - * Source/GSInvocation.h: - * Source/GSSocketStream.m: - * Source/NSValueTransformer.m: - * Source/NSPortCoder.m: - * Source/NSSpellServer.m: - * Source/NSBundle.m: - * Source/NSURLHandle.m: - * Source/NSPropertyList.m: - * Source/NSPathUtilities.m: - * Source/NSProcessInfo.m: - * Source/NSDistributedNotificationCenter.m: - * Source/GNUmakefile: - * Source/NSSocketPort.m: - * Source/NSRunLoop.m: - * Source/NSUserDefaults.m: - * Source/NSArray.m: - * Source/NSMessagePortNameServer.m: - * Source/NSDebug.m: - * Source/NSKeyedUnarchiver.m: - * Source/NSKeyValueObserving.m: - * Source/GSHTTPURLHandle.m: - * Source/GSFFIInvocation.m: - * Source/NSMessagePort.m: - * Source/NSInvocation.m: - * Source/NSFileManager.m: - * Source/NSURLResponse.m: - * Source/NSURLProtocol.m: - * Source/NSException.m: - * Source/NSURL.m: - * Source/NSString.m: - * Source/NSObject.m: - * Source/NSDecimalNumber.m: - * Source/Additions/GSXML.m: - * Source/Additions/GNUmakefile: - * Source/Additions/GSCategories.m: - * Source/Additions/GCDictionary.m: - * Source/Additions/GSMime.m: - * Source/GSString.m: - * Source/NSConnection.m: - * Source/NSThread.m: - * Source/NSHost.m: - * Source/NSProtocolChecker.m: - * Source/GSHTTPAuthentication.m: - * Source/NSSerializer.m: - * Source/NSClassDescription.m: - * Source/GSFileHandle.m: - * Source/NSSet.m: - * Source/NSDistantObject.m: - * Source/NSTask.m: - * Source/NSNumberFormatter.m: - * Source/GSFTPURLHandle.m: - * SSL/GSSSLHandle.m: - * configure.ac: - * configure: - * base.make.in: - * Tools/sfparse.m: - * Tools/plget.m: - * Tools/AGSParser.m: - * Tools/autogsdoc.m: - * Tools/AGSOutput.m: - * Tools/HTMLLinker.m: - Tweaks to get things to compile with garbage collection again - and (mostly) compile without warnings. - -2009-01-09 Richard Frith-Macdonald - - * Source/NSTimer.m: ([invalidate]) release target and user info. - -2009-01-07 Richard Frith-Macdonald - - * Source/NSBundle.m: Revert last change. Remove undocumented code - which looked for operating system specific files. Also changed - behavior when given a nil/empty extension to match MacOS-X. - Also optimised and simplified code and changed a private method - which was missing the leading underscore. - -2009-01-07 16:33-EST Gregory John Casamento - - * Source/NSBundle.m: Correct issue where *-gnustep.* is not - searched for when explicitly calling pathForResource:... - -2009-01-06 Richard Frith-Macdonald - - * configure: - * config.mak.in: - * Source/NSPathUtilities.m: - * Source/GNUmakefile: - * Source/pathconfig: - * Source/pathconfig/configure: - * Source/pathconfig/configure.ac: - * Source/pathconfig/pathconfig.h.in: - * Source/pathconfig/pathconfig.mak.in: - * SSL/GNUmakefile: - * configure.ac: - * Documentation/GNUmakefile: - * NSTimeZones/GNUmakefile: - * GNUmakefile: - * Tools/GNUmakefile: - * Testing/GNUmakefile: - Move path configuration stuff into separate subdirectry/file so that - we can hack it more easily and so that only the code that needs it - will include it. - -2009-01-06 Nicola Pero - - * config.mak.in: Check here if GNUSTEP_BASE_DOMAIN and - GNUSTEP_INSTALLATION_DOMAIN do not match when using relative - paths. If they do not match, print a long explanation of how to - fix the problem, and abort. If relative paths are not used, - automatically set GNUSTEP_INSTALLATION_DOMAIN to the domain that - was chosen at configure time - unless overridden on the command - line. - * Makefile.postamble: Removed before-all rule that was doing the - check now in config.mak.in. - - * SSL/Makefile.postamble (config.mak): Touch config.mak after - running config.status to prevent spurious invocations of - config.status. - (config.h): Always touch config.h after running config.status for - the same reason. - -2009-01-06 Nicola Pero - - * configure.ac: Detect relative paths in the paths that we - hardcode into gnustep-base, and set the - GNUSTEP_BASE_RELATIVE_PATHS variable if any is found. - * configure: Regenerated. - * config.mak.in: Added GNUSTEP_BASE_RELATIVE_PATHS. - * Makefile.postamble: Only do the automatic reconfiguration at - install time if GNUSTEP_BASE_RELATIVE_PATHS is set. Make the - message printed when we reconfigure more prominent. - -2009-01-05 17:58-EST Gregory John Casamento - - * Source/NSBundle.m: Use CFBundleExecutable if NSExecutable isn't - present when loading the bundle object code. - -2009-01-05 Fred Kiefer - - * Source/NSKeyValueObserving.m (-overrideSetterFor:): Only output - a NSDebugLLog() not an NSLog() when the class has no setter for - the key. - -2009-01-05 Fred Kiefer - - * Source/NSString.m (-paragraphRangeForRange:, - -getParagraphStart:...): Basic implementation of these methods. - -2009-01-05 Richard Frith-Macdonald - - * Source/NSRunLoop.m: check for performers in thread even if there are - no input sources available. - * Source/unix/GSRunLoopCtxt.m: Add diagnostics - * Source/win32/GSRunLoopCtxt.m: Add diagnostics - * Testing/thread.m: Change to allow perform in maion thrad to take - place and program to terminate. - -2009-01-04 Richard Frith-Macdonald - - * Source/mframe/sparc64/generic: guess at a config - * Source/mframe/sparc64/openbsd: guess at a config - * Source/mframe/configure.ac: add sparc64 - * Source/mframe/configure: regenerate - Guess at config for sparc64 openbsd - -2009-01-02 Richard Frith-Macdonald - - * Source/NSBundle.m: ([+bundleForLibrary:]) return nil if the - supplied library name is empty. - -2008-12-31 Fred Kiefer - - * Source/NSDecimalNumber.m (-initWithBytes:objCType:): Avoid - memory leak and memory corruption by retaining notANumber before - returning it. - -2008-12-29 Richard Frith-Macdonald - - * Makefile.postamble (before-all): Remove test for mingw on situation - which can occur on all systems, not just mingw. - -2008-12-25 11:10-EST Gregory John Casamento - - * Source/GNUmakefile: Add new NSObjectNSComparisonMethods.m - category to the makefile. - * Source/NSObject+NSComparisonMethods.m: Added to implement - Mac OS X specific methods for comparison of objects. On Cocoa these - are in NSScriptWhoseTests.h, but since GNUstep doesn't support - Apple Script I've put them in a separate category for now. Some - applications use these to do comparisons (even though they are for - scripting). The location of these may change in the future depending - on if we implement scripting. - -2008-12-24 Nicola Pero - - * configure.ac: Improved help for --with-installation-domain=xxx. - If no --with-installation-domain=xxx option is used, and - gnustep-config supports the new option - --installation-domain-for=gnustep-base, use it to determine the - installation domain as accurately as possible (including - supporting the environment variable GNUSTEP_INSTALLATION_DOMAIN - and the installation-domains.conf file). Otherwise fall back to - LOCAL. If an invalid installation domain is provided on the - command-line, abort with an error. - * configure: Regenerated. - * GNUmakefile: Set PACKAGE_NAME before importing common.make. Do - not try to set GNUSTEP_BASE_DOMAIN or GNUSTEP_INSTALLATION_DOMAIN. - * Makefile.postamble (before-all): Only check that - GNUSTEP_BASE_DOMAIN matches GNUSTEP_INSTALLATION_DOMAIN on MinGW. - Quote GNUSTEP_BASE_DOMAIN and GNUSTEP_INSTALLATION_DOMAIN to catch - the case when one of them is empty. Added ECHO_NOTHING to the - rule to suppress ugly code output. Print an error message when - reconfiguring automatically. - -2008-12-22 Richard Frith-Macdonald - - * Version 1.19.0 - * Documentation/news.texi: - * Documentation/ReleaseNotes.gsdoc: - Update for new release. - * configure.ac: Fix error checking for objc_set_unexpected - * configure: regenerate - -2008-12-22 Richard Frith-Macdonald - - * config.mak.in: - * configure: - * Makefile.postamble: - * configure.ac: - * GNUmakefile: - Update from stable branch. - -2008-12-21 Adam Fedor - - * Update documentation for version 1.18.0 - -2008-12-19 Nicola Pero - - * All GNUmakefiles: removed GNUSTEP_CORE_SOFTWARE=YES and - added PACKAGE_NAME=gnustep-base. - * GNUmakefile: Export PACKAGE_NAME to reduce chances of a problem - if a GNUmakefile in a subdirectory is missing it. - * Tools/make_strings/GNUmakefile: Do not set PACKAGE_NAME to - make_strings. - * Testing/synctest/GNUmakefile: Do not set PACKAGE_NAME to Synctest. - -2008-12-19 Richard Frith-Macdonald - - * Source/NSPathUtilities.m: Merge in bugfixes from stable branch. - -2008-12-18 Nicola Pero - - * All GNUmakefiles: added GNUSTEP_CORE_SOFTWARE=YES at the - beginning. - * GNUmakefile: Export GNUSTEP_CORE_SOFTWARE to reduce chances of a - problem if a GNUmakefile in a subdirectory is missing it. - * Documentation/General/GNUmakefile: Removed setting - GNUSTEP_INSTALLATION_DOMAIN to SYSTEM. - -2008-12-17 Richard Frith-Macdonald - - * Source/NSConnection.m: - * Tools/gdnc.m: - Enable keepalive only on mswindows and for server connections using - NSMessagePort. - -2008-12-16 Richard Frith-Macdonald - - * Source/NSLock.m: Tiny cleanup of lock finalisation process. - -2008-12-15 Richard Frith-Macdonald - - * Source/NSURL.m: When initialising with schem, host and path, allow - the host to contain username, password and port as well as just the - host. Document this change (which seems to be how MacOS-X works). - -2008-12-09 Wolfgang Lux - - * Source/unix/GSRunLoopCtxt.m (-pollUntil:within): Add missing - local variable declaration and fix incorrect arguments for some - receivedEvent:type:extra:forMode: messages in the select based - implementation. - -2008-12-08 Richard Frith-Macdonald - - * Source/NSKeyedUnarchiver.m: ([versionForClassName:]) implement - * Source/NSUnarchiver.m: - * Source/NSCoder.m: - * Headers/Foundation/NSCoder.h: - Update method to return NSInteger. - -2008-12-07 Adam Fedor - - * configure.ac: Add custom objc library check from gnustep-make - (So we can find libobjc in LOCAL domain). - -2008-12-07 Richard Frith-Macdonald - - * Headers/Foundation/NSConnection.h: - * Source/NSConnection.m: - Fix keepalive bugs. - -2008-12-07 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/NSTask+GS.h: NSTask category - * Headers/Additions/GNUstepBase/GSCategories.h: remove NSTask - * Source/NSDistributedNotificationCenter.m: Use new header - * Source/NSSocketPortNameServer.m: Use new header - Reorganise so we have a lightweight header for the category of - NSTask containing additional gnustep specific methods. - -2008-12-06 Wolfgang Lux - - * Source/NSBundle.m (+bundleForLibrary:version:): Fix infinite - loop in code dropping the extension from the library name. - -2008-12-06 Richard Frith-Macdonald - - * Source/Additions/GSXML.m: - Hack to avoid issues on systems where the xml headers use the reserved - word 'id'. - -2008-12-06 Richard Frith-Macdonald - - * Source/Additions/GSCategories.m: ([+launchPathForTool:]) - Convenience method to locate a tool in the standard locations or in the - PATH so that it can be used as the launch path of a task. - -2008-12-05 Nicola Pero - - * configure.ac: On mingw32, set GNUSTEP_BASE_PATH to - GNUSTEP_LOCAL_TOOLS by default to match the new default - installation domain. Added new option --with-installation-domain - allowing to override this setting. - * configure: Regenerated. - -2008-12-05 Richard Frith-Macdonald - - * Source/NSBundle.m: ([bundleForLibrary:version:]) extract version - from end of library name if possible. - ([_addFrameworkFromClass:]) find the framework directory from path to - the dll on windows. - -2008-12-04 Richard Frith-Macdonald - - * Source/Additions/GSObjCRuntime.m: Fix minor thread-safety issue - with behaviors ... lock the runtime while modifying method lists. - * Source/NSDictionary.m: Fix initialisation order so that if two - threads are initialising the cached class info should always be - set up in the correct order. - * Source/NSSet.m: ditto. - -2008-12-04 Richard Frith-Macdonald - - * Source/NSURL.m: Implement ipv6 addresses as per RFC2732 - Fixes #25003 - -2008-12-02 Richard Frith-Macdonald - - * Source/NSURLProtocol.m: - Add class for caching pairs of socket streams so we can eventually - implement connection keepalive. - -2008-12-01 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: - * Source/NSURLProtocol.m: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - * Testing/nsconnection_client.m: - When working with abstract selectors, try to use untyped ones so that - we don't confuse checks we put into the method signature code. - -2008-11-30 Wolfgang Lux - - * install.sh: Fix header syntax and provide default for make - command argument. - -2008-11-28 Richard Frith-Macdonald - - * config/config.unexpected.m: Add check for objc_set_unexpected - * configure.ac: Use new check - * configure: Regenerate - * Headers/Additions/GNUstepBase/config.h.in: Regenerate - * Source/GSSocketStream.m: Fix reliabce on expression evaluation order - * Source/NSException.m: Implement uncaught exception handler for - when native objc exceptions are enabled. - -2008-11-27 Fred Kiefer - - * configure.ac: Correct typing error in last change. - * configure: regenerate - -2008-11-27 Richard Frith-Macdonald - - * configure.ac: check for native exceptions use. - * configure: regenerate - Disable the use of ffcall with native exceptions as the two are - incompatible (ffcall changes the stack so that throwing an exception - will crash the process). - -2008-11-27 Richard Frith-Macdonald - - * Source/NSDistributedNotificationCenter.m: - * Tools/gdnc.h: - * Tools/gdnc.m: - Use NSUInteger for the observer ID. - -2008-11-27 Richard Frith-Macdonald - - * Documentation/GNUmakefile: - * GNUmakefile: - * NSCharacterSets/GNUmakefile: - * NSTimeZones/GNUmakefile: - * Resources/GNUmakefile: - * Source/GNUmakefile: - * SSL/GNUmakefile: - * Tools/GNUmakefile: - Removed GNUSTEP_INSTALLATION_DOMAIN. - NB. This means that gnustep-base will now install in the local domain - by default, and to get the old behavior you will need to do - 'make GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install' - The rationale for this change is that the system domain is for - resources installed by the operating system packagers, but the - local domain is for add-ons you install yourself (to be used by - all users of the system), and you don't normally want to overwrite - the operating system supplied version by accident. - -2008-11-26 10:09-EST Gregory John Casamento - - * Headers/Additions/GNUstepBase/GSVersionMacros.h: Add - defines for earlier version of Mac OS X back to 10.0. - * Source/synchronization.m: Correct a problem found during testing. - * Testing/synctest/main.m: Updated test. - -2008-11-24 Richard Frith-Macdonald - - * Source/NSObject.m: ([methodSignatureForSelector:]) Check that the - types of the selector (if known) and the types of the actual method - match. Raise an NSInternalInconsistencyException if they don't. - -2008-11-23 Richard Frith-Macdonald - - * Source/Additions/unicode/gsm0338.h: Add more mappings from unicode - characters representing accented letters to simple letters in the gsm - alphabet for lossy conversion. - -2008-11-22 Richard Frith-Macdonald - - * re-bump version to 1.17.0 for next release when we make a new - unstable branch. - -2008-11-21 Richard Frith-Macdonald - - * Version: set to 1.15.4 for new release on unstable branch. - * Documentation/ReleaseNotes.gsdoc: Document the 1.15.4 release - Make new release on unstable branch to that it's keeping up with - the bugfixes in the stable branch. - -2008-11-20 Richard Frith-Macdonald - - * Headers/Foundation/NSConnection.h: New ivars - * Source/NSConnection.m: Add diuagnostic information and implement - private mechanism for keepalive (for mswindows, where the NSMessagePort - implementation doesn;t know if the remote end has gone away until it - attempts to send to it). - * Tools/gdnc..m: Use private keepalive mechanism. - -2008-11-19 Richard Frith-Macdonald - - * Source/NSData.m: Fix bug #24883 - * Headers/Foundation/NSRange.h: Update to use NSUInteger - -2008-11-19 Richard Frith-Macdonald - - * configure.ac: Changes to tolerate older version of gnutls - * configure: regenerate - * config/pathtls.m4: Fix typos - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * Source/GSSocketStream.m: Fix to send required events to handler - after SSL or SOCKS module has dealt with them. - * Source/GSStream.h: New method to reset sent events mask - * Source/GSStream.m: ditto - * Source/GSString.m: Fix nil pointer reference - -2008-11-18 Richard Frith-Macdonald - - * Source/NSURL.m: Check class of arguments to designated initialiser - * configure.ac: Warn about bug in libkvm - * configure: Regenerate - * Source/NSProcessInfo.m: Report problem in libkvm and suggest - workarounds. - -2008-11-17 Roland Schwingel - - * Source/GSSocketStream.m: - * Source/NSPropertyList.m: - * Source/NSDistributedNotificationCenter.m: - * Source/NSSocketPort.m: - * Source/NSRunLoop.m: - * Source/GSFFCallInvocation.m: - * Source/NSArray.m: - * Source/inet_ntop.c: - * Source/NSDebug.m: - * Source/NSPredicate.m: - * Source/GSHTTPURLHandle.m: - * Source/GSFFIInvocation.m: - * Source/NSMessagePort.m: - * Source/win32/GSFileHandle.m: - * Source/win32/NSUserDefaults.m: - * Source/win32/NSMessagePort.m: - * Source/win32/GSRunLoopCtxt.m: - * Source/win32/NSMessagePortNameServer.m: - * Source/NSKeyValueMutableArray.m: - * Source/NSURL.m: - * Source/mframe.m: - * Source/NSObject.m: - * Source/NSString.m: - * Source/NSDecimalNumber.m: - * Source/cifframe.m: - * Source/Additions/GSXML.m: - * Source/GSString.m: - * Source/NSConnection.m: - * Source/NSProxy.m: - * Source/GSFormat.m: - * Source/NSSet.m: - * Source/NSTask.m: - * Source/NSCharacterSet.m: - * Source/NSNumberFormatter.m: - Cosmetic changes plus a couple of fixes for 64bit mswindows. - -2008-11-15 Richard Frith-Macdonald - - * Source/NSProcessInfo.m: Remove useless sysctl command. - * Source/NSMessagePort.m: Ensure port is not deallocated while - being invalidated. Fix memory leak of port lock. - * Source/NSSocketPort.m: ditto - -2008-11-15 Wolfgang Lux - - * Source/NSMessagePort.m (-invalidate, -removeHandle:): Fix - potential crash while closing a message port. - -2008-11-14 Wolfgang Lux - - * Source/NSProcessInfo.m (-processorCount, -activeProcessorCount): - Improve portability. - - * Source/NSPathUtilities.m (NSTemporaryDirectory): Use /var/tmp on - Darwin since /tmp is cleaned regularly. - -2008-10-13 Richard Frith-Macdonald - - * Source/NSPage.m: Update to use NSUInteger and to cope with large - address space in windows. - * Headers/Foundation/NSObjCRuntime.h: typedef NSUInteger earlier - * Headers/Foundation/NSZone.h: Update to use NSUInteger. - * Source/NSProcessInfo.m; implement new MacOS-x 5 methods based on - Fred's suggestion and Scotts code as fallback and wiht a version - for mswindows too. - -2008-10-11 Richard Frith-Macdonald - - * Source/NSUserDefaults.m: implement KVC methods to get and set values - as these appear to be an undocumented feature of MacOS-X (bug #24807). - -2008-11-05 17:27-EST Gregory John Casamento - - * Testing/synctest/GNUmakefile - * Testing/synctest/GNUmakefile.postamble - * Testing/synctest/GNUmakefile.preamble - * Testing/synctest/main.m - * Testing/synctest/PC.project - * Testing/synctest/PC.project.backup - * Testing/synctest/SyncTestInfo.plist: Added test tool for - @synchronize. - -2008-10-30 Richard Frith-Macdonald - - * Tools/gdomap.c: Improve error messages and information about - the -a option. - * Source/NSPredicate.m: parse literal strings - -2008-10-29 Richard Frith-Macdonald - - * Source/NSException.m: Fix stacktrace to be available when built - without DEBUG=YES. Check environment variable to activate/deactivate. - * Documentation/Basegsdoc: Improve documentation of stack trace. - -2008-10-28 Richard Frith-Macdonald - - * Source/GSString.m: Cope with loads of leading space in - intValue and doubleValue. - -2008-10-27 Richard Frith-Macdonald - - * Source/GSFormat.m: Fix possible problem when current unix locale - does not use '.' as the decimal separator. - -2008-10-27 Nicola Pero - - * Headers/Foundation/NSFileManager.h: Fixed typo - declare NSError - class before referencing it. - -2008-10-26 20:59-EDT Gregory John Casamento - - * Headers/Foundation/NSFileManager.h: Added declaration for new method - here. - * Source/NSFileManager.m: Added implementation for the method - -(BOOL)createDirectoryAtPath:withIntermediateDirectories:attributes: - error:. - -2008-10-19 Wolfgang Lux - - * configure.ac: fix test for sychronization in objc runtime. - -2008-10-19 Richard Frith-Macdonald - - * Source/synchronization.m: make internal functions private. - -2008-10-16 Richard Frith-Macdonald - - * Source/NSCalendarDate.m: Fix typo (bug #24573) - -2008-10-14 Richard Frith-Macdonald - - * Source/GSSocketStream.m: Fix for #24564 - * Source/inet_pton.c: Fix for #24563 - * Source/inet_ntop.c: Fix for #24563 - -2008-10-12 Larry Campbelln - - * Source/NSDate.m: Add keyed archiving support. - -2008-10-11 Eric Wasylishen - - * Source/NSBundle.m: fix bug #24320 - -2008-10-10 Richard Frith-Macdonald - - * Source/NSTimeZones/NSTimeZones.tar: updated. - -2008-10-03 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: Ensure that we always return NO when we - need mo more data to complete parsing. - * Source/GSHTTPURLHandle.mL: Fix check for response parse completion. - -2008-10-01 Adam Fedor - - * Source/DocMakefile: Add NSAffineTranform - -2008-09-29 22:54-EDT Gregory John Casamento - - * Source/synchronization.m: Remove uneeded objc_sync_remove_node - function. - -2008-09-26 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Fix compilation problem on systems - without iconv. - -2008-09-25 00:18-EDT Gregory John Casamento - - * Source/synchronization.m: Correct issue in objc_sync_remove_node() - method where it could do a NULL dereference. Also moved the locks on - the tables to the highest level so to reduce the possibility of - threading issues. - -2008-09-24 17:26-EDT Gregory John Casamento - - * Source/NSUserDefaults.m: Corrected previous change. - -2008-09-24 08:25-EDT Gregory John Casamento - - * Source/NSUserDefaults.m: -addSuiteNamed change so that we don't - rely on the value of NSNotFound being -(2^32)-1 and a rollover to - 0. - -2008-09-23 20:31-EDT Gregory John Casamento - - * config.mak.in: Added reference to HAVE_OBJC_SYNC_ENTER - * configure: Recompiled script - * configure.ac: Changed configure to check for objc_sync_enter - function. - * Headers/Additions/GNUstepBase/config.h.in: Added #define here for - HAVE_OBJC_SYNC_ENTER - * Source/GNUmakefile: Added check for the value, if no, then compile - synchronization.m - * Source/synchronization.m: Implementation for @synchronize support. - -2008-09-23 Richard Frith-Macdonald - - * Source/NSThread.m: add a couple of checks to ensure correct - initialisation of class. - * Source/NSDate.m: - * Source/NSCalendarDate.m: Check for time interval since reference - date being NaN, and raise an exception. - -2008-09-21 00:05-EDT Gregory John Casamento - - * COPYINGv3: Adding back in. - -2008-09-19 Richard Frith-Macdonald - - * Source/NSDistributedLock.m: Standardise the path we are given for - the lock file. - -2008-09-18 Richard Frith-Macdonald - - * Source/NSThread.m: try to make firing of thread performers - more robust. - * Source/Additions/GSMime.m: make some NSLog() calls be debug only. - -2008-09-14 13:20-EDT Gregory John Casamento - - * install.sh: Install script for use by compile-all. - -2008-08-25 18:55-EDT Gregory John Casamento - - * COPYINGv3: Remove since GNUstep is now GPLv2 again. - * Headers/Foundation/NSNumberFormatter.h - * Source/NSNumberFormatter.m: Added methods missing from GNUstep - that are present in 10.4 (stringFromNumber:, numberFromString:) - -2008-08-25 Fred Kiefer - - * Source/NSAutoreleasePool.m (-drain): Implement. - * Source/NSAutoreleasePool.m (-dealloc): Reset _parent and _child. - * Source/NSAutoreleasePool.m (-_endThread:): Free cache of ended - thread not of current. - -2008-08-20 Yavor Doganov (tiny change) - - * config/procfs.m4: Check for `proc' in /proc/mounts rather than - relying on the output of `mount'; fixes build issue in - chroots. Reported by Funda Wang (bug #23876). - -2008-07-17 Richard Frith-Macdonald - - * Source/Additions/GSCategories.m: littleEndian() fix to work on - systems with other word sizes. - -2008-07-15 Richard Frith-Macdonald - - * Source/GSPrivate.h: New private function to get range of string func. - * Source/NSString.m: Optimise replacing string in string. - * Source/GSString.m: New function to return range getting function. - * Source/GSeq.h: Fixup comment - * Testing/string.m: Add trival check. - Optimise ([replaceOccurrencesOfString:withString:options:range:]) - -2008-07-11 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Add support for byte order specific - unicode (including 32bit) via iconv. Change encoding lookup - mechanism to cope with new Mac-OS-X encoding values. - -2008-07-06 Richard Frith-Macdonald - - * Source/NSRunLoop.m: - * Source/NSArray.m: - * Source/NSSortDescriptor.m: - * Source/Additions/GSCompatibility.m: - * Source/NSDictionary.m: - * Source/NSSerializer.m: - * Source/NSSet.m: - Wherever ([-getObjects:]) is called, check to see if the receiver is - a proxy, and if so we populate the buffer by calling ([-objectAtIndex:]) - instead. This because a proxy via DO does not know how many itesm are - in the buffer and assumes it's only one. - -2008-07-06 Richard Frith-Macdonald - - * configure.ac: use libffi in preference to ffcall as it doesn't mess - up the stack. - * configure: regenerate - -2008-07-02 Richard Frith-Macdonald - - * Source/NSIndexSet.m: Implement ([-countOfIndexesInRange:]) - -2008-06-30 Richard Frith-Macdonald - - * Source/GSFFIInvocation.m: - * Source/NSInvocation.m: - * Source/cifframe.h: - * Source/cifframe.m: - Tweaks to get NS_MESSAGE and NS_INVOCATION working on my 64bit - system. - -2008-06-28 Richard Frith-Macdonald - - * configure.ac: Check for sys/mman.h and mprotect - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * Source/GSFFIInvocation.m: Use mmap and mprotect to ensure that - closure memory is executable. - -2008-06-27 17:22-EDT Gregory John Casamento - - * Source/NSUnarchiver.m: Issue a warning when the class can't be - resolved by the runtime in decodeValueOfObjCType:at:. - -2008-06-27 Richard Frith-Macdonald - - * Source/NSPropertyList.m: sort dictionary keys only if they are - strings. This is the new MacOS-X behavior (old behavior was to sort - if all responded to compare:). - Fixes bug #23727 - -2008-06-21 Richard Frith-Macdonald - - * Headers/Foundation/NSException.h - * Source/NSException.h - Change macros for setting uncaught handler to be functions (to match - MacOS-X) and make the pointer itsself be private. - -2008-06-18 Richard Frith-Macdonald - - * Source/NSConnection.m: Fix error getting run loop for current - thread when it has not already been set. - -2008-06-16 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSUnion.h: add NSUInteger type as addr - * Headers/Additions/GNUstepBase/GSIMap.h: use addr for - GSIMapNodeForSimpleKey() so that it works for pointers on machines - where sizeof(int) != sizeof(void*) - -2008-06-15 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: Be more tolerant of illegal data in - quoted printable words. - -2008-06-13 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: Fix incorrect adjustment of buffer - when handling large string containing multibyte utf-8 data. - -2008-06-12 Richard Frith-Macdonald - - * Update timezones, bump version to 1.17.0 for next release. - -2008-06-12 Richard Frith-Macdonald - - * Documentation/ReleaseNotes.gsdoc: Add information about movement - to MacOS-X compatibility. - -2008-06-11 David Ayers - - * Source/NSNumberFormatter.m ([-stringForObjectValue:]): Implement - handling of localizesFormat. - Return string value of attributedStringForZero if applicable so that - formatting for the common case is not short circuted for zero. - -2008-06-10 Richard Frith-Macdonald - - * Tools/AGSHtml.m: if something is scheduled for removal, mark it as - 'Likely to be changed/moved/removed' rather than 'deprecated'. - -2008-06-10 Richard Frith-Macdonald - - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSBundle.h: - * Headers/Foundation/NSSerialization.h: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSMethodSignature.h: - * Headers/Foundation/NSHost.h: - * Headers/Foundation/NSArchiver.h: - * Headers/Foundation/NSInvocation.h: - Fix typo in macro name - -2008-06-10 Richard Frith-Macdonald - - * configure.ac: Check for stdlib.h - * Headers/Additions/GNUstepBase/config.h.in: add stdlib.h - * configure: Regenerate - * Source/NSString.m: Don't use realpath unless PATH_MAX is known - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSBundle.h: - * Headers/Foundation/NSSerialization.h: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSMethodSignature.h: - * Headers/Foundation/NSHost.h: - * Headers/Foundation/NSArchiver.h: - * Headers/Foundation/NSInvocation.h: - Mark non-OSX methods as deprecated so we can move them to the - additions library or delete them if we want to. - -2008-06-08 Richard Frith-Macdonald - - * COPYINGv3: - * NSCharacterSets/GNUmakefile: - * Source/NSIndexPath.m: - * Source/NSSocketPortNameServer.m: - * Source/NSMapTable.m: - * Source/GSLocale.m: - * Source/GSSocketStream.h: - * Source/NSTimeZone.m: - * Source/NSNetServices.m: - * Source/hpux-load.h: - * Source/NSHashTable.m: - * Source/GSInvocation.h: - * Source/NSURLCredential.m: - * Source/GSSocketStream.m: - * Source/NSValueTransformer.m: - * Source/NSPortCoder.m: - * Source/NSURLAuthenticationChallenge.m: - * Source/Makefile.postamble: - * Source/NSSpellServer.m: - * Source/NSCalendarDate.m: - * Source/NSBundle.m: - * Source/NSKeyValueCoding.m: - * Source/NSURLHandle.m: - * Source/NSTimer.m: - * Source/NSPropertyList.m: - * Source/libgnustep-base-entry.m: - * Source/GSConcreteValueTemplate.m: - * Source/NSAffineTransform.m: - * Source/CompatibilityHeaders.make: - * Source/NSPathUtilities.m: - * Source/NSScanner.m: - * Source/NSDistributedNotificationCenter.m: - * Source/NSProcessInfo.m: - * Source/NSGeometry.m: - * Source/NSNotificationQueue.m: - * Source/GNUmakefile: - * Source/thr-mach.h: - * Source/NSSocketPort.m: - * Source/NSRunLoop.m: - * Source/NSAttributedString.m: - * Source/NSUndoManager.m: - * Source/NSMethodSignature.m: - * Source/thr-mach.m: - * Source/NSFormatter.m: - * Source/NSUserDefaults.m: - * Source/GSArray.m: - * Source/GSFFCallInvocation.m: - * Source/mframe/configure.ac: - * Source/mframe/mframe.head: - * Source/mframe/README: - * Source/NSKeyValueMutableSet.m: - * Source/NSArray.m: - * Source/GSStream.h: - * Source/NSMessagePortNameServer.m: - * Source/objc-gnu2next.m: - * Source/GSStream.m: - * Source/NSKeyedArchiver.m: - * Source/NSDebug.m: - * Source/unix/Makefile.preamble: - * Source/unix/GNUmakefile: - * Source/unix/NSStream.m: - * Source/NSKeyedUnarchiver.m: - * Source/GSConcreteValue.m: - * Source/NSPortMessage.m: - * Source/NSURLDownload.m: - * Source/NSDistributedLock.m: - * Source/NSFileHandle.m: - * Source/NSPredicate.m: - * Source/simple-load.h: - * Source/preface.m: - * Source/NSKeyValueObserving.m: - * Source/NSAssertionHandler.m: - * Source/GSHTTPURLHandle.m: - * Source/NSConcreteNumberTemplate.m: - * Source/win32-load.h: - * Source/NSCallBacks.h: - * Source/NSZone.m: - * Source/NSPage.m: - * Source/NSCallBacks.m: - * Source/NSURLCredentialStorage.m: - * Source/NSPort.m: - * Source/NSSortDescriptor.m: - * Source/GSFFIInvocation.m: - * Source/NSMessagePort.m: - * Source/GSPrivate.h: - * Source/GSDictionary.m: - * Source/win32/GSFileHandle.m: - * Source/win32/Makefile.preamble: - * Source/win32/NSMessagePort.m: - * Source/win32/GNUmakefile: - * Source/win32/NSStream.m: - * Source/win32/NSMessagePortNameServer.m: - * Source/NSUnarchiver.m: - * Source/GSCountedSet.m: - * Source/NSConcreteNumber.h: - * Source/NSInvocation.m: - * Source/dld-load.h: - * Source/NSFileManager.m: - * Source/NSConcreteNumber.m: - * Source/NSURLResponse.m: - * Source/thr-pthread.m: - * Source/objc-load.h: - * Source/NSURLProtocol.m: - * Source/NSURLCache.m: - * Source/externs.m: - * Source/NSNotificationCenter.m: - * Source/GSAttributedString.m: - * Source/objc-load.m: - * Source/NSRange.m: - * Source/NSCoder.m: - * Source/NSHTTPCookieStorage.m: - * Source/NSException.m: - * Source/NSKeyValueMutableArray.m: - * Source/NSCopyObject.m: - * Source/NSURL.m: - * Source/cifframe.h: - * Source/NSString.m: - * Source/NSObject.m: - * Source/mframe.m: - * Source/DocMakefile: - * Source/NSDecimalNumber.m: - * Source/NSCachedURLResponse.m: - * Source/cifframe.m: - * Source/null-load.h: - * Source/Additions/Unicode.m: - * Source/Additions/GCArray.m: - * Source/Additions/GSXML.m: - * Source/Additions/GNUmakefile: - * Source/Additions/behavior.m: - * Source/Additions/GSFunctions.m: - * Source/Additions/GSCompatibility.m: - * Source/Additions/Makefile.preamble: - * Source/Additions/GSObjCRuntime.m: - * Source/Additions/GSNextRuntime.m: - * Source/Additions/GCDictionary.m: - * Source/Additions/GSCategories.m: - * Source/Additions/GCObject.m: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/Additions/GSMime.m: - * Source/Additions/GSLock.m: - * Source/GSSet.m: - * Source/NSNotification.m: - * Source/NSNumber.m: - * Source/NSDecimal.m: - * Source/GSString.m: - * Source/NSConnection.m: - * Source/NSDateFormatter.m: - * Source/GSPortPrivate.h: - * Source/NSAutoreleasePool.m: - * Source/NSThread.m: - * Source/NSData.m: - * Source/NSHTTPCookie.m: - * Source/NSDate.m: - * Source/NSHost.m: - * Source/GSNetwork.h: - * Source/callframe.h: - * Source/NSProxy.m: - * Source/NSObjCRuntime.m: - * Source/NSURLProtectionSpace.m: - * Source/callframe.m: - * Source/NSProtocolChecker.m: - * Source/NSError.m: - * Source/GSeq.h: - * Source/NSPipe.m: - * Source/GSValue.m: - * Source/NSDictionary.m: - * Source/Makefile.preamble: - * Source/GSHTTPAuthentication.m: - * Source/NSClassDescription.m: - * Source/NSSerializer.m: - * Source/NSNull.m: - * Source/NSURLRequest.m: - * Source/NSValue.m: - * Source/NSCountedSet.m: - * Source/NSLog.m: - * Source/GSFormat.m: - * Source/NSIndexSet.m: - * Source/GSFileHandle.m: - * Source/NSLock.m: - * Source/NSSet.m: - * Source/NSDistantObject.m: - * Source/NSTask.m: - * Source/NSArchiver.m: - * Source/win32-def.top: - * Source/NSCharacterSet.m: - * Source/NSPortNameServer.m: - * Source/NSNumberFormatter.m: - * Source/NSXMLParser.m: - * Source/GSFTPURLHandle.m: - * Source/NSEnumerator.m: - * Source/GSURLPrivate.h: - * Source/NSURLConnection.m: - * SSL/GSSSLHandle.m: - * SSL/Makefile.postamble: - * SSL/Makefile.preamble: - * SSL/configure.ac: - * SSL/GNUmakefile: - * SSL/COPYING.LIB: - * Makefile.postamble: - * configure.ac: - * COPYING: - * Headers/Foundation/NSTimeZone.h: - * Headers/Foundation/NSNetServices.h: - * Headers/Foundation/NSHashTable.h: - * Headers/Foundation/NSRange.h: - * Headers/Foundation/NSCoder.h: - * Headers/Foundation/NSURLCredential.h: - * Headers/Foundation/NSHTTPCookieStorage.h: - * Headers/Foundation/NSException.h: - * Headers/Foundation/NSByteOrder.h: - * Headers/Foundation/NSValueTransformer.h: - * Headers/Foundation/NSPortCoder.h: - * Headers/Foundation/NSURL.h: - * Headers/Foundation/NSCompoundPredicate.h: - * Headers/Foundation/NSURLAuthenticationChallenge.h: - * Headers/Foundation/NSObject.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSSpellServer.h: - * Headers/Foundation/NSCalendarDate.h: - * Headers/Foundation/NSDecimalNumber.h: - * Headers/Foundation/NSBundle.h: - * Headers/Foundation/NSKeyValueCoding.h: - * Headers/Foundation/NSPointerFunctions.h: - * Headers/Foundation/NSSerialization.h: - * Headers/Foundation/NSURLHandle.h: - * Headers/Foundation/NSPropertyList.h: - * Headers/Foundation/NSTimer.h: - * Headers/Foundation/NSAffineTransform.h: - * Headers/Foundation/NSNotification.h: - * Headers/Foundation/NSPathUtilities.h: - * Headers/Foundation/NSScanner.h: - * Headers/Foundation/NSDistributedNotificationCenter.h: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSNotificationQueue.h: - * Headers/Foundation/NSComparisonPredicate.h: - * Headers/Foundation/NSStream.h: - * Headers/Foundation/NSGeometry.h: - * Headers/Foundation/NSDecimal.h: - * Headers/Foundation/NSRunLoop.h: - * Headers/Foundation/NSAttributedString.h: - * Headers/Foundation/NSConnection.h: - * Headers/Foundation/NSUndoManager.h: - * Headers/Foundation/NSDateFormatter.h: - * Headers/Foundation/NSMethodSignature.h: - * Headers/Foundation/NSAutoreleasePool.h: - * Headers/Foundation/NSFormatter.h: - * Headers/Foundation/NSUserDefaults.h: - * Headers/Foundation/NSThread.h: - * Headers/Foundation/NSHTTPCookie.h: - * Headers/Foundation/NSData.h: - * Headers/Foundation/NSURLError.h: - * Headers/Foundation/NSDate.h: - * Headers/Foundation/NSHost.h: - * Headers/Foundation/NSArray.h: - * Headers/Foundation/NSProxy.h: - * Headers/Foundation/NSObjCRuntime.h: - * Headers/Foundation/NSURLProtectionSpace.h: - * Headers/Foundation/NSKeyedArchiver.h: - * Headers/Foundation/NSProtocolChecker.h: - * Headers/Foundation/NSDebug.h: - * Headers/Foundation/NSPortMessage.h: - * Headers/Foundation/NSError.h: - * Headers/Foundation/NSURLDownload.h: - * Headers/Foundation/NSFileHandle.h: - * Headers/Foundation/NSDistributedLock.h: - * Headers/Foundation/NSPredicate.h: - * Headers/Foundation/FoundationErrors.h: - * Headers/Foundation/NSKeyValueObserving.h: - * Headers/Foundation/NSDictionary.h: - * Headers/Foundation/NSErrorRecoveryAttempting.h: - * Headers/Foundation/NSClassDescription.h: - * Headers/Foundation/NSNull.h: - * Headers/Foundation/NSZone.h: - * Headers/Foundation/NSURLRequest.h: - * Headers/Foundation/NSValue.h: - * Headers/Foundation/NSURLCredentialStorage.h: - * Headers/Foundation/NSIndexSet.h: - * Headers/Foundation/NSPort.h: - * Headers/Foundation/NSSortDescriptor.h: - * Headers/Foundation/NSLock.h: - * Headers/Foundation/NSSet.h: - * Headers/Foundation/NSDistantObject.h: - * Headers/Foundation/NSExpression.h: - * Headers/Foundation/NSTask.h: - * Headers/Foundation/NSArchiver.h: - * Headers/Foundation/Foundation.h: - * Headers/Foundation/NSCharacterSet.h: - * Headers/Foundation/NSInvocation.h: - * Headers/Foundation/NSFileManager.h: - * Headers/Foundation/NSUtilities.h: - * Headers/Foundation/NSPortNameServer.h: - * Headers/Foundation/NSNumberFormatter.h: - * Headers/Foundation/NSXMLParser.h: - * Headers/Foundation/NSEnumerator.h: - * Headers/Foundation/NSURLResponse.h: - * Headers/Foundation/NSURLConnection.h: - * Headers/Foundation/NSIndexPath.h: - * Headers/Foundation/NSURLProtocol.h: - * Headers/Foundation/NSMapTable.h: - * Headers/Foundation/NSURLCache.h: - * Headers/Additions/GNUstepBase/GSLocale.h: - * Headers/Additions/GNUstepBase/GSXML.h: - * Headers/Additions/GNUstepBase/DistributedObjects.h: - * Headers/Additions/GNUstepBase/behavior.h: - * Headers/Additions/GNUstepBase/GSFunctions.h: - * Headers/Additions/GNUstepBase/GSConfig.h.in: - * Headers/Additions/GNUstepBase/preface.h.in: - * Headers/Additions/GNUstepBase/GSObjCRuntime.h: - * Headers/Additions/GNUstepBase/GSCategories.h: - * Headers/Additions/GNUstepBase/GSIMap.h: - * Headers/Additions/GNUstepBase/GCObject.h: - * Headers/Additions/GNUstepBase/GSMime.h: - * Headers/Additions/GNUstepBase/GSIArray.h: - * Headers/Additions/GNUstepBase/GSUnion.h: - * Headers/Additions/GNUstepBase/GSLock.h: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - * Headers/Additions/GNUstepBase/GSFileHandle.h: - * Headers/Additions/GNUstepBase/GNUstep.h: - * Headers/Additions/GNUstepBase/objc-gnu2next.h: - * Headers/Additions/GNUstepBase/Unicode.h: - * Makefile: - * GNUmakefile: - * macosx/config.h: - * base.make.in: - * Tools/gspath.m: - * Tools/AGSHtml.h: - * Tools/plmerge.m: - * Tools/xmlparse.m: - * Tools/AGSIndex.h: - * Tools/AGSHtml.m: - * Tools/AGSIndex.m: - * Tools/sfparse.m: - * Tools/gdnc.h: - * Tools/plparse.m: - * Tools/pldes.m: - * Tools/defaults.m: - * Tools/Makefile.postamble: - * Tools/locale_alias.m: - * Tools/Makefile.preamble: - * Tools/DocMakefile: - * Tools/gsdoc-1_0_0.dtd: - * Tools/plget.m: - * Tools/pl2link.m: - * Tools/gdnc.m: - * Tools/gsdoc-1_0_1.dtd: - * Tools/gsdoc-1_0_2.dtd: - * Tools/gsdoc-1_0_3.dtd: - * Tools/AGSParser.h: - * Tools/gsdoc-1_0_1.rnc: - * Tools/gsdoc-0_6_5.dtd: - * Tools/gsdoc-0_6_6.dtd: - * Tools/plser.m: - * Tools/gsdoc-0_6_7.dtd: - * Tools/AGSOutput.h: - * Tools/AGSParser.m: - * Tools/autogsdoc.m: - * Tools/make_strings/StringsFile.h: - * Tools/make_strings/StringsEntry.h: - * Tools/make_strings/make_strings.m: - * Tools/make_strings/StringsFile.m: - * Tools/make_strings/StringsEntry.m: - * Tools/make_strings/GNUmakefile: - * Tools/make_strings/SourceEntry.h: - * Tools/make_strings/make_strings.h: - * Tools/make_strings/GNUmakefile.preamble: - * Tools/make_strings/SourceEntry.m: - * Tools/AGSOutput.m: - * Tools/GNUmakefile: - * Tools/gdomap.c: - * Tools/plist-0_9.dtd: - * Tools/gdomap.h: - * Tools/HTMLLinker.m: - * Tools/pl.m: - * Tools/cvtenc.m: - * config/config.constant-string-class.m: - * Testing/Makefile.postamble: - * Testing/exported-strings.m: - * Testing/gslock.m: - * Testing/GNUmakefile: - * Testing/nsattributedstring.m: - * Testing/nsmethodsignature.m: - * Testing/diningPhilosophers.m: - * Testing/gsbehavior.m: - * Testing/Makefile.preamble: - * Testing/benchmark.m: - * COPYING.LIB: - Temporarily revert library and essential tools to LGPLv2 so that - developers have longer to get used to LGPLv3. - Keep non-essential tools and examples at GPLv3 - -2008-06-07 Richard Frith-Macdonald - - * Source/NSUserDefaults.m: - Fix possible deadlock reported by Larry Campbell, and improve - optimisation a little. - -2008-06-06 Richard Frith-Macdonald - - * Source/NSTimeZone.m: Monitor to see if the time zone specified in - the user defaults system changes. If so, we update the system zone. - -2008-06-06 Richard Frith-Macdonald - - * Source/GSLocale.m: - * Source/NSTimeZone.m: - * Source/NSNetServices.m: - * Source/NSSpellServer.m: - * Source/NSBundle.m: - * Source/NSPathUtilities.m: - * Source/NSScanner.m: - * Source/NSProcessInfo.m: - * Source/NSArray.m: - * Source/externs.m: - * Source/NSCoder.m: - * Source/NSString.m: - * Source/NSConnection.m: - * Source/NSAutoreleasePool.m: - * Source/NSData.m: - * Source/NSObjCRuntime.m: - * Source/NSIndexSet.m: - * Source/NSLock.m: - * Source/NSSet.m: - * Documentation/ReleaseNotes.gsdoc: - * Headers/Foundation/NSTimeZone.h: - * Headers/Foundation/NSNetServices.h: - * Headers/Foundation/NSCoder.h: - * Headers/Foundation/NSString.h: - * Headers/Foundation/NSSpellServer.h: - * Headers/Foundation/NSBundle.h: - * Headers/Foundation/NSPathUtilities.h: - * Headers/Foundation/NSScanner.h: - * Headers/Foundation/NSProcessInfo.h: - * Headers/Foundation/NSComparisonPredicate.h: - * Headers/Foundation/NSConnection.h: - * Headers/Foundation/NSAutoreleasePool.h: - * Headers/Foundation/NSUserDefaults.h: - * Headers/Foundation/NSData.h: - * Headers/Foundation/NSArray.h: - * Headers/Foundation/NSObjCRuntime.h: - * Headers/Foundation/NSIndexSet.h: - * Headers/Foundation/NSLock.h: - * Headers/Foundation/NSSet.h: - Lots of small OSX10.5 compatibility updates:- - Some new enumerations and constant strings. - Some new method implementations. - Some new empty method stubs. - Change NSLocale constant string to GSLocale in preparation for adding - the new NSLocal class. - -2008-05-25 Richard Frith-Macdonald - - * configure.ac: For now, only use ffi for sparc64 on solaris as - it doesn't appear to work on bsd. - -2008-05-24 Nicola Pero - - * Tools/Makefile.postamble: Use GNUSTEP_DOC_MAN instead of - GNUSTEP_DOCUMENTATION_MAN. This requires gnustep-make version 2, - but that was already a requirement. (Suggestion by Chris Vetter - ). - -2008-05-23 Richard Frith-Macdonald - - * configure.ac: Check for systems which need -lnsl (solaris) - Reintroduce use of ffi by default on sparc64 as I just couldn't - get ffcall to work at all and the latest ffi seems to work atr - least for all the common cases. - * Tools/gdnc.m: Fix incorrectly sized instance variable. - -2008-05-22 Richard Frith-Macdonald - - * SSL/GSSSLHandle.m: Attempt to improve error logging. - -2008-05-21 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Fix reference to uninitialised variable. - -2008-05-14 Richard Frith-Macdonald - - * Source/GSArray.m: Fix bug allowing nil to be placed in array. - -2008-05-01 Richard Frith-Macdonald - - * configure.ac: try to use libffi on sparc64 as libffcall does not - work. Warn if user tries to enable libffcall. - -2008-04-25 Richard Frith-Macdonald - - * Source/NSPropertyList.m: - Use more memory efficient bitmaps for old style property list parsing - where we know we are only using 8bit characters. - -2008-03-20 David Chisnall - - * Source/win32/GSRunLoopCtxt.m: Fix bad function call (bug #22676) - -2008-03-19 Richard Frith-Macdonald - - * Source/NSAutoreleasePool.m: Use get_imp() to fetch the - implementation of the release method. - -2008-03-19 Richard Frith-Macdonald - - * Source/DocMakefile: include GNUstep.h - * Headers/Foundation/NSObject.h: include GNUstep.h for macros - * Headers/Foundation/NSBundle.h: move gnustep specific macros out - * Headers/Additions/GNUstepBase/GSFunctions.h: undeprecate and add - GSLocalizedStringFromTableInFramework from NSBundle.h - * Headers/Additions/GNUstepBase/GNUstep.h: Add comments etc. - Code changes to avoid duplication of macro definitions, make - GNUstep.h usable anywhere, and rename a couple of GNUstep specific - extensions to use the GS prefix rather than the (reserved by Apple) - NS prefix. - -2008-03-18 Riccardo Mottola - - * Source/GNUMakefile: Added FoundationErrors.h - -2008-03-18 Richard Frith-Macdonald - - * Source/NSString.m: Add a couple of new MacOS-X methods. - * Headers/Foundation/NSString.h: ditto - * Headers/Foundation/FoundationErrors.h: New list of error codes - * Headers/Foundation/Foundation.h: include error codes - More MacOS-X compatibility tweaks - -2008-03-17 Richard Frith-Macdonald - - * Headers/Foundation/NSThread.h: - * Source/NSThread.m: Add ([+isMainThread]) and ([-isFinished]). - Also check that we are not trying to perform a selector on an invalid - thread finished. - -2008-03-17 Richard Frith-Macdonald - - * Source/NSRunLoop.m: - * Source/unix/GSRunLoopCtxt.m: - * Source/GSRunLoopCtxt.h: - * Source/GSPrivate.h: - * Source/win32/GSRunLoopCtxt.m: - * Source/NSConnection.m: - * Source/NSThread.m: - * Headers/Foundation/NSThread.h: - Got round to committing the thread changes held back for last release. - Beware ... this code is not properly tested yet. The idea is that it - should provide the new (in MacOS-X 10.5) methods to support performing - of selectors in other threads. - -2008-03-17 Richard Frith-Macdonald - - * Source/NSPort.m: - * Source/NSException.m: - * Source/NSConnection.m: - * Headers/Foundation/NSException.h: - * Headers/Foundation/NSPort.h: - Update exceptions to match those in MacOS-X for compatibility. - -2008-03-16 Matt Rice - - * Source/NSException.m: Add NSObjectNotAvailableException. - * Headers/Foundation/NSException.h: Ditto. - -2008-03-16 Richard Frith-Macdonald - - * Source/NSDebug.m: Trap sigbus if gcc functions to get stack frame - info run off the end of the stack. - * Source/NSString.m: Implement ([-decimalValue]) ... undocumented - feature of MacOS-X foundation. - -2008-03-16 Richard Frith-Macdonald - - * Source/NSArray.m: - * Source/NSSet.m: - Add ([-valueForKeyPath:]) to implement KVC aggregate operators. - * Source/NSKeyValueCoding.m: When accessing instance variable directly - look for _var before var as in MacOS-X - -2008-03-14 Nicola Pero - - * Source/NSDictionary.m ([-initWithObjectsAndKeys:], - [+dictionaryWithObjectsAndKeys:]): Improved documentation: tell - people to terminate the list with nil. - -2008-03-13 Richard Frith-Macdonald - - * Source/NSAutoreleasePool.m; use ([+instanceMethodForSelector:]) - to cache release method implementation for a class. - -2008-03-13 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: - Make all keypath methods perform recursive evaluation of the path - for compatibility with MacOS-X and to permit classes to effectively - override the keypath methods. - -2008-03-12 Richard Frith-Macdonald - - * Source/Additions/GSInsensitiveDictionary.m: - Include GSCategories.h for NSWarnMLog - -2008-03-12 Richard Frith-Macdonald - - * Source/Additions/GSInsensitiveDictionary.m: - Don't do gnustep specific debug if building apple-apple-apple - -2008-03-11 Adam Fedor - - * Version 1.15.3 - -2008-03-05 Richard Frith-Macdonald - - * Source/NSPage.m: Removed obsolete includes (see bug #22479) - -2008-03-05 Matt Rice - - * Source/NSKeyValueCoding.m ([-setValue:forKey:]): Pass value - to takeValue:forKey:. - -2008-03-05 Richard Frith-Macdonald - - * Source/NSBundle.m Make better guess at what the caller meant when - they give us a non-absolute path name on mingw. - -2008-03-03 Richard Frith-Macdonald - - * Source/NSNull.m: Make result of description method match MacOSX - * Headers/Foundation/NSKeyValueObserving.h: Add new MacOSX features. - * Source/NSKeyValueObserving.m: Rewrite code for handling observations - and notifications. Fix various bugs and add new options from - version 10.5 of MacOS-X - -2008-03-02 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: Avoid calling deprecated methods as a - result of KVO overriding them. - * Source/NSKeyValueObserving.m: Minor tidyups - -2008-02-25 Richard Frith-Macdonald - - * Headers/Foundation/NSObject.h: Moved some headers to NSObjCRuntime.h - * Headers/Foundation/NSObjCRuntime.h: Added NSInteger and NSUInteger - for MacOSX compatibiulity. - * Headers/Additions/GNUstep/GSVersionMacros.h: Don't declare constants - which should be set by the user to say which MacOSX version they want. - * Headers/Foundation/NSPointerFunctions.h: New MacOSX declarations ... - no definitions yet. - -2008-02-23 Richard Frith-Macdonald - - * Source/NSKeyValueObserving.m: - Don't calculate KVO info in cases where there is no observer. - -2008-02-22 Richard Frith-Macdonald - - * Source/mframe/mframe.head: Change function arguments - * Source/mframe.m: Support nul termination of type strings - * Source/NSMethodSignature.m: nul terminate type strings - * Source/NSObjCRuntime.m: update for changed function args - -2008-02-21 Richard Frith-Macdonald - - * Headers/Foundation/NSKeyValueCoding.h: - * Headers/Foundation/NSThread.h: - * Headers/Foundation/NSKeyValueObserving.h: - * Headers/Additions/GNUstepBase/GSXML.h: - Documentation fixes. - -2008-02-20 Richard Frith-Macdonald - - * Source/Additiuons/GSObjCRuntime.m: Add support for NSPoint, NSRange, - NSSize and NSRect for bug #22277 - -2008-02-20 Richard Frith-Macdonald - - * configure.ac: Add convoluted checks to cope with interdependency - os some system headers on FreeBSD. - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: Regenerate - * Source/NSFileManager.m: Include sys/cdefs.h when available - (for FreeBSD). - -2008-02-20 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: - * Headers/Additions/GNUstepBase/GSVersionMacros.h: - Minor tweaks for building under leopard. - * Source/NSPathUtilities.m: minor thread safety fix. - * Source/NSSocketPort.m: remove bogus comment - * Source/NSMessagePort.m: remove bogus comment - * Source/Additions/Unicode.m: add lockign for nl_langinfo - * Source/Additions/GSMime.m: New method to parse headers - * Headers/Additions/GNUstepBase/GSMime.h: ditto - * Source/NSString.m: Change ([-boolValue]) to match new MacOS-X method. - * Source/GSString.m: ditto - -2008-02-19 Nicola Pero - - * Source/GNUmakefile (libgnustep-base_NEEDS_GUI): Set to NO - (libgnustep-baseadd_NEEDS_GUI): Set to NO. - * SSL/GNUmakefile (SSL_NEEDS_GUI): Set to NO. - -2008-02-17 Richard Frith-Macdonald - - * Source/NSDistributedNotificationCenter.m: Remove delay and change - code to immediately release resources used while trying to connect - to server. - * Source/NSConnection.m: When creating a connection and getting its - proxy, release the connection immediately if the proxy is nil, so - that repeated calls don't use more resources. - * Source/NSMessagePortNameServer.m: Implement distributed locking - of names directory. - * Source/NSNSAutoreleasePool.m: When emptying pool, add diagnostic - message and exceptions where an object we are releasing is bad in - some way. - * Headers/Foundation/NSPropertyList.h: Clarify/fix documentation of - date format. - -2008-02-17 19:21-EST Gregory John Casamento - - * Source/NSDistributedNotificationCenter.m: Added a short wait to the - _connect method when starting GDNC to correct bug#22351. - Worked with Riccardo Motolla to test this (riccardo@kaffe.org). - -2008-02-16 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: Fix errors in code for folding header - lines. - -2008-02-14 Richard Frith-Macdonald - - * Source/GSHTTPURLHandle.m: Remove self as observer of socket - while ssl connection is in progress. - -2008-02-13 Richard Frith-Macdonald - - * Source/NSArray.m: Minor optimisation ...use a subarray when - returning all objects from an array enumerator. - -2008-02-07 Richard Frith-Macdonald - - * Source/NSXMLParser.m: Fix retain/release error. - -2008-02-06 Richard Frith-Macdonald - - * Source/NSXMLParser.m: Fix bug in sloppy parser, failing - to skip space at end of tag and therefore missing the trailing - '/' in a collapsed element. - -2008-01-28 Adam Fedor - - * configure.ac: Add option to disable bfd. - * Source/inet_pton.c, Source/inet_ntop.c: Add includes to - compile on Solaris - -2008-01-27 Richard Frith-Macdonald - - * Source/NSXMLParser.m: Implement reporting of namespace - prefixes with libxml2 based parser and with sloppy parser. - -2008-01-26 Richard Frith-Macdonald - - * Source/Additions/NSXML.m: Fixup SAX interface to pass namespace - information separately (retain old method for binary backward - compatibility). - * Source/NSXMLParser.m: Implement handing of namespaces with libxml2 - based parser. - -2008-01-25 Richard Frith-Macdonald - - * Source/Additions/NSXML.m: In SAX count namespace declarations - in element start as attributes. - -2008-01-23 Richard Frith-Macdonald - - * Source/NSHost.m: Fix minor thread safety issue ... could get - release host if another thread clears cache at same time as lookup. - -2008-01-21 Fred Kiefer - - * Resources/Languages/Spanish: Quoting corrections by Matias - Adrian . - -2008-01-18 Richard Frith-Macdonald - - * Tools/autogsdoc.m: Fix bug recording sources and outputs in - index and dependencies. - * Source/NSTimeZone.m: Fix coding style errors and buffer overrun - on mswindows reported by Roland Schwingel. - -2008-01-14 Nicola Pero - - * configure.ac: Do not read obsolete GNUSTEP_USER_DIR and do not - substitute GNUSTEP_TARGET_USER_DIR. - * configure: Regenerated. - * Headers/Additions/GNUstepBase/config.h.in: Regenerated. - * Source/NSPathUtilities.m: Do not read obsolete GNUSTEP_USER_DIR - from the configuration. Ignore it if found. It is never used - anywhere. - * Documentation/Base.gsdoc: Removed or slightly updated some - obsolete documentation on filesystem configuration. - -2008-01-10 Richard Frith-Macdonald - - * Source/inet_pton.c: - * Source/inet_ntop.c: - * Source/GSNetwork.h: - * Source/GNUmakefile: - * configure.ac: - * configure: - Avoid using mswindows getnameinfo function as it doesn't work for - Riccardo for some reason ... perhaps older mingw32 doesn't have it. - -2008-01-10 Richard Frith-Macdonald - - * Source/NSPathUtilities.m: Allow '../' to indicate a relocatable - resource. Add support for GlobalDefaults.plist. - * Source/NSUserDefaults.m: Improve documentation - * Documentation/ReleaseNotes.gsdoc: Note recent changes. - * Documentation/Base.gsdoc: Improve documentation - * Headers/Foundation/NSUserDefaults.h: Improve comments. - -2008-01-10 Richard Frith-Macdonald - - * Source/GSSocketStream.m: tweak TLS code - * Source/GSStream.m: simplify socket code - * configure.ac: enable gnu tls by default - * configure: regenerate - -2008-01-09 Richard Frith-Macdonald - - * Source/GSSocketStream.h: - * Source/GSSocketStream.m: - * Source/unix/NSStream.m: - * Source/GSNetwork.h: - Further reorganisation and simplification for socks support. - -2008-01-07 Richard Frith-Macdonald - - * Source/GSSocketStream.h: simplify socket address handling - * Source/GSSocketStream.m: ditto + more work on socks - * Source/GSStream.h: minor tweaks - * Source/GSStream.m:minor tweaks - * Source/unix/NSStream.m: simplified socket address handling - * Source/GSNetwork.h: add macro to get socket address length - * Source/GSHTTPAuthentication.m: Handle arg classh check in init - * Source/NSURLRequest.m: ditto - * Source/NSURLProtocol.m: attempt to add support for authentication - -2008-01-07 Fred Kiefer - - * Source/NSFileManager.m (-fileSystemAttributesAtPath:): Correct - block size for systems using statvfs(). - -2008-01-05 Richard Frith-Macdonald - - * Source/GSSocketStream.m: Try to honor protocol requested. - * Source/NSURLProtocol.m: Add https - -2008-01-05 Nicola Pero - - * Source/Additions/GSXML.m ([GSXPathContext - -registerNamespaceWithPrefix:href:]): Added new method to support - namespaces in XPath expressions. - * Headers/Additions/GNUstepBase/GSXML.h: Same. - -2008-01-05 Richard Frith-Macdonald - - * config/pathtls.m4: fixup form mingw32 - * configure: regenerate - * Source/GSSocketStream.m: Fix missing ifdefs - -2008-01-04 Riccardo Mottola - - * Source/NSKeyValueObserving.m: fixed cc99ism - -2008-01-04 Richard Frith-Macdonald - - * Source/GSSocketStream.h: - * Source/GSSocketStream.m: - Add rudimentary gnutls support. Client sockets only, - no checking of certificates etc. - -2007-01-04 Richard Frith-Macdonald - - * config/pathtls.m4: New checks for gnu tls - * configure.ac: Add checks for gnu tls. - * config.mak.in: Take note of tls availability - * Headers/Additions/GNUstepBase/config.h.in: ditto - * base.make.in: ditto - * configure: regenerate - Preparatory checks for using gnu tls. - -2008-01-04 Richard Frith-Macdonald - - * Source/GSSocketStream.h: derived from GSStream.h - * Source/GSSocketStream.m: derived from GSStream.m - * Source/GNUmakefile: use new files - * Source/GSStream.h: remove code to GSSocketStream.h - * Source/GSStream.m: remove code to GSSocketStream.m - * Source/unix/NSStream.m: include GSSocketStream.h - * Source/win32/NSStream.m: include GSSocketStream.h - Minor restructuring for clarity. - -2008-01-04 Richard Frith-Macdonald - - * Headers/Foundation/NSStream.h: Tweak comments. - * Source/GSNetwork.h: New file for common networking declarations. - * Source/GSStream.h: - * Source/GSStream.m: - * Source/unix/NSStream.m: - * Source/win32/NSStream.m: - Extract socket networking code for both unix and windows into - semi-abstract superclasses for input/output/server streams so - that we avoid huge duplication of code and can maintain the - socket code more easily. - Alter the behavior of the code on windows so that when the - other end closes the connection we should be able to read all - data in transit in the same way as on unix (ie don't close - the local end until a read/write actually fails). - -2008-01-03 Richard Frith-Macdonald - - * Source/inet_pton.c: Add mswindows implementation of - inet_ntop() as well. - -2008-01-02 Richard Frith-Macdonald - - * Source/win32/GSFileHandle.m: rename to GSFileHandleWin32.m - * Source/win32/NSUserDefaultsWin32.m: rename to NSUserDefaults.m - * Source/win32/NSMessagePortWin32.m: rename to NSMessagePort.m - * Source/win32/NSStreamWin32.m: rename to NSStream.m - * Source/win32/NSMessagePortNameServerWin32.m: rename to - NSMessagePortNameServer.m - * Source/win32/GNUmakefile: Rename source files for consistency. - -2008-01-01 Adam Fedor - - * Tools/HTMLLinker.gsdoc: Readded - -2008-01-01 Adam Fedor - - * Version 1.15.2 - -2007-12-31 Richard Frith-Macdonald - - * Source/NSMessagePort.m: - * Source/NSSocketPort.m: - Fix error sending NSPortMessage objects which have not reserved - space in their first component. - -2007-12-26 Richard Frith-Macdonald - - * config/config.joinable.m: test for joinable threads. - * configure.ac: Add test for setrlimit and joinable threads - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * Source/NSThread.m: implement setting stack size for new - threads. Hack in workaround for versions of libobjc which - leak thread resource memory. - -2007-12-24 Adam Fedor - - * configure.ac: Don't fail if ffcall trampolines don't work. - * configure: regnerate. - -2007-12-24 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Perhaps a bit paranoid, but alter to recheck - all timers after any timer is fired, so we ar sure to pick up any - changes done to timer fire dates during the firing of a timer. - * Source/NSThread.m: Fix memory leak and correct thread startup - semantics to be like MacOS-X I hope. - -2007-12-22 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Fix error finding earliest timer for limit date. - -2007-12-21 Richard Frith-Macdonald - - * Source/GSLocale.m: protect locale access with locks. - -2007-12-21 David Ayers - - * Source/NSPathUtilities.m (_POSIX_PTHREAD_SEMANTICS): Define to expose - POSIX compliant signatures for get(pw/gr)(nam/uid)_r. - - * Headers/Additions/GNUstepBase/config.h.in, configure.ac (alloca.h): - Check for header. - * configure: Regenerate. - * Source/mframe.m, Source/cifframe.m, Source/NSConnection.m, - Source/callframe.m, Source/GSFormat.m: Include alloca.h where available. - -2007-12-20 David Ayers - - * Headers/Additions/GNUstepBase/GSLock.h: Include GSObjCRuntime.h for - GS_EXPORT declaration. - * Source/NSFileManager.m (_POSIX_PTHREAD_SEMANTICS): Define to expose - POSIX compliant signatures for get(pw/gr)(nam/uid)_r. - -2007-12-19 Richard Frith-Macdonald - - * configure.ac: Add checks for thread-safe versions of some standard - library functions. - * Headers/Additions/GNUstepBase/config.h.in: Regenerate - * configure: Regenerate - * Source/NSPathUtilities.m: - * Source/NSProcessInfo.m: - * Source/NSFileManager.m: - * Source/externs.m: - * Source/Additions/GSObjCRuntime.m: - * Source/Additions/GSCategories.m: - * Source/Additions/GSLock.m: - * Headers/Foundation/NSObject.h: - * Headers/Additions/GNUstepBase/GSLock.h: - * Tools/defaults.m: - Use thread-safe variants of system functions or pretect unsafe ones - using gnustep_global_lock. - Fixes part (but not all) of bug #21320 - -2007-12-17 Fred Kiefer - - * Source/NSKeyValueObserving.m - (-setKeys:triggerChangeNotificationsForDependentKey:): Correct the - key strategy of the map. - -2007-12-17 Adam Fedor - - * Source/Makefile.postamble: Use DESTDIR over obsolete INSTALL_ROOT_DIR - * configure.ac, config/objc-con-autoload.m4, config/procfs.m4: Some - improvements for cross-compiling. - -2007-12-15 Fred Kiefer - - * Source/NSKeyValueObserving.m (-keyPathChanged:): Correct - forwarding of changes. - -2007-12-15 Fred Kiefer - - * Source/NSValueTransformer.m, - * Source/externs.m: Moved name of standard NSValueTransformers to - externs and corrected strings. - -2007-12-15 Fred Kiefer - - * Source/NSKeyValueObserving.m (-overrideSetterFor:): Replace - exception with log message. - * Source/NSKeyValueObserving.m (-addObserver:...context:): Use - original class as key for replacement. - -2007-12-15 Fred Kiefer - - * Source/NSKeyValueObserving.m (-overrideSetterFor:): Manually - capitalize the string, as the NSString method capitalizedString - lowers all other characters. - -2007-12-14 Fred Kiefer - - * Source/NSKeyValueObserving.m (-overrideSetterFor:): Made aware - of dependent key mapping. - -2007-12-14 Richard Frith-Macdonald - - * Source/NSKeyValueObserving.m: Rewrite code for the subclass which - handles overriding of setters. Should only override the setters for - the keys which have been observed. Compiles but untested! - -2007-12-11 Richard Frith-Macdonald - - * Source/NSUserDefaults.m: catch any exception if som eone breaks our - lock on the defaults file. - -2007-12-11 Richard Frith-Macdonald - - * Source/NSIndexSet.m: Test and debug ([-initWithCoder:]) - and ([-encodeWithCoder:]) methods for keyed archiving of sets - with multiple index ranges. - Implement old-style coding/decoding as well. - -2007-12-10 Chris Farber - - * Source/NSKeyValueObserving.m: implement methods needed for gui - bindings. - -2007-12-08 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Deal with mutation of timers array during - firing of a timer. - -2007-12-07 Richard Frith-Macdonald - - * Headers/Additions/GNUstepBase/GSConfig.h.in: - * Headers/Foundation/NSString.h: - declare unichar as uint16_t - -2007-12-07 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Keep timers unordered and check all of them - each time round ... to avoid bug where a timer is added to more - than one run loop mode and firing in one mode could result in badly - ordered timers in another mode. - Handle resetting of time for repeating timers. - Allow timeout handler callbacks to use ([-setFireDate:]) and have - it honoured. - * Source/NSTimer.m: Remove resetting of fire date from ([-fire]) - and move it to the run loop for MacOS-X compatibility. - -2007-12-06 Richard Frith-Macdonald - - * Source/NSRunLoop.m: Report the current mode when producing detailed - debug output, for better tracking of problems. - -2007-12-06 Richard Frith-Macdonald - - * Source/NSException.m: fix error reporting module containing code - and limit the length of the stack trace. - -2007-12-06 Richard Frith-Macdonald - - * Source/NSURL.m: Increase detail of information about bad URL string - on initialisation. Only output debug info if --GNU-Debug=dflt - -2007-12-06 Richard Frith-Macdonald - - * Source/NSException.m: honour environment variable for displaying - stack trace. - -2007-12-06 Richard Frith-Macdonald - - * Source/NSIndexSet.m (-initWithCoder:): Implement guessed algorithm - for keyed archiving of sets with multiple index ranges. - -2007-12-06 Fred Kiefer - - * Source/NSIndexSet.m (-initWithCoder:): Fix wrong method in last - change. - -2007-12-05 Richard Frith-Macdonald - - * Source/NSException.m: Add new MacOS-X method and improve stack trace - code. - * Source/NSXMLParser.m Add include for NSDictionary. - * Documentation/Base.gsdoc: Improve documentation of stack trace. - * Headers/Foundation/NSException.h: Add new MacOS-X method. - -2007-12-05 David Ayers - - * Source/NSDecimalNumber.m: (isinf,isnan,isinff,isnanf): Remove. - (GSIsNAN,GSIsInf): Attempt a more portable approach with using - _ISOC99_SOURCE which is also supported by some BSD's and possibly - Solaris. - -2007-12-04 Richard Frith-Macdonald - - * Source/NSFileManager.h: move includes around to fix bug #21718 - -2007-12-03 David Ayers - - * Source/NSDecimalNumber.m: (isinf,isnan,isinff,isnanf): - Temporary empty definitions of C99 macros for environments - which do not define them. - -2007-12-03 Fred Kiefer - - * Source/NSIndexSet.m (-initWithCoder:, -encodeWithCoder) - * Source/NSData.m (NSMutableData-initWithCoder:, - -encodeWithCoder): Add some keyed encoding/decoding. - -2007-12-03 Richard Frith-Macdonald - - * Source/NSDebug.m: - * Source/GSPrivate.h: - * Source/NSException.m: - * Source/NSThread.m: - Rewrite some stackframe handling code for greater efficiency. - When raising an exception, just get the current stack and don't - bother translating addresses to method/function information until - needed by the -description method. Improves performance of - exception handling and eliminates the possibility of a recursive - exception due to a problem in the stacktrace code. - -2007-12-02 David Ayers - - * Source/NSDecimal.m (GSDecimalDouble): Use NAN when available. - * Source/NSDecimalNumber.m ([initWithBytes:objCType:]): Implement - initialization with scalar types. Use GSPrivateDefaultLocale - to initialze intermediate string to match expectations of - initWithString. - (NSDecimalNumberClass): Added local class cache. - ([+initialize]): Initialize new cache. - ([-compare]): Test for all subclasses instead of only NSDecimalNumber - instances. - - * Source/NSCalendarDate.m: Add explicit include of NSDictionary.h. - * Source/NSNotification.m: Ditto. - * Source/NSURLResponse.m: Ditto. Use available dictionary declartion. - * Source/NSURLProtocol.m: Add explicit import of NSData.h. - * Source/NSSerializer.m: Add explicit import of NSEnumerator.h. - * Source/NSURLConnection.m - ([-initWithResponsePointer:andErrorPointer:]): Add declaration. - - * Source/NSKeyValueMutableArray.m: Various non-functional variable - and parameter renames to avoid bogus compiler warnings. - * Source/NSKeyValueMutableSet.m: Ditto. - -2007-11-30 Richard Frith-Macdonald - - * Tools/gdomap.h: fix typo - -2007-11-29 Marcus Muller - - * Source/NSKeyValueCoding.m: Make backward compatibility work with - situations where we have classes using both new and old APIs in the - same executable. - -2007-11-29 Richard Frith-Macdonald - - * Source/GSLocale.m: - * Source/NSTimeZone.m: - * Source/NSNetServices.m: - * Source/NSURLCredential.m: - * Source/NSPortCoder.m: - * Source/NSURLAuthenticationChallenge.m: - * Source/NSKeyValueCoding.m: - * Source/NSBundle.m: - * Source/NSURLHandle.m: - * Source/NSPropertyList.m: - * Source/NSAffineTransform.m: - * Source/GSRunLoopWatcher.m: - * Source/NSUserDefaults.m: - * Source/GSArray.m: - * Source/GSFFCallInvocation.m: - * Source/NSArray.m: - * Source/GSStream.m: - * Source/NSDebug.m: - * Source/unix/NSStream.m: - * Source/NSKeyedUnarchiver.m: - * Source/GSConcreteValue.m: - * Source/NSURLDownload.m: - * Source/GSHTTPURLHandle.m: - * Source/NSURLCredentialStorage.m: - * Source/GSFFIInvocation.m: - * Source/GSDictionary.m: - * Source/GSCountedSet.m: - * Source/NSUnarchiver.m: - * Source/win32/NSStreamWin32.m: - * Source/NSURLResponse.m: - * Source/NSURLProtocol.m: - * Source/NSURLCache.m: - * Source/GSAttributedString.m: - * Source/NSException.m: - * Source/NSURL.m: - * Source/Additions/GSObjCRuntime.m: - * Source/Additions/GSInsensitiveDictionary.m: - * Source/GSSet.m: - * Source/NSConnection.m: - * Source/GSString.m: - * Source/NSHost.m: - * Source/NSURLProtectionSpace.m: - * Source/GSValue.m: - * Source/NSDictionary.m: - * Source/GSHTTPAuthentication.m: - * Source/NSURLRequest.m: - * Source/NSCountedSet.m: - * Source/GSFormat.m: - * Source/GSFileHandle.m: - * Source/NSSet.m: - * Source/NSArchiver.m: - * Source/NSPortNameServer.m: - * Source/GSFTPURLHandle.m: - * Source/NSEnumerator.m: - * Source/GSURLPrivate.h: - * Source/NSURLConnection.m: - * Headers/Foundation/NSArray.h: - * Headers/Foundation/NSFileManager.h: - * Headers/Foundation/NSUtilities.h: - * Tools/defaults.m: - * Tools/make_strings/make_strings.m: - * Tools/make_strings/StringsEntry.m: - * Testing/nstimezone.m: - * Testing/nsarray.m: - * Testing/nsprocessinfo.m: - * Testing/nsdictionary.m: - * Testing/nsset.m: - * Testing/nsarchiver.m: - * Testing/call.m: - * Testing/benchmark.m: - * Testing/nsbundle.m: - Remove use of deprecated NSUtilities.h header, and add explicit - includes of NSDictionary.h, NSEnumerator.h etc. - -2007-11-29 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: Remove erroneous check for nil argument - in obsolete method ([takeValue:forKey:]). - -2007-11-28 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: Improve code for folding header lines - to try to make sure long values don't go beyond the 78 character - limit. - -2007-11-26 Richard Frith-Macdonald - - * Source/Additions/GSXML.m: Make check for apple property lists - more tolerant. - -2007-11-25 Richard Frith-Macdonald - - * Headers/Foundation/NSThread.h: Add new methods from MacOS 10.5 - Add new ivars to match. Add _reserved to preserve binary - compatibility over future changes. Make all ivars private. - * Source/NSThread.m: Implement some new MacOS-5 stuff and add stubs - for stack size and thread cancellation. - * Source/NSException.m Implement ([NSThread+callStackReturnAddresses]) - Restructure a little to avoid problems when building without debug. - -2007-11-09 Adam Fedor - - * Version 1.15.1 - -2007-11-06 Roland Schwingel - - * Source/NSTimeZone.m: In windows use wide (unichar) API - -2007-11-05 Richard Frith-Macdonald - - * Source/NSXML.m: Make sloppy parser available for internal use when - parsing bad xml produced by Apple tools. - * Source/NSPropertyList.m: Use GSSloppyXMLParser if normal xml2 based - parsing fails due to Ap[ple4's inclusioon of illegal characters in - the XML. - -2007-10-31 Richard Frith-Macdonald - - * Source/NSUserDefaults.m: ([setBoolForKey:]) changed to store YES - or NO as a string for MacOS-X compatibility. - -2007-10-30 Adam Fedor - - * gnustep-base.spec.in: Change Copyright to License. - -2007-10-11 Wolfgang Lux - - * Source/NSUndoManager: Prevent incorrect posting of notifications - during undo/redo and avoid unnecessary creation of undo - groups. - -2007-10-10 Fred Kiefer - - * Source/NSDecimal.m (NSDecimalMultiplyByPowerOf10): Move check of - over/underflow after copy. - Patch by Mark Tracy . - -2007-10-03 Richard Frith-Macdonald - - * Source/NSData.m: Fix ([-classForCoder:]) to return base class of - cluster (bug #21133) - * Source/cifframe.m: avoid compiler warnings (bug #16996) - -2007-09-25 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: Decode headers as latin1 by default if - parsing http rather than mime. - -2007-09-14 Richard Frith-Macdonald - - Update files to use LGPL3 and GPL3 licenses. - -2007-09-09 Richard Frith-Macdonald - - * Source/NSNotificationCenter.m: Wrap posting of notification in - exception handler to log exceptions. - -2007-08-24 23:53-EDT Gregory John Casamento - - * Headers/Foundation/NSPort.h: Removed commented out declaration - in the header. - -2007-08-04 David Ayers - - * Source/GSHTTPURLHandle.m (writeKeyCallBacks): Use retained - callbacks for keys. - -2007-08-02 Richard Frith-Macdonald - - * Source/NSProcessInfo.m: Private method to check existence of - process. - -2007-07-31 Richard Frith-Macdonald - - * Headers/Foundation/NSRange.h: - * Headers/Foundation/NSException.h: - * Headers/Foundation/NSGeometry.h: - * Headers/Foundation/NSAutoreleasePool.h: - * Headers/Additions/GNUstepBase/preface.h.in: - * macosx/GNUstepBase/preface.h: - Use __typeof__ rather than typeof so that if the header is included - in user code which is compiled with a flag to disalow typeof, the - code will still work. - -2007-07-25 Fred Kiefer - - * Headers/Foundation/NSErrorRecoveryAttempting.h: Add new file. - * Source/GNUmakefile: Install this file. - -2007-07-22 Richard Frith-Macdonald - - * Tools/AGSOutput.m: escape angle brackets in types of function - arguments. - -2007-07-19 Riccardo Mottola - - * Source/NSKeyValueCoding.m: - * Source/NSKeyValueMutableSet.m: - Code cleanup and C99-ism fixes - -2007-07-14 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: - * Source/NSKeyValueMutableSet.m: - * Source/NSArray.m: - * Source/NSKeyValueMutableArray.m: - Whitespace and initialisation tidyups. - -2007-07-11 Richard Frith-Macdonald - - * Source/NSString.m: For MacOS-X compatibility, alter -propertyList - to have the undocumented behavior of parsing strings file format - too. - -2007-07-10 Chris Farber - - * Source/NSArray.m ([NSArray -objectsAtIndexes:]): New method. - ([NSMutableArray -removeObjectsAtIndexes:]): New method. - * Headers/Foundation/NSArray.h: Added the new methods. - - * Source/NSKeyValueCoding.m ([-mutableArrayValueForKey:]): New - method. ([-mutableArrayValueForKeyPath:]): New method. - ([-mutableSetValueForKey:]): New method. - ([-mutableSetValueForKeyPath:]): New method. - ([-valueForUndefinedKey:]): Include key and object in the reason - of an NSUndefinedKeyException. - * Headers/Foundation/NSKeyValueCoding.h: Added the new methods. - - * Source/NSKeyValueMutableSet.m: New file. - * Source/NSKeyValueMutableArray.m: New file. - -2007-07-10 Richard Frith-Macdonald - - * Source/win32/GSFileHandleWin32.m: Fixup for pipes as suggested by - Matthew Jiminez. - -2007-06-26 Richard Frith-Macdonald - - * Source/NSKeyedArchiver.m: - * Source/NSKeyedUnarchiver.m: - Implement support for arrays of objc types to fix bug #20268 - -2007-06-21 Richard Frith-Macdonald - - Rewrite code to support parsing of predicates containing - all the '%' format strings (as suggested by Fred). - -2007-06-20 Richard Frith-Macdonald - - * Source/NSPredicate.m: Fix bug #20215 ... scanning of greater than - and less than operators. - Add code to attempt to support parsing of predicates containing - all the '%' format strings ... untested. - -2007-06-15 Adam Fedor - - * Source/NSTimeZone.m ([NSTimeZone +timeZoneArray]): Skip .tab - files when looking for zones. - -2007-06-14 Richard Frith-Macdonald - - * Source/NSNumber.m: Implement ([isEqualToValue:]) - * Source/NSPredicate.m: Fix bug #20169 - -2007-06-13 Richard Frith-Macdonald - - * Source/NSURLHandle.m: ([loadInForeground]) return as soon as load - is complete, rather than waiting for up to a second. - -2007-06-12 Fred Kiefer - - * Source/NSPredicate.m: Fake like and matches by using - compare:options: and reverted change for string equality. - -2007-06-11 Fred Kiefer - - * Source/NSPredicate.m: Improved predicate parsing. Handle more - alternate key strings, implemented BETWEEN, use compare:options: - for string equality test and handle in for collections. - -2007-06-09 Fred Kiefer - - * Source/NSPredicate.m: Improved predicate parsing. - -2007-06-08 Richard Frith-Macdonald - - * Source/GSString.m Fix bug getting cString from literal string - with illegal (non-ascii) characters. - * Source/NSKeyValueCoding.m: Fix backward compatibility issue with - NSUnknownKeyException. - -2007-06-06 Richard Frith-Macdonald - - * Source/NSKeyValueCoding.m: Use UTF8 rather than ASCII - -2007-06-03 Richard Frith-Macdonald - - * Source/GSHTTPURLHandle.m: define MSG_DONTWAIT as zero if it's not - defined ... it should not be needed anyway if the socket is already - non-blocking. - -2007-06-03 Richard Frith-Macdonald - - * Source/win32/GSFileHandleWin32.m: Clean up indentation issues etc. - -2007-06-01 Richard Frith-Macdonald - - * Source/Additions/GSMime.m: Fix problem where any header starting - with 'http' would be mangled. - -2007-05-31 Richard Frith-Macdonald - - * Tools/NSKeyValueCoding.m: Minor fix for backward compatibility in - ([setNilValueForKey:]). - -2007-05-30 Richard Frith-Macdonald - - * Tools/gdomap.m: Don't trap abort signal. - -2007-05-29 Richard Frith-Macdonald - - * Source/NSData.m: when unable to open a file, log should be debug - level rather than warn level. - -2007-05-23 Fred Kiefer - - * Headers/Foundation/NSCompoundPredicate.h: Add some common ivars. - * Headers/Foundation/NSExpression.h:Add some common ivar. - * Source/NSPredicate.m: Implement a lot of missing functionality - for the predicate and expression classes. Clean up formatting. - -2007-05-16 Richard Frith-Macdonald - - * Headers/Foundation/NSNetServices.h: fix bug #19872 - -2007-05-16 Richard Frith-Macdonald - - * Source/NSURLConnection.m: Cancel when deallocating. - * Source/NSURLProtocol.m: Make sure load is stopped if an error - occurs. - -2007-05-15 Richard Frith-Macdonald - - * Source/NSException.m: Permit some recursion in handling uncaught - exceptions so that different exception handlers can be tried ... - in particular, so that the gui library exception handler can - fall back to using the base library handler and get a printout of - the exception details when the program terminates. - -2007-05-15 Richard Frith-Macdonald - - * Source/NSURLConnection.m: Minor simplifications. - * Source/NSURLProtocol.m: Perform automatic redirect from - http://host to http://host/ to standardise URL used for caching as - noted in Apple documentation. - * Source/NSURLRequest.m: use case insensitive dictionary for headers. - * Source/Additions/GSMime.m: fix error makeing tokens lowercase. - -2007-05-14 Richard Frith-Macdonald - - * Source/Additions/GSInsensitiveDictionary.m: For internal use storing - values on case insensitive keys. - * Source/Additions/GNUmakefile: Build insensitive dictionaries. - * Source/GSPrivate.h: Make insensitive dictionaries available. - * Source/NSURLResponse.m: Use insensitive dictionaries. - * Source/NSURLProtocol.m: Clean up. - * Source/Additions/GSMime.m: New stuff to retain case information. - * Headers/Additions/GNUstepBase/GSMime.h: ditto. - -2007-05-14 Richard Frith-Macdonald - - * Source/NSURLProtocol.m: - * Source/NSURLRequest.m: - * Source/NSURLConnection.m: - Added tweaks for redirection andvarious comments. - -2007-05-14 Richard Frith-Macdonald - - * Source/Additions/Unicode.m: - Avoid using NSString while printing warning about iconv problems ... - try to avoid possible recursion etc. - -2007-05-13 Richard Frith-Macdonald - - * Source/NSURLProtocol.m: Replace mystep response parsing code with - more reliable/standard-compliant stuff adapted from NSURLHandle.m - -2007-05-12 Richard Frith-Macdonald - - * Source/GSStream.h: New runloop management - * Source/GSStream.m: Support scheduling in multiple runloops to match - documented MacOS-X behavior. Trigger instant event on error or eof. - * Source/unix/NSStream.m: Don't send error and eof events asap, defer - until the runloop runs as this is how MacOS-X behaves. - * Source/win32/NSStreamWin32.m: ditto. - * Source/unix/GSRunLoopCtxt.m: Fix failure to trigger immediate events - when there are no non-immediate input sources in th loop. Fix busy - poll when there are no non-immediate sources in the loop. - * Source/win32/GSRunLoopCtxt.m: ditto - -2007-05-12 Richard Frith-Macdonald - - * Source/NSURLProtocol.m: Fix multiple release of headers. - -2007-05-11 Richard Frith-Macdonald - - * Source/GSStream.m: - * Source/unix/NSStream.m: - * Source/win32/NSStreamWin32.m: - * Headers/Foundation/NSStream.h: - First hack at extensions to get address and port properties for - network streams. Use localhost if no host is given for connect. - * Source/GSFFIInvocation.m: - Attempt to use forward2 if available. - * Source/NSURLProtocol.m: - Fixup some problems with incorporation of code from mySTEP. - -2007-05-11 Richard Frith-Macdonald - - * Source/NSURLResponse.m: - * Source/NSURLProtocol.m: - * Source/NSURLRequest.m: - * Source/GSURLPrivate.h: - * Source/NSURLConnection.m: - Changes accidentally missed from update on 27th april. - -2007-05-02 Nicola Pero - - * configure.ac: Set GNUSTEP_MAKEFILES to CURRENT_GNUSTEP_MAKEFILES - before sourcing GNUstep.sh. Fixes building when paths to hardcode - in the library are different from paths used when building, - typically a case when packaging. - * configure: Regenerated. - -2007-04-28 Richard Frith-Macdonald - - * Source/thr-pthread.m: Set thread attributes detached to avoid memory - leak as suggested by Chris Ball - -2007-04-27 Richard Frith-Macdonald - - * Source/NSBundle.m: Reformat for coding standards. Alter library - resource lookup to find correct version when multiple versions of - the base library are installed and the old unversioned api is used. - * Source/NSURLHandle.m: Scheduling tweak. - * Source/GSFFCallInvocation.m: Use forward2 if available. - * Source/GSFFIInvocation.m: Use forward2 if available. - * Source/NSURLRequest.m: Tidyups - * Source/NSURLConnection.m: Tidyups - * Source/NSURLProtocol.m: Incorporate some concrete protocols from - mySTEP ....needs rewriting and then testing. - * Headers/Foundation/NSURLRequest.h: Fix typos and improve comments. - -2007-04-16 Richard Frith-Macdonald - - * config/config.forward2.m: Test for forward2 function in runtime. - * configure.ac: Run forward2 test - * Headers/Additions/GNUstepBase/config.h.in: record forward2 test. - * configure: regenerate - -2007-04-15 Richard Frith-Macdonald - - * configure.ac: check for wide character support in printf - * config/config.wprintf.c: ditto - * configure: regenerate - * Headers/Additions/GNUstepBase/config.h.in: regenerate - * Source/NSString.m: Don't use wide char support if we don't have it. - Should fix bug #19587 - -2007-04-15 Richard Frith-Macdonald - - * Source/NSBundle.m: - ([+pathForResource:ofType:inRootPath:inDirectory:withVersion:]) - Tolerate nil/empty resource name for compatibility with MacOS-X - and to fix bug #19588 - * Source/NSPredicate.m: Implement ([-filterUsingPredicate:]) for - NSMutableArray. - * Headers/Foundation/NSPredicate.h: Add the - ([-filterUsingPredicate:]) method and document it. - * config/config.printf.c: use 'wide' field in info structure to - check that it exists. - -2007-04-13 Ricccardo Mottola - - * Source/NSSortDescriptor.m : removed C99-ism - -2007-04-13 Ricccardo Mottola - - * Source/GSHTTPURLHandle.m : removed C99-ism - -2007-04-13 Adam Fedor - - * Version: Fix matching numeric version - -2007-04-13 Richard Frith-Macdonald - - * Source/GSFileHandle.m: ([-readDataOfLength:]) fix bug which could - cause short reads. - -2007-04-12 Adam Fedor - - * Tool/HTMLLinker.m: Re-add. - - * Documentation/coding-standards.texi: Add info section - * Documentation/manual/manual.texi: Likewise (patch from - Marco Bardelli). - * gnustep-base-debug.spec.in: Remove - - * gnustep-base.spec.in, Documentation/install.texi: Document - that gnustep-make 2.0.0 is required. - -2007-04-12 Adam Fedor - - * Version 1.15.0 - 2007-04-12 Adam Fedor * Version 1.14.0 @@ -6919,7 +662,7 @@ 2006-12-26 Richard Frith-Macdonald * Headers/Foundation/NSValueTransformer.h: - * Source/NSValueTransformer.m: + * Source/NSValueTransformer.h: Complete implementation. Make thread-safe. Document. diff --git a/Documentation/Base.gsdoc b/Documentation/Base.gsdoc index c520a36bf..69c5ddc1e 100644 --- a/Documentation/Base.gsdoc +++ b/Documentation/Base.gsdoc @@ -1,5 +1,5 @@ - + next -----------> next -----------> next --> nil - * nil <-- prev <----------- prev <----------- prev + * head ---------> prev -----------> prev -----------> prev --> nil + * nil <-- next <----------- next <----------- next * tail ---------------------------------------------> */ @@ -191,24 +198,30 @@ static inline void remove_from_queue_no_release(NSNotificationQueueList *queue, NSNotificationQueueRegistration *item) { - if (item->next) - { - item->next->prev = item->prev; - } - else - { - NSCAssert(queue->tail == item, @"tail item not at tail of queue!"); - queue->tail = item->prev; - } - if (item->prev) { item->prev->next = item->next; } else { - NSCAssert(queue->head == item, @"head item not at head of queue!"); - queue->head = item->next; + queue->tail = item->next; + if (item->next) + { + item->next->prev = NULL; + } + } + + if (item->next) + { + item->next->prev = item->prev; + } + else + { + queue->head = item->prev; + if (item->prev) + { + item->prev->next = NULL; + } } } @@ -228,12 +241,7 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, { NSNotificationQueueRegistration *item; -#if GS_WITH_GC - item = NSAllocateCollectable(sizeof(NSNotificationQueueRegistration), - NSScannedOption); -#else item = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueRegistration)); -#endif if (item == 0) { [NSException raise: NSMallocException @@ -245,12 +253,12 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, item->object = [notification object]; item->modes = [modes copyWithZone: [modes zone]]; - item->next = NULL; - item->prev = queue->tail; + item->prev = NULL; + item->next = queue->tail; queue->tail = item; - if (item->prev) + if (item->next) { - item->prev->next = item; + item->next->prev = item; } if (!queue->head) { @@ -265,7 +273,8 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, */ @interface NSNotificationQueue (Private) -- (NSNotificationCenter*) _center; +- (void) _postNotification: (NSNotification*)notification + forModes: (NSArray*)modes; @end /** @@ -277,16 +286,6 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, */ @implementation NSNotificationQueue -static NSArray *defaultMode = nil; - -+ (void) initialize -{ - if (defaultMode == nil) - { - defaultMode = [[NSArray alloc] initWithObjects: (id*)&NSDefaultRunLoopMode - count: 1]; - } -} /** * Returns the default notification queue for use in this thread. It will @@ -335,15 +334,8 @@ static NSArray *defaultMode = nil; // init queue _center = RETAIN(notificationCenter); -#if GS_WITH_GC - _asapQueue = NSAllocateCollectable(sizeof(NSNotificationQueueList), - NSScannedOption); - _idleQueue = NSAllocateCollectable(sizeof(NSNotificationQueueList), - NSScannedOption); -#else _asapQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList)); _idleQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList)); -#endif if (_asapQueue == 0 || _idleQueue == 0) { DESTROY(self); @@ -368,15 +360,15 @@ static NSArray *defaultMode = nil; [NotificationQueueList unregisterQueue: self]; /* - * release items from our queues + * release self from queues */ - while ((item = _asapQueue->head) != 0) + for (item = _asapQueue->head; item; item=item->prev) { remove_from_queue(_asapQueue, item, _zone); } NSZoneFree(_zone, _asapQueue); - while ((item = _idleQueue->head) != 0) + for (item = _idleQueue->head; item; item=item->prev) { remove_from_queue(_idleQueue, item, _zone); } @@ -400,10 +392,10 @@ static NSArray *defaultMode = nil; * not posted. */ - (void) dequeueNotificationsMatching: (NSNotification*)notification - coalesceMask: (NSUInteger)coalesceMask + coalesceMask: (unsigned int)coalesceMask { NSNotificationQueueRegistration *item; - NSNotificationQueueRegistration *prev; + NSNotificationQueueRegistration *next; id name = [notification name]; id object = [notification object]; @@ -413,9 +405,9 @@ static NSArray *defaultMode = nil; /* * find in ASAP notification in queue matching both */ - for (item = _asapQueue->tail; item; item = prev) + for (item = _asapQueue->tail; item; item = next) { - prev = item->prev; + next = item->next; //PENDING: should object comparison be '==' instead of isEqual?! if ((object == item->object) && [name isEqual: item->name]) { @@ -425,9 +417,9 @@ static NSArray *defaultMode = nil; /* * find in idle notification in queue matching both */ - for (item = _idleQueue->tail; item; item = prev) + for (item = _idleQueue->tail; item; item = next) { - prev = item->prev; + next = item->next; if ((object == item->object) && [name isEqual: item->name]) { remove_from_queue(_idleQueue, item, _zone); @@ -439,9 +431,9 @@ static NSArray *defaultMode = nil; /* * find in ASAP notification in queue matching name */ - for (item = _asapQueue->tail; item; item = prev) + for (item = _asapQueue->tail; item; item = next) { - prev = item->prev; + next = item->next; if ([name isEqual: item->name]) { remove_from_queue(_asapQueue, item, _zone); @@ -450,9 +442,9 @@ static NSArray *defaultMode = nil; /* * find in idle notification in queue matching name */ - for (item = _idleQueue->tail; item; item = prev) + for (item = _idleQueue->tail; item; item = next) { - prev = item->prev; + next = item->next; if ([name isEqual: item->name]) { remove_from_queue(_idleQueue, item, _zone); @@ -464,9 +456,9 @@ static NSArray *defaultMode = nil; /* * find in ASAP notification in queue matching sender */ - for (item = _asapQueue->tail; item; item = prev) + for (item = _asapQueue->tail; item; item = next) { - prev = item->prev; + next = item->next; if (object == item->object) { remove_from_queue(_asapQueue, item, _zone); @@ -475,9 +467,9 @@ static NSArray *defaultMode = nil; /* * find in idle notification in queue matching sender */ - for (item = _idleQueue->tail; item; item = prev) + for (item = _idleQueue->tail; item; item = next) { - prev = item->prev; + next = item->next; if (object == item->object) { remove_from_queue(_idleQueue, item, _zone); @@ -511,17 +503,13 @@ static NSArray *defaultMode = nil; * in which case they are removed through a call to * -dequeueNotificationsMatching:coalesceMask: . The modes argument * determines which [NSRunLoop] mode notification may be posted in (nil means - * NSDefaultRunLoopMode). + * all modes). */ - (void) enqueueNotification: (NSNotification*)notification postingStyle: (NSPostingStyle)postingStyle - coalesceMask: (NSUInteger)coalesceMask + coalesceMask: (unsigned int)coalesceMask forModes: (NSArray*)modes { - if (modes == nil) - { - modes = defaultMode; - } if (coalesceMask != NSNotificationNoCoalescing) { [self dequeueNotificationsMatching: notification @@ -530,21 +518,11 @@ static NSArray *defaultMode = nil; switch (postingStyle) { case NSPostNow: - { - NSString *mode; - - mode = [[NSRunLoop currentRunLoop] currentMode]; - if (mode == nil || [modes indexOfObject: mode] != NSNotFound) - { - [_center postNotification: notification]; - } - } + [self _postNotification: notification forModes: modes]; break; - case NSPostASAP: add_to_queue(_asapQueue, notification, modes, _zone); break; - case NSPostWhenIdle: add_to_queue(_idleQueue, notification, modes, _zone); break; @@ -555,118 +533,49 @@ static NSArray *defaultMode = nil; @implementation NSNotificationQueue (Private) -- (NSNotificationCenter*) _center +- (void) _postNotification: (NSNotification*)notification + forModes: (NSArray*)modes { - return _center; + NSString *mode = [[NSRunLoop currentRunLoop] currentMode]; + + // check to see if run loop is in a valid mode + if (mode == nil || modes == nil + || [modes indexOfObject: mode] != NSNotFound) + { + [_center postNotification: notification]; + } } @end -static void -notify(NSNotificationCenter *center, NSNotificationQueueList *list, - NSString *mode, NSZone *zone) -{ - BOOL allocated = NO; - void *buf[100]; - void **ptr = buf; - unsigned len = sizeof(buf) / sizeof(*buf); - unsigned pos = 0; - NSNotificationQueueRegistration *item = list->head; - - /* Gather matching items into a buffer. - */ - while (item != 0) - { - if (mode == nil || [item->modes indexOfObject: mode] != NSNotFound) - { - if (pos == len) - { - unsigned want; - - want = (len == 0) ? 2 : len * 2; - if (NO == allocated) - { - void *tmp; - - tmp = NSZoneMalloc(NSDefaultMallocZone(), - want * sizeof(void*)); - memcpy(tmp, (void*)ptr, len * sizeof(void*)); - ptr = tmp; - allocated = YES; - } - else - { - ptr = NSZoneRealloc(NSDefaultMallocZone(), - ptr, want * sizeof(void*)); - } - len = want; - } - ptr[pos++] = item; - } - item = item->next; // head --> tail uses next link - } - len = pos; // Number of items found - - /* Posting a notification catches exceptions, so it's OK to use - * retain/release of objects here as we won't get an exception - * causing a leak. - */ - if (len > 0) - { - /* First, we make a note of each notification while removing the - * corresponding list item from the queue ... so that when we get - * round to posting the notifications we will not get problems - * with another notif() trying to use the same items. - */ - for (pos = 0; pos < len; pos++) - { - item = ptr[pos]; - ptr[pos] = RETAIN(item->notification); - remove_from_queue(list, item, zone); - } - - /* Now that we no longer need to worry about r-entrancy, - * we step through our notifications, posting each one in turn. - */ - for (pos = 0; pos < len; pos++) - { - NSNotification *n = (NSNotification*)ptr[pos]; - - [center postNotification: n]; - RELEASE(n); - } - - if (allocated) - { - NSZoneFree(NSDefaultMallocZone(), ptr); - } - } -} - /* * The following code handles sending of queued notifications by * NSRunLoop. */ -void -GSPrivateNotifyASAP(NSString *mode) +static inline void notifyASAP(NSNotificationQueue *q) { - NotificationQueueList *item; + NSNotificationQueueList *list = ((accessQueue)q)->_asapQueue; - for (item = currentList(); item; item = item->next) + /* + * post all ASAP notifications in queue + */ + while (list->head) { - if (item->queue) - { - notify(item->queue->_center, - item->queue->_asapQueue, - mode, - item->queue->_zone); - } + NSNotificationQueueRegistration *item = list->head; + NSNotification *notification = item->notification; + NSArray *modes = item->modes; + + remove_from_queue_no_release(list, item); + [q _postNotification: notification forModes: modes]; + RELEASE(notification); + RELEASE(modes); + NSZoneFree(((accessQueue)q)->_zone, item); } } void -GSPrivateNotifyIdle(NSString *mode) +GSPrivateNotifyASAP() { NotificationQueueList *item; @@ -674,34 +583,60 @@ GSPrivateNotifyIdle(NSString *mode) { if (item->queue) { - notify(item->queue->_center, - item->queue->_idleQueue, - mode, - item->queue->_zone); + notifyASAP(item->queue); + } + } +} + +static inline void notifyIdle(NSNotificationQueue *q) +{ + NSNotificationQueueList *list = ((accessQueue)q)->_idleQueue; + + /* + * post next IDLE notification in queue + */ + if (list->head) + { + NSNotificationQueueRegistration *item = list->head; + NSNotification *notification = item->notification; + NSArray *modes = item->modes; + + remove_from_queue_no_release(list, item); + [q _postNotification: notification forModes: modes]; + RELEASE(notification); + RELEASE(modes); + NSZoneFree(((accessQueue)q)->_zone, item); + } + /* + * Post all ASAP notifications. + */ + notifyASAP(q); +} + +void +GSPrivateNotifyIdle() +{ + NotificationQueueList *item; + + for (item = currentList(); item; item = item->next) + { + if (item->queue) + { + notifyIdle(item->queue); } } } BOOL -GSPrivateNotifyMore(NSString *mode) +GSPrivateNotifyMore() { NotificationQueueList *item; for (item = currentList(); item; item = item->next) { - if (item->queue != nil) + if (item->queue && ((accessQueue)item->queue)->_idleQueue->head) { - NSNotificationQueueRegistration *r; - - r = item->queue->_idleQueue->head; - while (r != 0) - { - if (mode == nil || [r->modes indexOfObject: mode] != NSNotFound) - { - return YES; - } - r = r->next; - } + return YES; } } return NO; diff --git a/Source/NSNull.m b/Source/NSNull.m index 56d6eac02..e432e07a9 100644 --- a/Source/NSNull.m +++ b/Source/NSNull.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,8 +25,7 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSNull.h" +#include "Foundation/NSNull.h" /** * An object to use as a placeholder - in collections for instance. @@ -82,11 +81,6 @@ static NSNull *null = 0; GSNOSUPERDEALLOC; } -- (NSString*) description -{ - return @""; -} - - (void) encodeWithCoder: (NSCoder*)aCoder { } diff --git a/Source/NSNumber.m b/Source/NSNumber.m index af8ee7e69..9ea1b6f50 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -1,18 +1,16 @@ -/** Implementation of NSNumber for GNUStep - Copyright (C) 2010 Free Software Foundation, Inc. +/** NSNumber - Object encapsulation of numbers - Written by: David Chisnall - Partial rewrite: Richard Frith-Macdonld - (to compile on gnu/linux and mswindows, - to meet coding/style standards, - to restore lost functionality) - - Date: February 2010 + Copyright (C) 1993, 1994, 1996, 2000 Free Software Foundation, Inc. + + Written by: Adam Fedor + Created: Mar 1995 + Rewrite: Richard Frith-Macdonald + Date: Mar 2000 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -21,377 +19,1765 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. - */ + NSNumber class reference + $Date$ $Revision$ +*/ +#include +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSException.h" +#include "Foundation/NSString.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSPortCoder.h" +#include "Foundation/NSObjCRuntime.h" -#import "common.h" +#include "NSConcreteNumber.h" +#include "GSPrivate.h" -#if !defined(LLONG_MAX) -# if defined(__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX-1) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) -# else -# error Neither LLONG_MAX nor __LONG_LONG_MAX__ found -# endif -#endif - - -#import "Foundation/NSCoder.h" -#import "Foundation/NSDecimalNumber.h" -#import "Foundation/NSException.h" -#import "Foundation/NSValue.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" - -/* - * NSNumber implementation. This matches the behaviour of Apple's - * implementation. Values in the range -1 to 12 inclusive are mapped to - * singletons. All other values are mapped to the smallest signed value that - * will store them, unless they are greater than LLONG_MAX, in which case - * they are stored in an unsigned long long. - * Booleans are handled as a special case since some stuff (notably interface - * builder (nib) archives) needs to differentiate between booleans and integers. - */ - -@interface NSSignedIntegerNumber : NSNumber +@interface GSCachedBool : NSBoolNumber @end - -@interface NSIntNumber : NSSignedIntegerNumber +@interface GSCachedInt : NSIntNumber +@end +@implementation GSCachedBool +- (id) copyWithZone: (NSZone*)zone { -@public - int value; + return RETAIN(self); +} +- (void) dealloc +{ + [NSException raise: NSGenericException + format: @"Attempt to deallocate bool number owned by cache"]; + GSNOSUPERDEALLOC; } @end - -/* Some code needs to differentiate between booleans and other NSNumber - * instances, so we need a special subclass to permit that. - */ -@interface NSBoolNumber : NSIntNumber -@end - -@interface NSLongLongNumber : NSSignedIntegerNumber +@implementation GSCachedInt +- (id) copyWithZone: (NSZone*)zone { -@public - long long int value; + return RETAIN(self); } -@end - -@interface NSUnsignedLongLongNumber : NSNumber +- (void) dealloc { -@public - unsigned long long int value; + [NSException raise: NSGenericException + format: @"Attempt to deallocate int number owned by cache"]; + GSNOSUPERDEALLOC; } @end -// The value ivar in all of the concrete classes contains the real value. -#define VALUE value -#define COMPARE(value, other) \ -if (value < other)\ - {\ - return NSOrderedAscending;\ - }\ -if (value > other)\ - {\ - return NSOrderedDescending;\ - }\ -return NSOrderedSame; - -@implementation NSSignedIntegerNumber -- (NSComparisonResult) compare: (NSNumber*)aNumber -{ - if (aNumber == self) - { - return NSOrderedSame; - } - if (aNumber == nil) - { - [NSException raise: NSInvalidArgumentException - format: @"nil argument for compare:"]; - } - - switch ([aNumber objCType][0]) - { - /* For cases smaller than or equal to an int, we could get the int - * value and compare. - */ - case 'c': - case 'C': - case 's': - case 'S': - case 'i': - case 'I': - case 'l': - case 'L': - case 'q': - { - long long value = [self longLongValue]; - long long other = [aNumber longLongValue]; - - COMPARE (value, other); - } - case 'Q': - { - unsigned long long other; - unsigned long long value; - long long v; - - /* According to the C type promotion rules, we should cast this to - * an unsigned long long, however Apple's code does not do this. - * Instead, it performs a real comparison. - */ - v = [self longLongValue]; - - /* If this value is less than 0, then it is less than any value - * that can possibly be stored in an unsigned value. - */ - if (v < 0) - { - return NSOrderedAscending; - } - - other = [aNumber unsignedLongLongValue]; - value = (unsigned long long) v; - COMPARE (value, other); - } - case 'f': - case 'd': - { - double other = [aNumber doubleValue]; - double value = [self doubleValue]; - - COMPARE (value, other); - } - default: - [NSException raise: NSInvalidArgumentException - format: @"unrecognised type for compare:"]; - } - return 0; // Not reached. -} -@end - -@implementation NSIntNumber -#define FORMAT @"%i" -#include "NSNumberMethods.h" -@end - -@implementation NSBoolNumber -- (const char *) objCType -{ - return @encode(BOOL); -} -@end - -@implementation NSLongLongNumber -#define FORMAT @"%lli" -#include "NSNumberMethods.h" -@end - -@implementation NSUnsignedLongLongNumber -#define FORMAT @"%llu" -#include "NSNumberMethods.h" -- (NSComparisonResult) compare: (NSNumber*)aNumber -{ - if (aNumber == self) - { - return NSOrderedSame; - } - if (aNumber == nil) - { - [NSException raise: NSInvalidArgumentException - format: @"nil argument for compare:"]; - } - - switch ([aNumber objCType][0]) - { - /* For cases smaller than or equal to an int, we could get the int - * value and compare. - */ - case 'c': - case 'C': - case 's': - case 'S': - case 'i': - case 'I': - case 'l': - case 'L': - case 'q': - { - long long other = [aNumber longLongValue]; - - if (other < 0) - { - return NSOrderedDescending; - } - COMPARE (value, ((unsigned long long) other)); - } - case 'Q': - { - unsigned long long other = [aNumber unsignedLongLongValue]; - - COMPARE (value, other); - } - case 'f': - case 'd': - { - double other = [aNumber doubleValue]; - - COMPARE (((double) value), other); - } - default: - [NSException raise: NSInvalidArgumentException - format: @"unrecognised type for compare:"]; - } - return 0; // Not reached. -} -@end - -/* - * Abstract superclass for floating point numbers. - */ -@interface NSFloatingPointNumber : NSNumber -@end - -@implementation NSFloatingPointNumber -/* For floats, the type promotion rules say that we always promote to a - * floating point type, even if the other value is really an integer. - */ -- (BOOL) isEqualToNumber: (NSNumber*)aNumber -{ - return ([self doubleValue] == [aNumber doubleValue]) ? YES : NO; -} - -- (NSComparisonResult) compare: (NSNumber*)aNumber -{ - double other; - double value; - - if (aNumber == self) - { - return NSOrderedSame; - } - if (aNumber == nil) - { - [NSException raise: NSInvalidArgumentException - format: @"nil argument for compare:"]; - } - other = [aNumber doubleValue]; - value = [self doubleValue]; - COMPARE (value, other); -} -@end - -@interface NSFloatNumber : NSFloatingPointNumber -{ -@public - float value; -} -@end - -@implementation NSFloatNumber -#define FORMAT @"%0.7g" -#include "NSNumberMethods.h" -@end - -@interface NSDoubleNumber : NSFloatingPointNumber -{ -@public - double value; -} -@end - -@implementation NSDoubleNumber -#define FORMAT @"%0.16g" -#include "NSNumberMethods.h" -@end - @implementation NSNumber -static Class NSNumberClass; -static Class NSBoolNumberClass; -static Class NSIntNumberClass; -static Class NSLongLongNumberClass; -static Class NSUnsignedLongLongNumberClass; -static Class NSFloatNumberClass; -static Class NSDoubleNumberClass; +static NSMapTable *numberMap; +static BOOL multiThreaded = NO; +static NSNumber *boolN; +static NSNumber *boolY; +static NSNumber *smallIntegers[GS_SMALL * 2 + 1]; +static unsigned int smallHashes[GS_SMALL * 2 + 1]; /* - * Numbers from -1 to 12 inclusive that are reused. + * Cache info for each number class. + * In a multi-threaded system we may waste some memory in order to get speed. */ -static NSNumber *ReusedInstances[14]; -static NSBoolNumber *boolY; // Boolean YES (integer 1) -static NSBoolNumber *boolN; // Boolean NO (integer 0) +GSNumberInfo* +GSNumberInfoFromObject(NSNumber *o) +{ + Class c; + GSNumberInfo *info; + + if (o == nil) + return 0; + c = GSObjCClass(o); + info = (GSNumberInfo*)NSMapGet (numberMap, (void*)c); + if (info == 0) + { + const char *t = [o objCType]; + int order = -1; + + if (strlen(t) != 1) + { + NSLog(@"Invalid return value (%s) from [%@ objCType]", t, c); + } + else + { + switch (*t) + { + case 'c': order = 1; break; + case 'C': order = 2; break; + case 's': order = 3; break; + case 'S': order = 4; break; + case 'i': order = 5; break; + case 'I': order = 6; break; + case 'l': order = 7; break; + case 'L': order = 8; break; + case 'q': order = 9; break; + case 'Q': order = 10; break; + case 'f': order = 11; break; + case 'd': order = 12; break; + default: + NSLog(@"Invalid return value (%s) from [%@ objCType]", t, c); + break; + } + } + info = (GSNumberInfo*)NSZoneMalloc(NSDefaultMallocZone(), + (sizeof(GSNumberInfo))); + info->typeLevel = order; + + info->getValue = (void (*)(NSNumber*, SEL, void*)) + [o methodForSelector: @selector(getValue:)]; + + if (multiThreaded == YES) + { + NSMapTable *table; + + /* + * Memory leak for efficiency - the old map table is never + * deallocated, so we don't have to do any locking. + */ + table = NSCopyMapTableWithZone(numberMap, NSDefaultMallocZone()); + NSMapInsert(table, (void*)c, (void*)info); + numberMap = table; + } + else + { + NSMapInsert(numberMap, (void*)c, (void*)info); + } + } + return info; +} + +unsigned int +GSPrivateSmallHash(int n) +{ + return smallHashes[n + GS_SMALL]; +} + +static Class abstractClass; +static Class boolNumberClass; +static Class charNumberClass; +static Class uCharNumberClass; +static Class shortNumberClass; +static Class uShortNumberClass; +static Class intNumberClass; +static Class uIntNumberClass; +static Class longNumberClass; +static Class uLongNumberClass; +static Class longLongNumberClass; +static Class uLongLongNumberClass; +static Class floatNumberClass; +static Class doubleNumberClass; + ++ (void) _becomeThreaded: (NSNotification*)notification +{ + multiThreaded = YES; +} + (void) initialize { - int i; - - if ([NSNumber class] != self) + if (self == [NSNumber class]) { - return; - } + BOOL boolean; + int integer; + unsigned (*hasher)(NSNumber*, SEL); + GSNumberInfo *info; + CREATE_AUTORELEASE_POOL(pool); - NSNumberClass = self; - NSBoolNumberClass = [NSBoolNumber class]; - NSIntNumberClass = [NSIntNumber class]; - NSLongLongNumberClass = [NSLongLongNumber class]; - NSUnsignedLongLongNumberClass = [NSUnsignedLongLongNumber class]; - NSFloatNumberClass = [NSFloatNumber class]; - NSDoubleNumberClass = [NSDoubleNumber class]; + abstractClass = self; + hasher = (unsigned (*)(NSNumber*, SEL)) + [self instanceMethodForSelector: @selector(hash)]; - boolY = NSAllocateObject (NSBoolNumberClass, 0, 0); - boolY->value = 1; - boolN = NSAllocateObject (NSBoolNumberClass, 0, 0); - boolN->value = 0; + /* + * Create cache for per-subclass method implementations etc. + */ + numberMap = NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks, + NSOwnedPointerMapValueCallBacks, 0); - for (i = 0; i < 14; i++) - { - NSIntNumber *n = NSAllocateObject (NSIntNumberClass, 0, 0); + /* + * cache standard subclass info. + */ + boolNumberClass = [NSBoolNumber class]; + info = GSNumberInfoFromObject(AUTORELEASE([boolNumberClass alloc])); + /* + * Set the typeLevel for a boolean to be '0' + */ + info->typeLevel = 0; + charNumberClass = [NSCharNumber class]; + GSNumberInfoFromObject(AUTORELEASE([charNumberClass alloc])); + uCharNumberClass = [NSUCharNumber class]; + GSNumberInfoFromObject(AUTORELEASE([uCharNumberClass alloc])); + shortNumberClass = [NSShortNumber class]; + GSNumberInfoFromObject(AUTORELEASE([shortNumberClass alloc])); + uShortNumberClass = [NSUShortNumber class]; + GSNumberInfoFromObject(AUTORELEASE([uShortNumberClass alloc])); + intNumberClass = [NSIntNumber class]; + GSNumberInfoFromObject(AUTORELEASE([intNumberClass alloc])); + uIntNumberClass = [NSUIntNumber class]; + GSNumberInfoFromObject(AUTORELEASE([uIntNumberClass alloc])); + longNumberClass = [NSLongNumber class]; + GSNumberInfoFromObject(AUTORELEASE([longNumberClass alloc])); + uLongNumberClass = [NSULongNumber class]; + GSNumberInfoFromObject(AUTORELEASE([uLongNumberClass alloc])); + longLongNumberClass = [NSLongLongNumber class]; + GSNumberInfoFromObject(AUTORELEASE([longLongNumberClass alloc])); + uLongLongNumberClass = [NSULongLongNumber class]; + GSNumberInfoFromObject(AUTORELEASE([uLongLongNumberClass alloc])); + floatNumberClass = [NSFloatNumber class]; + GSNumberInfoFromObject(AUTORELEASE([floatNumberClass alloc])); + doubleNumberClass = [NSDoubleNumber class]; + GSNumberInfoFromObject(AUTORELEASE([doubleNumberClass alloc])); - n->value = i - 1; - ReusedInstances[i] = n; + /* + * cache bool values. + */ + boolN = (NSNumber*)NSAllocateObject([GSCachedBool class], 0, + NSDefaultMallocZone()); + boolean = NO; + boolN = [boolN initWithBytes: &boolean objCType: NULL]; + + boolY = (NSNumber*)NSAllocateObject([GSCachedBool class], 0, + NSDefaultMallocZone()); + boolean = YES; + boolY = [boolY initWithBytes: &boolean objCType: NULL]; + + /* + * cache small integer values. + */ + for (integer = -GS_SMALL; integer <= GS_SMALL; integer++) + { + NSNumber *num; + + num = (NSNumber*)NSAllocateObject([GSCachedInt class], 0, + NSDefaultMallocZone()); + num = [num initWithBytes: &integer objCType: NULL]; + smallIntegers[integer + GS_SMALL] = num; + smallHashes[integer + GS_SMALL] = (*hasher)(num, @selector(hash)); + } + + /* + * Make sure we know if we are multi-threaded so that if the caches + * need to grow, we do it by copying and replacing without deleting + * an old cache that may be in use by another thread. + */ + if ([NSThread isMultiThreaded]) + { + [self _becomeThreaded: nil]; + } + else + { + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(_becomeThreaded:) + name: NSWillBecomeMultiThreadedNotification + object: nil]; + } + RELEASE(pool); } } -- (const char *) objCType +/* Returns the concrete class associated with the type encoding. Note + that we don't allow NSNumber to instantiate any class but its own + concrete subclasses (see check at end of method) */ ++ (Class) valueClassWithObjCType: (const char*)type { - /* All concrete NSNumber types must implement this so we know which one - * they are. - */ - [self subclassResponsibility: _cmd]; - return NULL; // Not reached -} + Class theClass = Nil; -- (BOOL) isEqualToNumber: (NSNumber*)aNumber -{ - return ([self compare: aNumber] == NSOrderedSame) ? YES : NO; -} - -- (BOOL) isEqual: (id)anObject -{ - if ([anObject isKindOfClass: NSNumberClass]) + switch (*type) { - return [self isEqualToNumber: anObject]; + case _C_CHR: return charNumberClass; + case _C_UCHR: return uCharNumberClass; + case _C_SHT: return shortNumberClass; + case _C_USHT: return uShortNumberClass; + case _C_INT: return intNumberClass; + case _C_UINT: return uIntNumberClass; + case _C_LNG: return longNumberClass; + case _C_ULNG: return uLongNumberClass; +#ifdef _C_LNGLNG + case _C_LNGLNG: +#else + case 'q': +#endif + return longLongNumberClass; +#ifdef _C_ULNGLNG + case _C_ULNGLNG: +#else + case 'Q': +#endif + return uLongLongNumberClass; + case _C_FLT: return floatNumberClass; + case _C_DBL: return doubleNumberClass; + default: + break; } - return [super isEqual: anObject]; + + if (theClass == Nil && self == abstractClass) + { + [NSException raise: NSInvalidArgumentException + format: @"Invalid number type"]; + /* NOT REACHED */ + } + else if (theClass == Nil) + { + theClass = [super valueClassWithObjCType: type]; + } + return theClass; } -- (BOOL) isEqualToValue: (NSValue*)aValue ++ (NSNumber*) numberWithBool: (BOOL)value { - if ([aValue isKindOfClass: NSNumberClass]) + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) { - return [self isEqualToNumber: (NSNumber*)aValue]; + if (value == NO) + { + return boolN; + } + else + { + return boolY; + } + } + else // alloc class and init with object intWithXX method + { + return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] + initWithBool: value]); + } +} + ++ (NSNumber*) numberWithChar: (signed char)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(charNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithChar: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithDouble: (double)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + theObj = (NSNumber*)NSAllocateObject(doubleNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithDouble: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithFloat: (float)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + theObj = (NSNumber*)NSAllocateObject(floatNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithFloat: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithInt: (signed int)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(intNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithInt: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithLong: (signed long)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(longNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithLong: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithLongLong: (signed long long)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(longLongNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithLongLong: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithShort: (signed short)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(shortNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithShort: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithUnsignedChar: (unsigned char)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(uCharNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithUnsignedChar: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithUnsignedInt: (unsigned int)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(uIntNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithUnsignedInt: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithUnsignedLong: (unsigned long)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(uLongNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithUnsignedLong: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithUnsignedLongLong: (unsigned long long)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(uLongLongNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithUnsignedLongLong: value]; + } + + return AUTORELEASE(theObj); +} + ++ (NSNumber*) numberWithUnsignedShort: (unsigned short)value +{ + NSNumber *theObj = nil; + + // if class is NSNumber, replace by appropriate object + if (self == abstractClass) + { + if (value <= GS_SMALL) + { + return smallIntegers[value + GS_SMALL]; + } + theObj = (NSNumber*)NSAllocateObject(uShortNumberClass, 0, + NSDefaultMallocZone()); + theObj = [theObj initWithBytes: &value objCType: NULL]; + } + else // alloc class and init with object intWithXX method + { + theObj = [[self allocWithZone: NSDefaultMallocZone()] + initWithUnsignedShort: value]; + } + + return AUTORELEASE(theObj); +} + +/* + * A moderately sane default init method - a zero value integer. + */ +- (id) init +{ + return [self initWithInt: 0]; +} + +- (id) initWithBool: (BOOL)value +{ + RELEASE(self); + if (value == NO) + { + self = boolN; + } + else + { + self = boolY; + } + return RETAIN(self); +} + +- (id) initWithChar: (signed char)value +{ + RELEASE(self); + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(charNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithDouble: (double)value +{ + RELEASE(self); + self = (NSNumber*)NSAllocateObject(doubleNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithFloat: (float)value +{ + RELEASE(self); + self = (NSNumber*)NSAllocateObject(floatNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithInt: (signed int)value +{ + RELEASE(self); + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(intNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithLong: (signed long)value +{ + RELEASE(self); + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(longNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithLongLong: (signed long long)value +{ + RELEASE(self); + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(longLongNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithShort: (signed short)value +{ + RELEASE(self); + if (value <= GS_SMALL && value >= -GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(shortNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithUnsignedChar: (unsigned char)value +{ + RELEASE(self); + if (value <= GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(uCharNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithUnsignedInt: (unsigned int)value +{ + RELEASE(self); + if (value <= GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(uIntNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithUnsignedLong: (unsigned long)value +{ + RELEASE(self); + if (value <= GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(uLongNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithUnsignedLongLong: (unsigned long long)value +{ + RELEASE(self); + if (value <= GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(uLongLongNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) initWithUnsignedShort: (unsigned short)value +{ + RELEASE(self); + if (value <= GS_SMALL) + { + return RETAIN(smallIntegers[value + GS_SMALL]); + } + self = (NSNumber*)NSAllocateObject(uShortNumberClass, 0, + NSDefaultMallocZone()); + self = [self initWithBytes: &value objCType: NULL]; + return self; +} + +- (id) copyWithZone: (NSZone*)zone +{ + if (NSShouldRetainWithZone(self, zone)) + return RETAIN(self); + else + return NSCopyObject(self, 0, zone); +} + +- (NSString*) description +{ + return [self descriptionWithLocale: nil]; +} + +- (NSString*) descriptionWithLocale: (NSDictionary*)locale +{ + NSString *result = nil; + + if (GSObjCClass(self) == abstractClass) + { + [NSException raise: NSInternalInconsistencyException + format: @"descriptionWithLocale: for abstract NSNumber"]; + } + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + return [self boolValue] ? @"1" : @"0"; + break; + + case 1: + result = [[NSString alloc] initWithFormat: @"%i" locale: locale, + (int)[self charValue]]; + break; + + case 2: + result = [[NSString alloc] initWithFormat: @"%u" locale: locale, + (unsigned int)[self unsignedCharValue]]; + break; + + case 3: + result = [[NSString alloc] initWithFormat: @"%hi" locale: locale, + [self shortValue]]; + break; + + case 4: + result = [[NSString alloc] initWithFormat: @"%hu" locale: locale, + [self unsignedShortValue]]; + break; + + case 5: + result = [[NSString alloc] initWithFormat: @"%i" locale: locale, + [self intValue]]; + break; + + case 6: + result = [[NSString alloc] initWithFormat: @"%u" locale: locale, + [self unsignedIntValue]]; + break; + + case 7: + result = [[NSString alloc] initWithFormat: @"%li" locale: locale, + [self longValue]]; + break; + + case 8: + result = [[NSString alloc] initWithFormat: @"%lu" locale: locale, + [self unsignedLongValue]]; + break; + + case 9: + result = [[NSString alloc] initWithFormat: @"%lli" locale: locale, + [self longLongValue]]; + break; + + case 10: + result = [[NSString alloc] initWithFormat: @"%llu" locale: locale, + [self unsignedLongLongValue]]; + break; + + case 11: + result = [[NSString alloc] initWithFormat: @"%0.7g" locale: locale, + (double)[self floatValue]]; + break; + + case 12: + result = [[NSString alloc] initWithFormat: @"%0.16g" locale: locale, + [self doubleValue]]; + break; + + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for description"]; + } + } + return AUTORELEASE(result); +} + +/* All the rest of these methods must be implemented by a subclass */ +- (BOOL) boolValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get boolValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return (oData == 0) ? NO : YES; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } } return NO; } -- (NSUInteger) hash +- (signed char) charValue { - return (unsigned)[self doubleValue]; + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get charValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (double) doubleValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get doubleValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (float) floatValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get floatValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (signed int) intValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get intValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (signed long long) longLongValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get longLongValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (signed long) longValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get longValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (signed short) shortValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get shortValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; } - (NSString*) stringValue @@ -399,366 +1785,713 @@ static NSBoolNumber *boolN; // Boolean NO (integer 0) return [self descriptionWithLocale: nil]; } -- (NSString*) descriptionWithLocale: (id)aLocale +- (unsigned char) unsignedCharValue { - [self subclassResponsibility: _cmd]; - return nil; // Not reached + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get unsignedCharrValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; } -- (NSComparisonResult) compare: (NSNumber*)aNumber +- (unsigned int) unsignedIntValue { - [self subclassResponsibility: _cmd]; - return 0; // Not reached + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get unsignedIntValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; } -#define INTEGER_MACRO(type, ignored, name) \ -- (id) initWith ## name: (type)aValue \ -{\ - DESTROY(self);\ - return [[NSNumberClass numberWith ## name: aValue] retain];\ +- (unsigned long long) unsignedLongLongValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get unsignedLongLongValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; } -#include "GSNumberTypes.h" - -- (id) initWithBool: (BOOL)aValue +- (unsigned long) unsignedLongValue { - DESTROY(self); - return [(aValue == 0 ? boolN : boolY) retain];\ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get unsignedLongValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (unsigned short) unsignedShortValue +{ + if (GSObjCClass(self) == abstractClass) + [NSException raise: NSInternalInconsistencyException + format: @"get unsignedShortValue from abstract NSNumber"]; + else + { + GSNumberInfo *info = GSNumberInfoFromObject(self); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 1: + { + signed char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 3: + { + signed short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 5: + { + signed int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 7: + { + signed long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 11: + { + float oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + case 12: + { + double oData; + + (*(info->getValue))(self, @selector(getValue:), &oData); + return oData; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"unknown number type value for get"]; + } + } + return 0; +} + +- (NSComparisonResult) compare: (NSNumber*)other +{ + double otherValue; + double myValue; + + if (other == self) + { + return NSOrderedSame; + } + else if (other == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; + } + + myValue = [self doubleValue]; + otherValue = [other doubleValue]; + + if (myValue == otherValue) + { + return NSOrderedSame; + } + else if (myValue < otherValue) + { + return NSOrderedAscending; + } + else + { + return NSOrderedDescending; + } } /* - * Macro for checking whether this value is the same as one of the singleton - * instances. + * Because of the rule that two numbers which are the same according to + * [-isEqual: ] must generate the same hash, we must generate the hash + * from the most general representation of the number. + * NB. Don't change this without changing the matching function in + * NSConcreteNumber.m */ -#define CHECK_SINGLETON(aValue) \ -if (aValue >= -1 && aValue <= 12)\ -{\ - return ReusedInstances[aValue+1];\ -} - -+ (NSNumber *) numberWithBool: (BOOL)aValue +- (unsigned) hash { - if (self != NSNumberClass) + union { + double d; + unsigned char c[sizeof(double)]; + } val; + unsigned hash = 0; + unsigned i; + + val.d = [self doubleValue]; + for (i = 0; i < sizeof(double); i++) { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(BOOL)] autorelease]; + hash = (hash << 5) + hash + val.c[i]; } - if (0 == aValue) + return hash; +} + +- (BOOL) isEqual: (id)o +{ + if (o == self) { - return boolN; + return YES; } - return boolY; -} - -+ (NSNumber *) numberWithChar: (signed char)aValue -{ - if (self != NSNumberClass) + else if (o == nil) { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(char)] autorelease]; + return NO; } - return [self numberWithInt: aValue]; -} - -+ (NSNumber *) numberWithUnsignedChar: (unsigned char)aValue -{ - if (self != NSNumberClass) + else if (GSObjCIsInstance(o) == YES + && GSObjCIsKindOf(GSObjCClass(o), abstractClass)) { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(unsigned char)] autorelease]; + return [self isEqualToNumber: (NSNumber*)o]; } - return [self numberWithInt: aValue]; -} - -+ (NSNumber *) numberWithShort: (short)aValue -{ - if (self != NSNumberClass) + else { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(short)] autorelease]; + return [super isEqual: o]; } - return [self numberWithInt: aValue]; } -+ (NSNumber *) numberWithUnsignedShort: (unsigned short)aValue +- (BOOL) isEqualToNumber: (NSNumber*)o { - if (self != NSNumberClass) + if (o == self) { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(unsigned short)] autorelease]; + return YES; } - return [self numberWithInt: aValue]; -} - -+ (NSNumber *) numberWithInt: (int)aValue -{ - NSIntNumber *n; - - if (self != NSNumberClass) + else if (o == nil) { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(int)] autorelease]; + return NO; } - - CHECK_SINGLETON (aValue); - n = NSAllocateObject (NSIntNumberClass, 0, 0); - n->value = aValue; - return AUTORELEASE(n); -} - -+ (NSNumber *) numberWithUnsignedInt: (unsigned int)aValue -{ - if (self != NSNumberClass) + else if ([self compare: o] == NSOrderedSame) { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(unsigned int)] autorelease]; + return YES; } - - CHECK_SINGLETON (aValue); - if (aValue < (unsigned int) INT_MAX) - { - return [self numberWithInt: (int)aValue]; - } - return [self numberWithLongLong: aValue]; -} - -+ (NSNumber *) numberWithLong: (long)aValue -{ - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(long)] autorelease]; - } - return [self numberWithLongLong: aValue]; -} - -+ (NSNumber *) numberWithUnsignedLong: (unsigned long)aValue -{ - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(unsigned long)] autorelease]; - } - return [self numberWithUnsignedLongLong: aValue]; -} - -+ (NSNumber *) numberWithLongLong: (long long)aValue -{ - NSLongLongNumber *n; - - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(long long)] autorelease]; - } - CHECK_SINGLETON (aValue); - if (aValue < (long long)INT_MAX && aValue > (long long)INT_MIN) - { - return [self numberWithInt: (int) aValue]; - } - n = NSAllocateObject (NSLongLongNumberClass, 0, 0); - n->value = aValue; - return AUTORELEASE(n); -} - -+ (NSNumber *) numberWithUnsignedLongLong: (unsigned long long)aValue -{ - NSUnsignedLongLongNumber *n; - - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(unsigned long long)] autorelease]; - } - if (aValue < (unsigned long long) LLONG_MAX) - { - return [self numberWithLongLong: (long long) aValue]; - } - n = NSAllocateObject (NSUnsignedLongLongNumberClass, 0, 0); - n->value = aValue; - return AUTORELEASE(n); -} - -+ (NSNumber *) numberWithFloat: (float)aValue -{ - NSFloatNumber *n; - - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(float)] autorelease]; - } - n = NSAllocateObject (NSFloatNumberClass, 0, 0); - n->value = aValue; - return AUTORELEASE(n); -} - -+ (NSNumber *) numberWithDouble: (double)aValue -{ - NSDoubleNumber *n; - - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(double)] autorelease]; - } - n = NSAllocateObject (NSDoubleNumberClass, 0, 0); - n->value = aValue; - return AUTORELEASE(n); -} - -+ (NSNumber *) numberWithInteger: (NSInteger)aValue -{ - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(NSInteger)] autorelease]; - } - // Compile time constant; the compiler will remove this conditional - if (sizeof (NSInteger) == sizeof (int)) - { - return [self numberWithInt: aValue]; - } - return [self numberWithLongLong: aValue]; -} - -+ (NSNumber *) numberWithUnsignedInteger: (NSUInteger)aValue -{ - if (self != NSNumberClass) - { - return [[[self alloc] initWithBytes: (const void *)&aValue - objCType: @encode(NSUInteger)] autorelease]; - } - // Compile time constant; the compiler will remove this conditional - if (sizeof (NSUInteger) == sizeof (unsigned int)) - { - return [self numberWithUnsignedInt: aValue]; - } - return [self numberWithUnsignedLongLong: aValue]; -} - -- (id) initWithBytes: (const void *) - value objCType: (const char *)type -{ - switch (type[0]) - { - case 'c': - return [self initWithInteger: *(char *) value]; - case 'C': - return [self initWithInteger: *(unsigned char *) value]; - case 's': - return [self initWithInteger: *(short *) value]; - case 'S': - return [self initWithInteger: *(unsigned short *) value]; - case 'i': - return [self initWithInteger: *(int *) value]; - case 'I': - return [self initWithInteger: *(unsigned int *) value]; - case 'l': - return [self initWithLong: *(long *) value]; - case 'L': - return [self initWithUnsignedLong: *(unsigned long *) value]; - case 'q': - return [self initWithLongLong: *(long long *) value]; - case 'Q': - return [self initWithUnsignedLongLong: *(unsigned long long *) value]; - case 'f': - return [self initWithFloat: *(float *) value]; - case 'd': - return [self initWithDouble: *(double *) value]; - } - return [super initWithBytes: value objCType: type]; -} - -- (void *) pointerValue -{ - return (void *)[self unsignedIntegerValue]; -} - -- (id) replacementObjectForPortCoder: (NSPortCoder *) encoder -{ - return self; -} - -- (Class) classForCoder -{ - return NSNumberClass; -} - -- (void) encodeWithCoder: (NSCoder *) coder -{ - const char *type = [self objCType]; - char buffer[16]; - - [coder encodeValueOfObjCType: @encode (char) at: type]; - /* The most we currently store in an NSNumber is 8 bytes (double or long - * long), but we may add support for vectors or long doubles in future, so - * make this 16 bytes now so stuff doesn't break in fun and exciting ways - * later. - */ - [self getValue: buffer]; - [coder encodeValueOfObjCType: type at: buffer]; -} - -- (id) copyWithZone: (NSZone *) aZone -{ - // OSX just returns the receive with no copy. - return RETAIN (self); -} - -- (id) initWithCoder: (NSCoder *) coder -{ - char type[2] = { 0 }; - char buffer[16]; - - [coder decodeValueOfObjCType: @encode (char) at: type]; - [coder decodeValueOfObjCType: type at: buffer]; - return [self initWithBytes: buffer objCType: type]; -} - -- (NSString *) description -{ - return [self stringValue]; -} - -/* Return nil for an NSNumber that is allocated and initalized without - * providing a real value. Yes, this seems weird, but it is actually what - * happens on OS X. - */ -- (id) init -{ - DESTROY(self); - return nil; -} - -/* Stop the compiler complaining about unimplemented methods. Throwing an - * exception here matches OS X behaviour, although they throw an invalid - * argument exception. - */ -#define INTEGER_MACRO(type, name, ignored) \ -- (type) name ## Value\ -{\ - [self subclassResponsibility: _cmd];\ - return (type)0;\ -} - -#include "GSNumberTypes.h" - -- (BOOL) boolValue -{ - [self subclassResponsibility: _cmd]; return NO; } -- (NSDecimal) decimalValue -{ - NSDecimalNumber *dn; - NSDecimal decimal; +/* + * NSCoding + */ - dn = [[NSDecimalNumber alloc] initWithString: [self stringValue]]; - decimal = [dn decimalValue]; - [dn release]; - return decimal; +- (Class) classForCoder +{ + return abstractClass; } +- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder +{ + if ([aCoder isByref] == NO) + return self; + return [super replacementObjectForPortCoder: aCoder]; +} + +- (void) encodeWithCoder: (NSCoder*)coder +{ + const char *t = [self objCType]; + + [coder encodeValueOfObjCType: @encode(signed char) at: t]; + [coder encodeValueOfObjCType: t at: [self pointerValue]]; +} + +- (id) initWithCoder: (NSCoder*)coder +{ + char t[2]; + union { + signed char c; + unsigned char C; + signed short s; + unsigned short S; + signed int i; + unsigned int I; + signed long l; + unsigned long L; + signed long long q; + unsigned long long Q; + float f; + double d; + } data; + + [coder decodeValueOfObjCType: @encode(signed char) at: t]; + t[1] = '\0'; + [coder decodeValueOfObjCType: t at: &data]; + switch (*t) + { + case 'c': self = [self initWithChar: data.c]; break; + case 'C': self = [self initWithUnsignedChar: data.C]; break; + case 's': self = [self initWithShort: data.s]; break; + case 'S': self = [self initWithUnsignedShort: data.S]; break; + case 'i': self = [self initWithInt: data.i]; break; + case 'I': self = [self initWithUnsignedInt: data.I]; break; + case 'l': self = [self initWithLong: data.l]; break; + case 'L': self = [self initWithUnsignedLong: data.L]; break; + case 'q': self = [self initWithLongLong: data.q]; break; + case 'Q': self = [self initWithUnsignedLongLong: data.Q]; break; + case 'f': self = [self initWithFloat: data.f]; break; + case 'd': self = [self initWithDouble: data.d]; break; + default: + DESTROY(self); + NSLog(@"Attempt to decode number with unknown ObjC type"); + } + return self; +} @end diff --git a/Source/NSNumberFormatter.m b/Source/NSNumberFormatter.m index 5a73f79dc..0a1a47ed3 100644 --- a/Source/NSNumberFormatter.m +++ b/Source/NSNumberFormatter.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,17 +27,14 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSNumberFormatter_IVARS 1 -#import "Foundation/NSAttributedString.h" -#import "Foundation/NSDecimalNumber.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSNumberFormatter.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSCharacterSet.h" - -#import "GNUstepBase/GSLocale.h" +#include "Foundation/NSAttributedString.h" +#include "Foundation/NSDecimalNumber.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSException.h" +#include "Foundation/NSNumberFormatter.h" +#include "Foundation/NSString.h" +#include "Foundation/NSUserDefaults.h" +#include "Foundation/NSCharacterSet.h" @implementation NSNumberFormatter @@ -103,17 +100,17 @@ { NSNumberFormatter *c = (NSNumberFormatter*) NSCopyObject(self, 0, zone); - IF_NO_GC(RETAIN(c->_negativeFormat);) - IF_NO_GC(RETAIN(c->_positiveFormat);) - IF_NO_GC(RETAIN(c->_attributesForPositiveValues);) - IF_NO_GC(RETAIN(c->_attributesForNegativeValues);) - IF_NO_GC(RETAIN(c->_maximum);) - IF_NO_GC(RETAIN(c->_minimum);) - IF_NO_GC(RETAIN(c->_roundingBehavior);) - IF_NO_GC(RETAIN(c->_roundingBehavior);) - IF_NO_GC(RETAIN(c->_attributedStringForNil);) - IF_NO_GC(RETAIN(c->_attributedStringForNotANumber);) - IF_NO_GC(RETAIN(c->_attributedStringForZero);) + RETAIN(c->_negativeFormat); + RETAIN(c->_positiveFormat); + RETAIN(c->_attributesForPositiveValues); + RETAIN(c->_attributesForNegativeValues); + RETAIN(c->_maximum); + RETAIN(c->_minimum); + RETAIN(c->_roundingBehavior); + RETAIN(c->_roundingBehavior); + RETAIN(c->_attributedStringForNil); + RETAIN(c->_attributedStringForNotANumber); + RETAIN(c->_attributedStringForZero); return c; } @@ -518,7 +515,7 @@ NSString *prefix; NSString *suffix; NSString *wholeString; - NSString *fracPad = nil; + NSString *fracPad; NSString *fracPartString; NSMutableString *intPartString; NSMutableString *formattedNumber; @@ -537,26 +534,7 @@ BOOL displayFractionalPart = NO; BOOL negativeNumber = NO; NSString *useFormat; - NSString *defaultDecimalSeparator = nil; - NSString *defaultThousandsSeparator = nil; - if (_localizesFormat) - { - NSDictionary *defaultLocale = GSDomainFromDefaultLocale(); - defaultDecimalSeparator - = [defaultLocale objectForKey: NSDecimalSeparator]; - defaultThousandsSeparator - = [defaultLocale objectForKey: NSThousandsSeparator]; - } - - if (defaultDecimalSeparator == nil) - { - defaultDecimalSeparator = @"."; - } - if (defaultThousandsSeparator == nil) - { - defaultThousandsSeparator = @","; - } formattingCharacters = [NSCharacterSet characterSetWithCharactersInString: @"0123456789#.,_"]; placeHolders = [NSCharacterSet @@ -568,8 +546,7 @@ return [[self attributedStringForNotANumber] string]; if ([anObject isEqual: [NSDecimalNumber notANumber]]) return [[self attributedStringForNotANumber] string]; - if (_attributedStringForZero - && [anObject isEqual: [NSDecimalNumber zero]]) + if ([anObject isEqual: [NSDecimalNumber zero]]) return [[self attributedStringForZero] string]; useFormat = _positiveFormat; @@ -583,10 +560,7 @@ // if no format specified, use the same default that Cocoa does if (nil == useFormat) { - useFormat = [NSString stringWithFormat: @"%@#%@###%@##", - negativeNumber ? @"-" : @"", - defaultThousandsSeparator, - defaultDecimalSeparator]; + useFormat = negativeNumber ? @"-#,###.##" : @"#,###.##"; } prefixRange = [useFormat rangeOfCharacterFromSet: formattingCharacters]; @@ -606,16 +580,15 @@ //should also set NSDecimalDigits? if ([self hasThousandSeparators] - && (0 != [useFormat rangeOfString: defaultThousandsSeparator].length)) + && (0 != [useFormat rangeOfString:@","].length)) { displayThousandsSeparators = YES; } if ([self allowsFloats] - && (NSNotFound - != [useFormat rangeOfString: defaultDecimalSeparator].location)) + && (NSNotFound != [useFormat rangeOfString:@"." ].location)) { - decimalPlaceRange = [useFormat rangeOfString: defaultDecimalSeparator + decimalPlaceRange = [useFormat rangeOfString: @"." options: NSBackwardsSearch]; if (NSMaxRange(decimalPlaceRange) == [useFormat length]) { @@ -651,7 +624,7 @@ roundedNumber = [roundedNumber decimalNumberByMultiplyingBy: (NSDecimalNumber*)[NSDecimalNumber numberWithInt: -1]]; intPart = (NSDecimalNumber*) - [NSDecimalNumber numberWithInt: (int)[roundedNumber doubleValue]]; + [NSDecimalNumber numberWithInt: [roundedNumber intValue]]; fracPart = [roundedNumber decimalNumberBySubtracting: intPart]; intPartString = AUTORELEASE([[intPart descriptionWithLocale: locale] mutableCopy]); @@ -663,15 +636,14 @@ while (([placeHolders characterIsMember: [useFormat characterAtIndex: NSMaxRange(intPartRange)]] || [[useFormat substringFromRange: - NSMakeRange(NSMaxRange(intPartRange), 1)] isEqual: - defaultThousandsSeparator]) + NSMakeRange(NSMaxRange(intPartRange), 1)] isEqual: @","]) && NSMaxRange(intPartRange) < [useFormat length] - 1) { intPartRange.length++; } } intPad = [[useFormat substringWithRange: intPartRange] mutableCopy]; - [intPad replaceOccurrencesOfString: defaultThousandsSeparator + [intPad replaceOccurrencesOfString: @"," withString: @"" options: 0 range: NSMakeRange(0, [intPad length])]; @@ -784,20 +756,4 @@ return [NSString stringWithCharacters: &_thousandSeparator length: 1]; } -- (NSString *) stringFromNumber: (NSNumber *)number -{ - return [self stringForObjectValue: number]; -} - -- (NSNumber *) numberFromString: (NSString *)string -{ - id number = nil; - NSString *error; - - [self getObjectValue: &number - forString: string - errorDescription: &error]; - - return number; -} @end diff --git a/Source/NSNumberMethods.h b/Source/NSNumberMethods.h deleted file mode 100644 index 325175d17..000000000 --- a/Source/NSNumberMethods.h +++ /dev/null @@ -1,25 +0,0 @@ -#define INTEGER_MACRO(type, name, ignored) \ -- (type) name ## Value\ -{\ - return (type)VALUE;\ -} -#include "GSNumberTypes.h" -- (BOOL) boolValue -{ - return (VALUE == 0) ? NO : YES; -} -- (const char *) objCType -{ - return @encode(typeof(VALUE)); -} -- (NSString*) descriptionWithLocale: (id)aLocale -{ - return [[[NSString alloc] initWithFormat: FORMAT - locale: aLocale, VALUE] autorelease]; -} -- (void) getValue: (void*)buffer -{ - typeof(VALUE) *ptr = buffer; - *ptr = VALUE; -} -#undef FORMAT diff --git a/Source/NSObjCRuntime.m b/Source/NSObjCRuntime.m index 3756845a1..420398935 100644 --- a/Source/NSObjCRuntime.m +++ b/Source/NSObjCRuntime.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,56 +25,28 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSException.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSException.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSString.h" +#include #include /** - * Returns a string object containing the name for - * aProtocol. If aProtocol is 0, returns nil. - */ -NSString * -NSStringFromProtocol(Protocol *aProtocol) -{ - if (aProtocol != (Protocol*)0) - return [NSString stringWithUTF8String: (const char*)[aProtocol name]]; - return nil; -} - -/** - * Returns the protocol whose name is supplied in the - * aProtocolName argument, or 0 if a nil string is supplied. - */ -Protocol * -NSProtocolFromString(NSString *aProtocolName) -{ - if (aProtocolName != nil) - { - int len = [aProtocolName length]; - char buf[len+1]; - - [aProtocolName getCString: buf - maxLength: len + 1 - encoding: NSASCIIStringEncoding]; - return GSProtocolFromName (buf); - } - return (Protocol*)0; -} - -/** - * Returns a string object containing the name for + * Returns a string object containing the method name for * aSelector. If aSelector is 0, returns nil. */ NSString * NSStringFromSelector(SEL aSelector) { if (aSelector != (SEL)0) - return [NSString stringWithUTF8String: sel_getName(aSelector)]; + return [NSString stringWithUTF8String: GSNameFromSelector(aSelector)]; return nil; } /** - * Returns (creating if necessary) the selector whose name is supplied in the + * Returns a selector for the method whose name is supplied in the * aSelectorName argument, or 0 if a nil string is supplied. */ SEL @@ -88,7 +60,7 @@ NSSelectorFromString(NSString *aSelectorName) [aSelectorName getCString: buf maxLength: len + 1 encoding: NSASCIIStringEncoding]; - return sel_registerName (buf); + return GSSelectorFromName (buf); } return (SEL)0; } @@ -108,7 +80,7 @@ NSClassFromString(NSString *aClassName) [aClassName getCString: buf maxLength: len + 1 encoding: NSASCIIStringEncoding]; - return objc_lookUpClass (buf); + return GSClassFromName (buf); } return (Class)0; } @@ -121,7 +93,7 @@ NSString * NSStringFromClass(Class aClass) { if (aClass != (Class)0) - return [NSString stringWithUTF8String: (char*)class_getName(aClass)]; + return [NSString stringWithUTF8String: (char*)GSNameFromClass(aClass)]; return nil; } @@ -129,38 +101,19 @@ NSStringFromClass(Class aClass) * When provided with a C string containing encoded type information, * this method extracts size and alignment information for the specified * type into the buffers pointed to by sizep and alignp.
- * If either sizep or alignp is a null pointer, the corresponding data is + * If either sizep or alignp is a nil pointer, the corresponding data is * not extracted.
- * The function returns a pointer into the type information C string - * immediately after the decoded information. + * The function returns a pointer to the type information C string. */ const char * -NSGetSizeAndAlignment(const char *typePtr, - NSUInteger *sizep, NSUInteger *alignp) +NSGetSizeAndAlignment(const char *typePtr, unsigned *sizep, unsigned *alignp) { - if (typePtr != NULL) - { - /* Skip any offset, but don't call objc_skip_offset() as that's buggy. - */ - if (*typePtr == '+' || *typePtr == '-') - { - typePtr++; - } - while (isdigit(*typePtr)) - { - typePtr++; - } - typePtr = objc_skip_type_qualifiers (typePtr); - if (sizep) - { - *sizep = objc_sizeof_type (typePtr); - } - if (alignp) - { - *alignp = objc_alignof_type (typePtr); - } - typePtr = objc_skip_typespec (typePtr); - } + NSArgumentInfo info; + typePtr = mframe_next_arg(typePtr, &info); + if (sizep) + *sizep = info.size; + if (alignp) + *alignp = info.align; return typePtr; } diff --git a/Source/NSObject+NSComparisonMethods.m b/Source/NSObject+NSComparisonMethods.m deleted file mode 100644 index 4e4ba0cdb..000000000 --- a/Source/NSObject+NSComparisonMethods.m +++ /dev/null @@ -1,100 +0,0 @@ -/** Implementation of NSObject+NSComparisonMethods for GNUStep - Copyright (C) 2008 Free Software Foundation, Inc. - - Written by: Gregory Casamento - Date: 2008 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - - NSObject+NSComparisonMethods category reference - $Date: 2008-11-26 04:20:34 -0500 (Wed, 26 Nov 2008) $ $Revision: 27135 $ -*/ - -#import "common.h" -#import "Foundation/NSArray.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" - -@interface NSObject (NSComparisonMethods) -- (BOOL) doesContain: (id) object; -- (BOOL) isCaseInsensitiveLike: (id) object; -- (BOOL) isEqualTo: (id) object; -- (BOOL) isGreaterThan: (id) object; -- (BOOL) isGreaterThanOrEqualTo: (id) object; -- (BOOL) isLessThan: (id) object; -- (BOOL) isLessThanOrEqualTo: (id) object; -- (BOOL) isLike: (NSString *)object; -- (BOOL) isNotEqualTo: (id) object; -@end - -@implementation NSObject (NSComparisonMethods) -- (BOOL) doesContain: (id) object -{ - if (object) - { - if ([self isKindOfClass: [NSArray class]]) - { - [(NSArray *)self containsObject: object]; - } - } - return NO; -} - -- (BOOL) isCaseInsensitiveLike: (id) object -{ - NSLog(@"%@ not implemented yet", NSStringFromSelector(_cmd)); - return NO; -} - -- (BOOL) isEqualTo: (id) object -{ - return [self isEqual: object]; -} - -- (BOOL) isGreaterThan: (id) object -{ - return ([self compare: object] == NSOrderedDescending); -} - -- (BOOL) isGreaterThanOrEqualTo: (id) object -{ - return ([self compare: object] == NSOrderedDescending || - [self compare: object] == NSOrderedSame); -} - -- (BOOL) isLessThan: (id) object -{ - return ([self compare: object] == NSOrderedAscending); -} - -- (BOOL) isLessThanOrEqualTo: (id) object -{ - return ([self compare: object] == NSOrderedAscending || - [self compare: object] == NSOrderedSame); -} - -- (BOOL) isLike: (NSString *)object -{ - NSLog(@"%@ not implemented yet", NSStringFromSelector(_cmd)); - return NO; -} - -- (BOOL) isNotEqualTo: (id) object -{ - return !([self isEqual: object]); -} -@end diff --git a/Source/NSObject.m b/Source/NSObject.m index 648add6ed..ffdd3c9a1 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1,5 +1,5 @@ /** Implementation of NSObject for GNUStep - Copyright (C) 1994-2010 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. Written by: Andrew Kachites McCallum Date: August 1994 @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -28,25 +28,32 @@ /* On some versions of mingw we need to work around bad function declarations * by defining them away and doing the declarations ourself later. */ -#ifndef _WIN64 #define InterlockedIncrement BadInterlockedIncrement #define InterlockedDecrement BadInterlockedDecrement -#endif -#import "common.h" + +#include "config.h" +#include "GNUstepBase/preface.h" +#include +#include "Foundation/NSObject.h" #include -#import "Foundation/NSMethodSignature.h" -#import "Foundation/NSInvocation.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSException.h" -#import "Foundation/NSPortCoder.h" -#import "Foundation/NSDistantObject.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSMapTable.h" -#import "GNUstepBase/GSLocale.h" +#include "Foundation/NSMethodSignature.h" +#include "Foundation/NSInvocation.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSString.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSException.h" +#include "Foundation/NSPortCoder.h" +#include "Foundation/NSDistantObject.h" +#include "Foundation/NSZone.h" +#include "Foundation/NSDebug.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSMapTable.h" +#include +#include "GNUstepBase/GSLocale.h" #ifdef HAVE_LOCALE_H #include #endif @@ -57,11 +64,8 @@ #ifdef HAVE_SYS_SIGNAL_H #include #endif -#ifdef __FreeBSD__ -#include -#endif -#import "GSPrivate.h" +#include "GSPrivate.h" #ifndef NeXT_RUNTIME @@ -87,8 +91,6 @@ static IMP autorelease_imp; #include #include -static SEL finalize_sel; -static IMP finalize_imp; #endif static Class NSConstantStringClass; @@ -106,27 +108,20 @@ static Class NSConstantStringClass; - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector; @end -@interface GSContentAccessingProxy : NSProxy -{ - NSObject *object; -} -- (id) initWithObject: (id)anObject; -@end - /* * allocationLock is needed when running multi-threaded for - * protecting the map table of zombie information. + * protecting the map table of zombie information and for retain + * count protection (when using a map table ... REFCNT_LOCAL is NO) */ -static NSLock *allocationLock; +static objc_mutex_t allocationLock = NULL; BOOL NSZombieEnabled = NO; BOOL NSDeallocateZombies = NO; @class NSZombie; static Class zombieClass; -static NSMapTable *zombieMap; +static NSMapTable zombieMap; -#if !GS_WITH_GC static void GSMakeZombie(NSObject *o) { Class c = ((id)o)->class_pointer; @@ -134,12 +129,17 @@ static void GSMakeZombie(NSObject *o) ((id)o)->class_pointer = zombieClass; if (NSDeallocateZombies == NO) { - [allocationLock lock]; + if (allocationLock != 0) + { + objc_mutex_lock(allocationLock); + } NSMapInsert(zombieMap, (void*)o, (void*)c); - [allocationLock unlock]; + if (allocationLock != 0) + { + objc_mutex_unlock(allocationLock); + } } } -#endif static void GSLogZombie(id o, SEL sel) { @@ -147,19 +147,25 @@ static void GSLogZombie(id o, SEL sel) if (NSDeallocateZombies == NO) { - [allocationLock lock]; + if (allocationLock != 0) + { + objc_mutex_lock(allocationLock); + } c = NSMapGet(zombieMap, (void*)o); - [allocationLock unlock]; + if (allocationLock != 0) + { + objc_mutex_unlock(allocationLock); + } } if (c == 0) { - NSLog(@"Deallocated object (%p) sent %@", + NSLog(@"Deallocated object (0x%x) sent %@", o, NSStringFromSelector(sel)); } else { - NSLog(@"Deallocated %@ (%p) sent %@", - c, o, NSStringFromSelector(sel)); + NSLog(@"Deallocated %@ (0x%x) sent %@", + NSStringFromClass(c), o, NSStringFromSelector(sel)); } if (GSPrivateEnvironmentFlag("CRASH_ON_ZOMBIE", NO) == YES) { @@ -170,12 +176,24 @@ static void GSLogZombie(id o, SEL sel) /* * Reference count and memory management - * Reference counts for object are stored - * with the object. - * The zone in which an object has been - * allocated is stored with the object. + * + * If REFCNT_LOCAL is defined, reference counts for object are stored + * with the object, otherwise they are stored in a global map table + * that has to be protected by mutexes in a multithreraded environment. + * You therefore want REFCNT_LOCAL defined for best performance. + * + * If CACHE_ZONE is defined, the zone in which an object has been + * allocated is stored with the object - this makes lookup of the + * correct zone to free memory very fast. */ + +#if GS_WITH_GC == 0 && !defined(NeXT_RUNTIME) +#define REFCNT_LOCAL 1 +#define CACHE_ZONE 1 +#endif + + /* Now, if we are on a platform where we know how to do atomic * read, increment, and decrement, then we define the GSATOMICREAD * macro and macros or functions to increment/decrement. @@ -190,13 +208,14 @@ static void GSLogZombie(id o, SEL sel) #undef GSATOMICREAD #endif -#if defined(__MINGW__) -#ifndef _WIN64 +#if defined(REFCNT_LOCAL) + +#if defined(__MINGW32__) + #undef InterlockedIncrement #undef InterlockedDecrement LONG WINAPI InterlockedIncrement(LONG volatile *); LONG WINAPI InterlockedDecrement(LONG volatile *); -#endif /* Set up atomic read, increment and decrement for mswindows */ @@ -208,17 +227,10 @@ typedef int32_t volatile *gsatomic_t; #define GSAtomicIncrement(X) InterlockedIncrement((LONG volatile*)X) #define GSAtomicDecrement(X) InterlockedDecrement((LONG volatile*)X) - -#elif defined(__llvm__) || (defined(USE_ATOMIC_BUILDINS) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))) -/* Use the GCC atomic operations with recent GCC versions */ - -typedef int32_t volatile *gsatomic_t; -#define GSATOMICREAD(X) (*(X)) -#define GSAtomicIncrement(X) __sync_fetch_and_add(X, 1) -#define GSAtomicDecrement(X) __sync_fetch_and_sub(X, 1) +#endif -#elif defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) +#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) /* Set up atomic read, increment and decrement for intel style linux */ @@ -229,126 +241,34 @@ typedef int32_t volatile *gsatomic_t; static __inline__ int GSAtomicIncrement(gsatomic_t X) { - __asm__ __volatile__ ( - "lock addl $1, %0" - :"=m" (*X)); - return *X; + int i = 1; + __asm__ __volatile__( + "lock ; xaddl %0, %1;" + :"=r"(i) + :"m"(*X), "0"(i)); + return i + 1; } static __inline__ int GSAtomicDecrement(gsatomic_t X) { - __asm__ __volatile__ ( - "lock subl $1, %0" - :"=m" (*X)); - return *X; + int i = -1; + __asm__ __volatile__( + "lock ; xaddl %0, %1;" + :"=r"(i) + :"m"(*X), "0"(i)); + return i - 1; } -#elif defined(__PPC__) || defined(__POWERPC__) - -typedef int32_t volatile *gsatomic_t; - -#define GSATOMICREAD(X) (*(X)) - -static __inline__ int -GSAtomicIncrement(gsatomic_t X) -{ - int tmp; - __asm__ __volatile__ ( - "0:" - "lwarx %0,0,%1 \n" - "addic %0,%0,1 \n" - "stwcx. %0,0,%1 \n" - "bne- 0b \n" - :"=&r" (tmp) - :"r" (X) - :"cc", "memory"); - return *X; -} - -static __inline__ int -GSAtomicDecrement(gsatomic_t X) -{ - int tmp; - __asm__ __volatile__ ( - "0:" - "lwarx %0,0,%1 \n" - "addic %0,%0,-1 \n" - "stwcx. %0,0,%1 \n" - "bne- 0b \n" - :"=&r" (tmp) - :"r" (X) - :"cc", "memory"); - return *X; -} - -#elif defined(__m68k__) - -typedef int32_t volatile *gsatomic_t; - -#define GSATOMICREAD(X) (*(X)) - -static __inline__ int -GSAtomicIncrement(gsatomic_t X) -{ - __asm__ __volatile__ ( - "addq%.l %#1, %0" - :"=m" (*X)); - return *X; -} - -static __inline__ int -GSAtomicDecrement(gsatomic_t X) -{ - __asm__ __volatile__ ( - "subq%.l %#1, %0" - :"=m" (*X)); - return *X; -} - -#elif defined(__mips__) - -typedef int32_t volatile *gsatomic_t; - -#define GSATOMICREAD(X) (*(X)) - -static __inline__ int -GSAtomicIncrement(gsatomic_t X) -{ - int tmp; - - __asm__ __volatile__ ( - " .set mips2 \n" - "0: ll %0, %1 \n" - " addiu %0, 1 \n" - " sc %0, %1 \n" - " beqz %0, 0b \n" - :"=&r" (tmp), "=m" (*X)); - return *X; -} - -static __inline__ int -GSAtomicDecrement(gsatomic_t X) -{ - int tmp; - - __asm__ __volatile__ ( - " .set mips2 \n" - "0: ll %0, %1 \n" - " addiu %0, -1 \n" - " sc %0, %1 \n" - " beqz %0, 0b \n" - :"=&r" (tmp), "=m" (*X)); - return *X; -} +#endif #endif -#if !defined(GSATOMICREAD) +#if defined(REFCNT_LOCAL) && !defined(GSATOMICREAD) /* * Having just one allocationLock for all leads to lock contention * if there are lots of threads doing lots of retain/release calls. - * To alleviate this, instead of a single + * To alleviate this, if using REFCNT_LOCAL, instead of a single * allocationLock for all objects, we divide the object space into * chunks, each with its own lock. The chunk is selected by shifting * off the low-order ALIGNBITS of the object's pointer (these bits @@ -361,11 +281,11 @@ GSAtomicDecrement(gsatomic_t X) #define LOCKMASK (LOCKCOUNT-1) #define ALIGNBITS 3 -static NSLock *allocationLocks[LOCKCOUNT] = { 0 }; +static objc_mutex_t allocationLocks[LOCKCOUNT] = { 0 }; -static inline NSLock *GSAllocationLockForObject(id p) +static inline objc_mutex_t GSAllocationLockForObject(id p) { - NSUInteger i = ((((NSUInteger)(uintptr_t)p) >> ALIGNBITS) & LOCKMASK); + unsigned i = ((((unsigned)(uintptr_t)p) >> ALIGNBITS) & LOCKMASK); return allocationLocks[i]; } @@ -377,13 +297,19 @@ static inline NSLock *GSAllocationLockForObject(id p) #endif #define ALIGN __alignof__(double) +#if defined(REFCNT_LOCAL) || defined(CACHE_ZONE) + /* * Define a structure to hold information that is held locally * (before the start) in each object. */ typedef struct obj_layout_unpadded { - NSUInteger retained; +#if defined(REFCNT_LOCAL) + unsigned retained; +#endif +#if defined(CACHE_ZONE) NSZone *zone; +#endif } unp; #define UNP sizeof(unp) @@ -393,12 +319,40 @@ typedef struct obj_layout_unpadded { * structure correct. */ struct obj_layout { - NSUInteger retained; +#if defined(REFCNT_LOCAL) + unsigned retained; +#endif +#if defined(CACHE_ZONE) NSZone *zone; +#endif char padding[ALIGN - ((UNP % ALIGN) ? (UNP % ALIGN) : ALIGN)]; }; typedef struct obj_layout *obj; +#endif /* defined(REFCNT_LOCAL) || defined(CACHE_ZONE) */ + +#if !defined(REFCNT_LOCAL) + +/* + * Set up map table for non-local reference counts. + */ + +#define GSI_MAP_EQUAL(M, X, Y) (X.obj == Y.obj) +#define GSI_MAP_HASH(M, X) (X.uint >> 2) +#define GSI_MAP_RETAIN_KEY(M, X) +#define GSI_MAP_RELEASE_KEY(M, X) +#define GSI_MAP_RETAIN_VAL(M, X) +#define GSI_MAP_RELEASE_VAL(M, X) +#define GSI_MAP_KTYPES GSUNION_OBJ|GSUNION_INT +#define GSI_MAP_VTYPES GSUNION_INT +#define GSI_MAP_NOCLEAN 1 + +#include "GNUstepBase/GSIMap.h" + +static GSIMapTable_t retain_counts = {0}; + +#endif /* !defined(REFCNT_LOCAL) */ + /** * Examines the extra reference count for the object and, if non-zero @@ -413,13 +367,14 @@ NSDecrementExtraRefCountWasZero(id anObject) #if !GS_WITH_GC if (double_release_check_enabled) { - NSUInteger release_count; - NSUInteger retain_count = [anObject retainCount]; + unsigned release_count; + unsigned retain_count = [anObject retainCount]; release_count = [autorelease_class autoreleaseCountForObject: anObject]; if (release_count >= retain_count) [NSException raise: NSGenericException format: @"Release would release object too many times."]; } +#if defined(REFCNT_LOCAL) if (allocationLock != 0) { #if defined(GSATOMICREAD) @@ -444,18 +399,18 @@ NSDecrementExtraRefCountWasZero(id anObject) return YES; } #else /* GSATOMICREAD */ - NSLock *theLock = GSAllocationLockForObject(anObject); + objc_mutex_t theLock = GSAllocationLockForObject(anObject); - [theLock lock]; + objc_mutex_lock(theLock); if (((obj)anObject)[-1].retained == 0) { - [theLock unlock]; + objc_mutex_unlock(theLock); return YES; } else { ((obj)anObject)[-1].retained--; - [theLock unlock]; + objc_mutex_unlock(theLock); return NO; } #endif /* GSATOMICREAD */ @@ -472,7 +427,49 @@ NSDecrementExtraRefCountWasZero(id anObject) return NO; } } -#endif /* !GS_WITH_GC */ +#else + GSIMapNode node; + + if (allocationLock != 0) + { + objc_mutex_lock(allocationLock); + node = GSIMapNodeForKey(&retain_counts, (GSIMapKey)anObject); + if (node == 0) + { + objc_mutex_unlock(allocationLock); + return YES; + } + if (node->value.uint == 0) + { + GSIMapRemoveKey((GSIMapTable)&retain_counts, (GSIMapKey)anObject); + objc_mutex_unlock(allocationLock); + return YES; + } + else + { + (node->value.uint)--; + } + objc_mutex_unlock(allocationLock); + } + else + { + node = GSIMapNodeForKey(&retain_counts, (GSIMapKey)anObject); + if (node == 0) + { + return YES; + } + if ((node->value.uint) == 0) + { + GSIMapRemoveKey((GSIMapTable)&retain_counts, (GSIMapKey)anObject); + return YES; + } + else + { + --(node->value.uint); + } + } +#endif +#endif return NO; } @@ -481,14 +478,49 @@ NSDecrementExtraRefCountWasZero(id anObject) * from 0 to the maximum unsigned integer value minus one).
* The retain count for an object is this value plus one. */ -inline NSUInteger +inline unsigned NSExtraRefCount(id anObject) { #if GS_WITH_GC return UINT_MAX - 1; #else /* GS_WITH_GC */ +#if defined(REFCNT_LOCAL) return ((obj)anObject)[-1].retained; -#endif /* GS_WITH_GC */ +#else + GSIMapNode node; + unsigned ret; + + if (allocationLock != 0) + { + objc_mutex_t theLock = GSAllocationLockForObject(anObject); + + objc_mutex_lock(theLock); + node = GSIMapNodeForKey(&retain_counts, (GSIMapKey)anObject); + if (node == 0) + { + ret = 0; + } + else + { + ret = node->value.uint; + } + objc_mutex_unlock(theLock); + } + else + { + node = GSIMapNodeForKey(&retain_counts, (GSIMapKey)anObject); + if (node == 0) + { + ret = 0; + } + else + { + ret = node->value.uint; + } + } + return ret; +#endif +#endif } /** @@ -503,6 +535,7 @@ NSIncrementExtraRefCount(id anObject) #if GS_WITH_GC return; #else /* GS_WITH_GC */ +#if defined(REFCNT_LOCAL) if (allocationLock != 0) { #if defined(GSATOMICREAD) @@ -517,17 +550,17 @@ NSIncrementExtraRefCount(id anObject) format: @"NSIncrementExtraRefCount() asked to increment too far"]; } #else /* GSATOMICREAD */ - NSLock *theLock = GSAllocationLockForObject(anObject); + objc_mutex_t theLock = GSAllocationLockForObject(anObject); - [theLock lock]; + objc_mutex_lock(theLock); if (((obj)anObject)[-1].retained == UINT_MAX - 1) { - [theLock unlock]; + objc_mutex_unlock (theLock); [NSException raise: NSInternalInconsistencyException format: @"NSIncrementExtraRefCount() asked to increment too far"]; } ((obj)anObject)[-1].retained++; - [theLock unlock]; + objc_mutex_unlock (theLock); #endif /* GSATOMICREAD */ } else @@ -539,16 +572,52 @@ NSIncrementExtraRefCount(id anObject) } ((obj)anObject)[-1].retained++; } +#else /* REFCNT_LOCAL */ + GSIMapNode node; + + if (allocationLock != 0) + { + objc_mutex_lock(allocationLock); + node = GSIMapNodeForKey(&retain_counts, (GSIMapKey)anObject); + if (node != 0) + { + if ((node->value.uint) == UINT_MAX - 1) + { + objc_mutex_unlock(allocationLock); + [NSException raise: NSInternalInconsistencyException + format: + @"NSIncrementExtraRefCount() asked to increment too far"]; + } + (node->value.uint)++; + } + else + { + GSIMapAddPair(&retain_counts, (GSIMapKey)anObject, (GSIMapVal)1); + } + objc_mutex_unlock(allocationLock); + } + else + { + node = GSIMapNodeForKey(&retain_counts, (GSIMapKey)anObject); + if (node != 0) + { + if ((node->value.uint) == UINT_MAX - 1) + { + [NSException raise: NSInternalInconsistencyException + format: + @"NSIncrementExtraRefCount() asked to increment too far"]; + } + (node->value.uint)++; + } + else + { + GSIMapAddPair(&retain_counts, (GSIMapKey)anObject, (GSIMapVal)1); + } + } +#endif /* REFCNT_LOCAL */ #endif /* GS_WITH_GC */ } -#ifndef NDEBUG -#define AADD(c, o) GSDebugAllocationAdd(c, o) -#define AREM(c, o) GSDebugAllocationRemove(c, o) -#else -#define AADD(c, o) -#define AREM(c, o) -#endif /* * Now do conditional compilation of memory allocation functions @@ -560,67 +629,65 @@ NSIncrementExtraRefCount(id anObject) inline NSZone * GSObjCZone(NSObject *object) { - GSOnceFLog(@"GSObjCZone() is deprecated ... use -zone instead"); - /* MacOS-X 10.5 seems to return the default malloc zone if GC is enabled. - */ - return NSDefaultMallocZone(); + return 0; } static void GSFinalize(void* object, void* data) { - [(id)object finalize]; - AREM(((id)object)->class_pointer, (id)object); + [(id)object gcFinalize]; +#ifndef NDEBUG + GSDebugAllocationRemove(((id)object)->class_pointer, (id)object); +#endif ((id)object)->class_pointer = (void*)0xdeadface; } -static BOOL -GSIsFinalizable(Class c) -{ - if (get_imp(c, finalize_sel) != finalize_imp) - return YES; - return NO; -} - -inline id -NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone) +inline NSObject * +NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone) { id new; int size; - GC_descr gc_type; NSCAssert((CLS_ISCLASS(aClass)), @"Bad class for new object"); - gc_type = (GC_descr)aClass->gc_object_type; - size = class_getInstanceSize(aClass) + extraBytes; - if (size % sizeof(void*) != 0) + size = aClass->instance_size + extraBytes; + if (zone == GSAtomicMallocZone()) { - /* Size must be a multiple of pointer size for the garbage collector - * to be able to allocate explicitly typed memory. - */ - size += sizeof(void*) - size % sizeof(void*); - } - - if (gc_type == 0) - { - new = NSZoneCalloc(zone, 1, size); - NSLog(@"No garbage collection information for '%s'", - class_getName(aClass)); + new = NSZoneMalloc(zone, size); } else { - new = GC_calloc_explicitly_typed(1, size, gc_type); + GC_descr gc_type = (GC_descr)aClass->gc_object_type; + + if (gc_type == 0) + { + new = NSZoneMalloc(zone, size); + NSLog(@"No garbage collection information for '%s'", + GSNameFromClass(aClass)); + } + else if ([aClass requiresTypedMemory]) + { + new = GC_CALLOC_EXPLICTLY_TYPED(1, size, gc_type); + } + else + { + new = NSZoneMalloc(zone, size); + } } if (new != nil) { + memset(new, 0, size); new->class_pointer = aClass; - if (GSIsFinalizable(aClass)) + if (__objc_responds_to(new, @selector(gcFinalize))) { - /* We only do allocation counting for objects that can be - * finalised - for other objects we have no way of decrementing - * the count when the object is collected. +#ifndef NDEBUG + /* + * We only do allocation counting for objects that can be + * finalised - for other objects we have no way of decrementing + * the count when the object is collected. */ - AADD(aClass, new); + GSDebugAllocationAdd(aClass, new); +#endif GC_REGISTER_FINALIZER (new, GSFinalize, NULL, NULL, NULL); } } @@ -628,29 +695,47 @@ NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone) } inline void -NSDeallocateObject(id anObject) +NSDeallocateObject(NSObject *anObject) { } #else /* GS_WITH_GC */ +#if defined(REFCNT_LOCAL) || defined(CACHE_ZONE) + +#if defined(CACHE_ZONE) + inline NSZone * GSObjCZone(NSObject *object) { - GSOnceFLog(@"GSObjCZone() is deprecated ... use -zone instead"); - if (object_getClass(object) == NSConstantStringClass) + if (GSObjCClass(object) == NSConstantStringClass) return NSDefaultMallocZone(); return ((obj)object)[-1].zone; } -inline id -NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone) +#else /* defined(CACHE_ZONE) */ + +inline NSZone * +GSObjCZone(NSObject *object) { + if (GSObjCClass(object) == NSConstantStringClass) + return NSDefaultMallocZone(); + return NSZoneFromPointer(&((obj)object)[-1]); +} + +#endif /* defined(CACHE_ZONE) */ + +inline NSObject * +NSAllocateObject (Class aClass, unsigned extraBytes, NSZone *zone) +{ +#ifndef NDEBUG + extern void GSDebugAllocationAdd(Class c, id o); +#endif id new; int size; NSCAssert((CLS_ISCLASS(aClass)), @"Bad class for new object"); - size = class_getInstanceSize(aClass) + extraBytes + sizeof(struct obj_layout); + size = aClass->instance_size + extraBytes + sizeof(struct obj_layout); if (zone == 0) { zone = NSDefaultMallocZone(); @@ -659,23 +744,32 @@ NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone) if (new != nil) { memset (new, 0, size); +#if defined(CACHE_ZONE) ((obj)new)->zone = zone; +#endif new = (id)&((obj)new)[1]; new->class_pointer = aClass; - AADD(aClass, new); +#ifndef NDEBUG + GSDebugAllocationAdd(aClass, new); +#endif } return new; } inline void -NSDeallocateObject(id anObject) +NSDeallocateObject(NSObject *anObject) { +#ifndef NDEBUG + extern void GSDebugAllocationRemove(Class c, id o); +#endif if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer)) { obj o = &((obj)anObject)[-1]; - NSZone *z = o->zone; + NSZone *z = GSObjCZone(anObject); - AREM(((id)anObject)->class_pointer, (id)anObject); +#ifndef NDEBUG + GSDebugAllocationRemove(((id)anObject)->class_pointer, (id)anObject); +#endif if (NSZombieEnabled == YES) { GSMakeZombie(anObject); @@ -693,43 +787,66 @@ NSDeallocateObject(id anObject) return; } -#endif /* GS_WITH_GC */ - - -void -GSPrivateSwizzle(id o, Class c) -{ - if ((Class)o->class_pointer != c) - { -#if GS_WITH_GC - /* We only do allocation counting for objects that can be - * finalised - for other objects we have no way of decrementing - * the count when the object is collected. - */ - if (GSIsFinalizable(o->class_pointer)) - { - /* Already finalizable, so we just need to do any allocation - * accounting. - */ - AREM(o->class_pointer, o); - AADD(c, o); - } - else if (GSIsFinalizable(c)) - { - /* New class is finalizable, so we must register the instance - * for finalisation and do allocation acounting for it. - */ - AADD(c, o); - GC_REGISTER_FINALIZER (o, GSFinalize, NULL, NULL, NULL); - } #else - AREM(o->class_pointer, o); - AADD(c, o); -#endif /* GS_WITH_GC */ - o->class_pointer = c; - } + +inline NSZone * +GSObjCZone(NSObject *object) +{ + if (GSObjCClass(object) == NSConstantStringClass) + return NSDefaultMallocZone(); + return NSZoneFromPointer(object); } +inline NSObject * +NSAllocateObject (Class aClass, unsigned extraBytes, NSZone *zone) +{ + id new; + int size; + + NSCAssert((CLS_ISCLASS(aClass)), @"Bad class for new object"); + size = aClass->instance_size + extraBytes; + new = NSZoneMalloc (zone, size); + if (new != nil) + { + memset (new, 0, size); + new->class_pointer = aClass; +#ifndef NDEBUG + GSDebugAllocationAdd(aClass, new); +#endif + } + return new; +} + +inline void +NSDeallocateObject(NSObject *anObject) +{ + if ((anObject!=nil) && CLS_ISCLASS(((id)anObject)->class_pointer)) + { + NSZone *z = [anObject zone]; + +#ifndef NDEBUG + GSDebugAllocationRemove(((id)anObject)->class_pointer, (id)anObject); +#endif + if (NSZombieEnabled == YES) + { + GSMakeZombie(anObject); + if (NSDeallocateZombies == YES) + { + NSZoneFree(z, anObject); + } + } + else + { + ((id)anObject)->class_pointer = (void*) 0xdeadface; + NSZoneFree(z, anObject); + } + } + return; +} + +#endif /* defined(REFCNT_LOCAL) || defined(CACHE_ZONE) */ + +#endif /* GS_WITH_GC */ BOOL NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone) @@ -738,51 +855,42 @@ NSShouldRetainWithZone (NSObject *anObject, NSZone *requestedZone) return YES; #else return (!requestedZone || requestedZone == NSDefaultMallocZone() - || [anObject zone] == requestedZone); + || GSObjCZone(anObject) == requestedZone); #endif } -/* FIXME ... the following code is a hack for the gnu runtime only - */ + struct objc_method_description_list { int count; struct objc_method_description list[1]; }; - -/* Must have same layout as ivars of Protocol class - */ -struct protocol_class { - Class isa; - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods; - struct objc_method_description_list *class_methods; -}; +typedef struct { + @defs(Protocol) +} *pcl; struct objc_method_description * -GSDescriptionForInstanceMethod(Protocol *self, SEL aSel) +GSDescriptionForInstanceMethod(pcl self, SEL aSel) { - struct protocol_class *pcl = (struct protocol_class*)self; int i; struct objc_protocol_list *p_list; - const char *name = sel_getName(aSel); + const char *name = GSNameFromSelector(aSel); struct objc_method_description *result; - if (pcl->instance_methods != 0) + if (self->instance_methods != 0) { - for (i = 0; i < pcl->instance_methods->count; i++) + for (i = 0; i < self->instance_methods->count; i++) { - if (!strcmp ((char*)pcl->instance_methods->list[i].name, name)) - return &(pcl->instance_methods->list[i]); + if (!strcmp ((char*)self->instance_methods->list[i].name, name)) + return &(self->instance_methods->list[i]); } } - for (p_list = pcl->protocol_list; p_list != 0; p_list = p_list->next) + for (p_list = self->protocol_list; p_list != 0; p_list = p_list->next) { for (i = 0; i < p_list->count; i++) { - result = GSDescriptionForInstanceMethod(p_list->list[i], aSel); + result = GSDescriptionForInstanceMethod((pcl)p_list->list[i], aSel); if (result) { return result; @@ -794,27 +902,26 @@ GSDescriptionForInstanceMethod(Protocol *self, SEL aSel) } struct objc_method_description * -GSDescriptionForClassMethod(Protocol *self, SEL aSel) +GSDescriptionForClassMethod(pcl self, SEL aSel) { - struct protocol_class *pcl = (struct protocol_class*)self; int i; struct objc_protocol_list *p_list; - const char *name = sel_getName(aSel); + const char *name = GSNameFromSelector(aSel); struct objc_method_description *result; - if (pcl->class_methods != 0) + if (self->class_methods != 0) { - for (i = 0; i < pcl->class_methods->count; i++) + for (i = 0; i < self->class_methods->count; i++) { - if (!strcmp ((char*)pcl->class_methods->list[i].name, name)) - return &(pcl->class_methods->list[i]); + if (!strcmp ((char*)self->class_methods->list[i].name, name)) + return &(self->class_methods->list[i]); } } - for (p_list = pcl->protocol_list; p_list != 0; p_list = p_list->next) + for (p_list = self->protocol_list; p_list != 0; p_list = p_list->next) { for (i = 0; i < p_list->count; i++) { - result = GSDescriptionForClassMethod(p_list->list[i], aSel); + result = GSDescriptionForClassMethod((pcl)p_list->list[i], aSel); if (result) { return result; @@ -829,12 +936,12 @@ GSDescriptionForClassMethod(Protocol *self, SEL aSel) - (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel { - return GSDescriptionForInstanceMethod(self, aSel); + return GSDescriptionForInstanceMethod((pcl)self, aSel); } - (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel; { - return GSDescriptionForClassMethod(self, aSel); + return GSDescriptionForClassMethod((pcl)self, aSel); } @end @@ -904,70 +1011,44 @@ GSDescriptionForClassMethod(Protocol *self, SEL aSel) { if (allocationLock == 0) { -#if !defined(GSATOMICREAD) - NSUInteger i; +#if defined(REFCNT_LOCAL) && !defined(GSATOMICREAD) + unsigned i; for (i = 0; i < LOCKCOUNT; i++) { - allocationLocks[i] = [NSLock new]; + allocationLocks[i] = objc_mutex_allocate(); } #endif - allocationLock = [NSLock new]; + allocationLock = objc_mutex_allocate(); } } #if GS_WITH_GC -/* Function to log Boehm GC warnings - * NB. This must not allocate any collectable memory as it may result - * in a deadlock in the garbage collecting library. +/** + * A utility method used when garbage collection is enabled. Can be ignored. */ -static void -GSGarbageCollectorLog(char *msg, GC_word arg) ++ (BOOL) requiresTypedMemory { - char buf[strlen(msg)+1024]; - sprintf(buf, msg, (unsigned long)arg); - fprintf(stderr, "Garbage collector: %s", buf); + return NO; } #endif /** - * Semi-private function in libobjc2 that initialises the classes used for - * blocks. + * This message is sent to a class once just before it is used for the first + * time. If class has a superclass, its implementation of +initialize is + * called first. You can implement +initialize in your own class if you need + * to. NSObject's implementation handles essential root object and base + * library initialization. */ -#ifndef __MINGW__ -BOOL -objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); -#endif - -+ (void)load -{ -#ifndef __MINGW__ - /* When NSObject is loaded, register it as the superclass of the block - * classes */ - if (objc_create_block_classes_as_subclasses_of) - objc_create_block_classes_as_subclasses_of(self); -#endif -} - + (void) initialize { if (self == [NSObject class]) { -#if GS_WITH_GC - /* Make sure that the garbage collection library is initialised. - * This is not necessary on most platforms, but is good practice. - */ - GC_init(); - GC_set_warn_proc(GSGarbageCollectorLog); -#endif - -#ifdef __MINGW__ - { - // See libgnustep-base-entry.m - extern void gnustep_base_socket_init(void); - gnustep_base_socket_init(); - } -#else /* __MINGW__ */ +#ifdef __MINGW32__ + // See libgnustep-base-entry.m + extern void gnustep_base_socket_init(void); + gnustep_base_socket_init(); +#else #ifdef SIGPIPE /* @@ -997,9 +1078,9 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); fprintf(stderr, "Unable to retrieve information about SIGPIPE\n"); } } -#else /* HAVE_SIGACTION */ +#else { - void (*handler)(NSInteger); + void (*handler)(int); handler = signal(SIGPIPE, SIG_IGN); if (handler != SIG_DFL) @@ -1007,32 +1088,25 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); signal(SIGPIPE, handler); } } -#endif /* HAVE_SIGACTION */ -#endif /* SIGPIPE */ -#endif /* __MINGW__ */ - -#if GS_WITH_GC - finalize_sel = @selector(finalize); - finalize_imp = get_imp(self, finalize_sel); +#endif +#endif #endif -#if (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) +#if defined(__FreeBSD__) && defined(__i386__) // Manipulate the FPU to add the exception mask. (Fixes SIGFPE // problems on *BSD) // Note this only works on x86 -# if defined(FE_INVALID) - fedisableexcept(FE_INVALID); -# else - { - volatile short cw; - __asm__ volatile ("fstcw (%0)" : : "g" (&cw)); - cw |= 1; /* Mask 'invalid' exception */ - __asm__ volatile ("fldcw (%0)" : : "g" (&cw)); + { + volatile short cw; + + __asm__ volatile ("fstcw (%0)" : : "g" (&cw)); + cw |= 1; /* Mask 'invalid' exception */ + __asm__ volatile ("fldcw (%0)" : : "g" (&cw)); } -# endif #endif + #ifdef HAVE_LOCALE_H GSSetLocaleC(LC_ALL, ""); // Set up locale from environment. #endif @@ -1040,10 +1114,6 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); // Create the global lock gnustep_global_lock = [NSRecursiveLock new]; - // Behavior debugging - GSObjCBehaviorDebug(GSPrivateEnvironmentFlag("GNUSTEP_BEHAVIOR_DEBUG", - GSObjCBehaviorDebug(-1))); - // Zombie management stuff. zombieMap = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0); @@ -1054,6 +1124,12 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); autorelease_class = [NSAutoreleasePool class]; autorelease_sel = @selector(addObject:); autorelease_imp = [autorelease_class methodForSelector: autorelease_sel]; +#if GS_WITH_GC == 0 +#if !defined(REFCNT_LOCAL) + GSIMapInitWithZoneAndCapacity(&retain_counts, + NSDefaultMallocZone(), 1024); +#endif +#endif NSConstantStringClass = [NSString constantStringClass]; GSPrivateBuildStrings(); [[NSNotificationCenter defaultCenter] @@ -1313,11 +1389,6 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); NSDeallocateObject (self); } -- (void) finalize -{ - return; -} - /** * This method is an anachronism. Do not use it. */ @@ -1350,7 +1421,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ + (Class) superclass { - return class_getSuperclass(self); + return GSObjCSuper(self); } /** @@ -1358,7 +1429,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (Class) superclass { - return class_getSuperclass(object_getClass(self)); + return GSObjCSuper(GSObjCClass(self)); } /** @@ -1390,7 +1461,35 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ + (BOOL) conformsToProtocol: (Protocol*)aProtocol { - return class_conformsToProtocol(self, aProtocol); + struct objc_protocol_list* proto_list; + + if (aProtocol == 0) + { + return NO; + } + for (proto_list = ((struct objc_class*)self)->protocols; + proto_list; proto_list = proto_list->next) + { + unsigned int i; + + for (i = 0; i < proto_list->count; i++) + { + /* xxx We should add conformsToProtocol to Protocol class. */ + if ([proto_list->list[i] conformsTo: aProtocol]) + { + return YES; + } + } + } + + if ([self superclass]) + { + return [[self superclass] conformsToProtocol: aProtocol]; + } + else + { + return NO; + } } /** @@ -1399,7 +1498,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (BOOL) conformsToProtocol: (Protocol*)aProtocol { - return class_conformsToProtocol([self class], aProtocol); + return [[self class] conformsToProtocol: aProtocol]; } /** @@ -1430,12 +1529,12 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; /* - * If 'self' is an instance, object_getClass() will get the class, + * If 'self' is an instance, GSObjCClass() will get the class, * and get_imp() will get the instance method. - * If 'self' is a class, object_getClass() will get the meta-class, + * If 'self' is a class, GSObjCClass() will get the meta-class, * and get_imp() will get the class method. */ - return get_imp(object_getClass(self), aSelector); + return get_imp(GSObjCClass(self), aSelector); } /** @@ -1461,7 +1560,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); /** * Returns the method signature describing how the receiver would handle * a message with aSelector. - *
Returns nil if given a null selector. + *
Raises NSInvalidArgumentException if given a null selector. */ - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector { @@ -1469,12 +1568,11 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); struct objc_method *mth; Class c; - if (0 == aSelector) - { - return nil; - } + if (aSelector == 0) + [NSException raise: NSInvalidArgumentException + format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - c = (GSObjCIsInstance(self) ? object_getClass(self) : (Class)self); + c = (GSObjCIsInstance(self) ? GSObjCClass(self) : (Class)self); mth = GSGetMethod(c, aSelector, GSObjCIsInstance(self), YES); if (mth == 0) @@ -1500,7 +1598,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); while (found == NO && protocols != 0) { - NSUInteger i = 0; + unsigned i = 0; while (found == NO && i < protocols->count) { @@ -1540,7 +1638,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); - (NSString*) description { return [NSString stringWithFormat: @"<%s: %p>", - class_getName([self class]), self]; + GSClassNameFromObject(self), self]; } /** @@ -1575,7 +1673,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); format: @"%s(%s) does not recognize %s", GSClassNameFromObject(self), GSObjCIsInstance(self) ? "instance" : "class", - aSelector ? sel_getName(aSelector) : "(null)"]; + aSelector ? GSNameFromSelector(aSelector) : "(null)"]; } - (retval_t) forward: (SEL)aSel : (arglist_t)argFrame @@ -1599,13 +1697,6 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (void) forwardInvocation: (NSInvocation*)anInvocation { - id target = [self forwardingTargetForSelector: [anInvocation selector]]; - - if (nil != target) - { - [anInvocation invokeWithTarget: target]; - return; - } [self doesNotRecognizeSelector: [anInvocation selector]]; return; } @@ -1686,8 +1777,8 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); #if GS_WITH_GC == 0 if (double_release_check_enabled) { - NSUInteger release_count; - NSUInteger retain_count = [self retainCount]; + unsigned release_count; + unsigned retain_count = [self retainCount]; release_count = [autorelease_class autoreleaseCountForObject:self]; if (release_count > retain_count) [NSException @@ -1725,7 +1816,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); * The default implementation returns a value based on the address * of the instance. */ -- (NSUInteger) hash +- (unsigned) hash { /* * Ideally we would shift left to lose any zero bits produced by the @@ -1734,7 +1825,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); * In the absence of detailed information, pick a reasonable value * assuming the object will be aligned to an eight byte boundary. */ - return (NSUInteger)(uintptr_t)self >> 3; + return (unsigned)(uintptr_t)self >> 3; } /** @@ -1765,7 +1856,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (BOOL) isKindOfClass: (Class)aClass { - Class class = object_getClass(self); + Class class = GSObjCClass(self); return GSObjCIsKindOf(class, aClass); } @@ -1783,7 +1874,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (BOOL) isMemberOfClass: (Class)aClass { - return (object_getClass(self) == aClass) ? YES : NO; + return (GSObjCClass(self) == aClass) ? YES : NO; } /** @@ -1819,12 +1910,12 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - msg = get_imp(object_getClass(self), aSelector); + msg = get_imp(GSObjCClass(self), aSelector); if (!msg) { [NSException raise: NSGenericException format: @"invalid selector passed to %s", - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; return nil; } return (*msg)(self, aSelector); @@ -1844,12 +1935,12 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - msg = get_imp(object_getClass(self), aSelector); + msg = get_imp(GSObjCClass(self), aSelector); if (!msg) { [NSException raise: NSGenericException format: @"invalid selector passed to %s", - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; return nil; } @@ -1872,11 +1963,11 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - msg = get_imp(object_getClass(self), aSelector); + msg = get_imp(GSObjCClass(self), aSelector); if (!msg) { [NSException raise: NSGenericException - format: @"invalid selector passed to %s", sel_getName(_cmd)]; + format: @"invalid selector passed to %s", GSNameFromSelector(_cmd)]; return nil; } @@ -1970,7 +2061,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); * By convention, objects which should (or can) never be deallocated * return the maximum unsigned integer value. */ -- (NSUInteger) retainCount +- (unsigned) retainCount { #if GS_WITH_GC return UINT_MAX; @@ -1984,7 +2075,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); * the maximum unsigned integer value, as classes can not be deallocated * the retain count mechanism is a dummy system for them. */ -+ (NSUInteger) retainCount ++ (unsigned) retainCount { return UINT_MAX; } @@ -2002,13 +2093,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (NSZone*) zone { -#if GS_WITH_GC - /* MacOS-X 10.5 seems to return the default malloc zone if GC is enabled. - */ - return NSDefaultMallocZone(); -#else - return (((obj)self)[-1]).zone; -#endif + return GSObjCZone(self); } /** @@ -2031,20 +2116,20 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); return self; } -+ (BOOL) resolveClassMethod: (SEL)name +/** + * Returns the version number of the receiving class. This will default to + * a number assigned by the Objective C compiler if [NSObject -setVersion] has + * not been called. + */ ++ (int) version { - return NO; -} - -+ (BOOL) resolveInstanceMethod: (SEL)name -{ - return NO; + return class_get_version(self); } /** * Sets the version number of the receiving class. Should be nonnegative. */ -+ (id) setVersion: (NSInteger)aVersion ++ (id) setVersion: (int)aVersion { if (aVersion < 0) [NSException raise: NSInvalidArgumentException @@ -2054,25 +2139,6 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); return self; } -/** - * Returns the version number of the receiving class. This will default to - * a number assigned by the Objective C compiler if [NSObject -setVersion] has - * not been called. - */ -+ (NSInteger) version -{ - return class_get_version(self); -} - -- (id) autoContentAccessingProxy -{ - return AUTORELEASE([[GSContentAccessingProxy alloc] initWithObject: self]); -} - -- (id) forwardingTargetForSelector:(SEL)aSelector -{ - return nil; -} @end @@ -2088,7 +2154,6 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ - (id) error: (const char *)aString, ... { -#if !defined(NeXT_RUNTIME) && !defined(__GNUSTEP_RUNTIME__) #define FMT "error: %s (%s)\n%s\n" char fmt[(strlen((char*)FMT)+strlen((char*)GSClassNameFromObject(self)) +((aString!=NULL)?strlen((char*)aString):0)+8)]; @@ -2101,9 +2166,8 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); /* xxx What should `code' argument be? Current 0. */ objc_verror (self, 0, fmt, ap); va_end(ap); -#undef FMT -#endif return nil; +#undef FMT } /* @@ -2188,7 +2252,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); format: @"%s(%s) does not recognize %s", GSClassNameFromObject(self), GSObjCIsInstance(self) ? "instance" : "class", - aSel ? sel_getName(aSel) : "(null)"]; + aSel ? GSNameFromSelector(aSel) : "(null)"]; return nil; } @@ -2213,6 +2277,25 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); */ @implementation NSObject (GNUstep) +/* GNU Object class compatibility */ + +/** + * Called to change the class used for autoreleasing objects. + */ ++ (void) setAutoreleaseClass: (Class)aClass +{ + autorelease_class = aClass; + autorelease_imp = [self instanceMethodForSelector: autorelease_sel]; +} + +/** + * returns the class used to autorelease objects. + */ ++ (Class) autoreleaseClass +{ + return autorelease_class; +} + /** * Enables runtime checking of retain/release/autorelease operations.
*

Whenever either -autorelease or -release is called, the contents of any @@ -2257,13 +2340,13 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); * level information. */ - (NSString*) descriptionWithLocale: (NSDictionary*)aLocale - indent: (NSUInteger)level + indent: (unsigned)level { return [self descriptionWithLocale: aLocale]; } + (NSString*) descriptionWithLocale: (NSDictionary*)aLocale - indent: (NSUInteger)level + indent: (unsigned)level { return [self descriptionWithLocale: aLocale]; } @@ -2280,13 +2363,18 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); - (BOOL) isClass { - return class_isMetaClass(object_getClass(self)); + return GSObjCIsClass((Class)self); +} + +- (BOOL) isInstance +{ + return GSObjCIsInstance(self); } - (BOOL) isMemberOfClassNamed: (const char*)aClassName { return ((aClassName!=NULL) - &&!strcmp(class_getName(object_getClass(self)), aClassName)); + &&!strcmp(GSNameFromClass(GSObjCClass(self)), aClassName)); } + (struct objc_method_description *) descriptionForInstanceMethod: (SEL)aSel @@ -2307,33 +2395,155 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); return ((struct objc_method_description *) GSGetMethod((GSObjCIsInstance(self) - ? object_getClass(self) : (Class)self), + ? GSObjCClass(self) : (Class)self), aSel, GSObjCIsInstance(self), YES)); } -+ (NSInteger) streamVersion: (void*)aStream +/** + * Transmutes the receiver into an immutable version of the same object + * and returns the result.
+ * If the receiver is not a mutable object or cannot be simply transmuted, + * then this method either returns the receiver unchanged or, + * if the force flag is set to YES, returns an autoreleased copy of the + * receiver.
+ * Mutable classes should override this default implementation.
+ * This method is used in methods which are declared to return immutable + * objects (eg. an NSArray), but which create and build mutable ones + * internally. + */ +- (id) makeImmutableCopyOnFail: (BOOL)force { - GSOnceMLog(@"[NSObject+streamVersion:] is deprecated ... do not use"); - return class_get_version (self); -} -- (id) read: (void*)aStream -{ - GSOnceMLog(@"[NSObject-read:] is deprecated ... do not use"); - return self; -} -- (id) write: (void*)aStream -{ - GSOnceMLog(@"[NSObject-write:] is deprecated ... do not use"); - return self; -} -- (id) awake -{ - GSOnceMLog(@"[NSObject-awake] is deprecated ... do not use"); + if (force == YES) + { + return AUTORELEASE([self copy]); + } return self; } +/** + * Changes the class of the receiver (the 'isa' pointer) to be aClassObject, + * but only if the receiver is an instance of a subclass of aClassObject + * which has not added extra instance variables.
+ * Returns zero on failure, or the old class on success. + */ +- (Class) transmuteClassTo: (Class)aClassObject +{ + if (GSObjCIsInstance(self) == YES) + if (class_is_class(aClassObject)) + if (class_get_instance_size(aClassObject)==class_get_instance_size(isa)) + if ([self isKindOfClass: aClassObject]) + { + Class old_isa = isa; + isa = aClassObject; + return old_isa; + } + return 0; +} + ++ (int) streamVersion: (TypedStream*)aStream +{ +#ifndef NeXT_RUNTIME + if (aStream->mode == OBJC_READONLY) + return objc_get_stream_class_version (aStream, self); + else +#endif + return class_get_version (self); +} + +//NOTE: original comments included the following excerpt, however it is +// probably not relevant now since the implementations are stubbed out. +// Subclasses should extend these, by calling +// [super read/write: aStream] before doing their own archiving. These +// methods are private, in the sense that they should only be called from +// subclasses. + +/** + * Originally used to read the instance variables declared in this + * particular part of the object from a stream. Currently stubbed out. + */ +- (id) read: (TypedStream*)aStream +{ + // [super read: aStream]; + return self; +} + +/** + * Originally used to write the instance variables declared in this + * particular part of the object to a stream. Currently stubbed out. + */ +- (id) write: (TypedStream*)aStream +{ + // [super write: aStream]; + return self; +} + +/** + * Originally used before [NSCoder] and related classes existed. Currently + * stubbed out. + */ +- (id) awake +{ + // [super awake]; + return self; +} + +@end + +/* + * Stuff for compatibility with 'Object' derived classes. + */ +@interface Object (NSObjectCompat) ++ (NSString*) description; ++ (void) release; ++ (id) retain; +- (NSString*) className; +- (NSString*) description; +- (void) release; +- (BOOL) respondsToSelector: (SEL)aSel; +- (id) retain; +@end + +@implementation Object (NSObjectCompat) ++ (NSString*) description +{ + return NSStringFromClass(self); +} ++ (void) release +{ + return; +} ++ (id) retain +{ + return self; +} +- (NSString*) className +{ + return NSStringFromClass([self class]); +} +- (NSString*) description +{ + return [NSString stringWithFormat: @"<%s: %p>", + GSClassNameFromObject(self), self]; +} +- (BOOL) isProxy +{ + return NO; +} +- (void) release +{ + return; +} +- (BOOL) respondsToSelector: (SEL)aSelector +{ + /* Object implements -respondsTo: */ + return [self respondsTo: aSelector]; +} +- (id) retain +{ + return self; +} @end @@ -2341,11 +2551,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); @implementation NSZombie - (Class) class { - return (Class)isa; -} -- (Class) originalClass -{ - return NSMapGet(zombieMap, (void*)self); + return object_get_class(self); } - (retval_t) forward:(SEL)aSel :(arglist_t)argFrame { @@ -2358,7 +2564,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); } - (void) forwardInvocation: (NSInvocation*)anInvocation { - NSUInteger size = [[anInvocation methodSignature] methodReturnLength]; + unsigned size = [[anInvocation methodSignature] methodReturnLength]; unsigned char v[size]; memset(v, '\0', size); @@ -2370,48 +2576,16 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak)); { Class c; - if (0 == aSelector) + if (allocationLock != 0) { - return nil; + objc_mutex_lock(allocationLock); } - [allocationLock lock]; c = NSMapGet(zombieMap, (void*)self); - [allocationLock unlock]; + if (allocationLock != 0) + { + objc_mutex_unlock(allocationLock); + } return [c instanceMethodSignatureForSelector: aSelector]; } @end -@implementation GSContentAccessingProxy -- (void) dealloc -{ - [object endContentAccess]; - [super dealloc]; -} - -- (void) finalize -{ - [object endContentAccess]; -} - -- (id) forwardingTargetForSelector: (SEL)aSelector -{ - return object; -} -/* Support for legacy runtimes... */ -- (void) forwardInvocation: (NSInvocation*)anInvocation -{ - [anInvocation invokeWithTarget: object]; -} - -- (id) initWithObject: (id)anObject -{ - ASSIGN(object, anObject); - [object beginContentAccess]; - return self; -} - -- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector -{ - return [object methodSignatureForSelector: aSelector]; -} -@end diff --git a/Source/NSOperation.m b/Source/NSOperation.m deleted file mode 100644 index a8d3a04d4..000000000 --- a/Source/NSOperation.m +++ /dev/null @@ -1,1060 +0,0 @@ -/**Implementation for NSOperation for GNUStep - Copyright (C) 2009,2010 Free Software Foundation, Inc. - - Written by: Gregory Casamento - Written by: Richard Frith-Macdonald - Date: 2009,2010 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - - NSOperation class reference - $Date: 2008-06-08 11:38:33 +0100 (Sun, 08 Jun 2008) $ $Revision: 26606 $ - */ - -#import "common.h" - -#import "Foundation/NSLock.h" - -#define GS_NSOperation_IVARS \ - NSRecursiveLock *lock; \ - NSConditionLock *cond; \ - NSOperationQueuePriority priority; \ - double threadPriority; \ - BOOL cancelled; \ - BOOL concurrent; \ - BOOL executing; \ - BOOL finished; \ - BOOL ready; \ - NSMutableArray *dependencies; - -#define GS_NSOperationQueue_IVARS \ - NSRecursiveLock *lock; \ - NSConditionLock *cond; \ - NSMutableArray *operations; \ - NSMutableArray *waiting; \ - NSString *name; \ - BOOL suspended; \ - NSInteger threads; \ - NSInteger idle; \ - NSInteger count; - -#import "Foundation/NSOperation.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSKeyValueObserving.h" -#import "Foundation/NSThread.h" -#import "GSPrivate.h" - -#define GSInternal NSOperationInternal -#include "GSInternal.h" -GS_PRIVATE_INTERNAL(NSOperation) - -static NSArray *empty = nil; - -@implementation NSOperation - -+ (BOOL) automaticallyNotifiesObserversForKey: (NSString*)theKey -{ - /* Handle all KVO manually - */ - return NO; -} - -+ (void) initialize -{ - empty = [NSArray new]; -} - -- (void) addDependency: (NSOperation *)op -{ - if (NO == [op isKindOfClass: [self class]]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] dependency is not an NSOperation", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - if (op == self) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] attempt to add dependency on self", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - [internal->lock lock]; - if (internal->dependencies == nil) - { - internal->dependencies = [[NSMutableArray alloc] initWithCapacity: 5]; - } - NS_DURING - { - if (NSNotFound == [internal->dependencies indexOfObjectIdenticalTo: op]) - { - [self willChangeValueForKey: @"dependencies"]; - [internal->dependencies addObject: op]; - /* We only need to watch for changes if it's possible for them to - * happen and make a difference. - */ - if (NO == [op isFinished] - && NO == [self isCancelled] - && NO == [self isExecuting] - && NO == [self isFinished]) - { - /* Can change readiness if we are neither cancelled nor - * executing nor finished. So we need to observe for the - * finish of the dependency. - */ - [op addObserver: self - forKeyPath: @"isFinished" - options: NSKeyValueObservingOptionNew - context: NULL]; - if (internal->ready == YES) - { - /* The new dependency stops us being ready ... - * change state. - */ - [self willChangeValueForKey: @"isReady"]; - internal->ready = NO; - [self didChangeValueForKey: @"isReady"]; - } - } - [self didChangeValueForKey: @"dependencies"]; - } - } - NS_HANDLER - { - [internal->lock unlock]; - NSLog(@"Problem adding dependency: %@", localException); - return; - } - NS_ENDHANDLER - [internal->lock unlock]; -} - -- (void) cancel -{ - if (NO == internal->cancelled && NO == [self isFinished]) - { - [internal->lock lock]; - if (NO == internal->cancelled && NO == [self isFinished]) - { - NS_DURING - { - [self willChangeValueForKey: @"isCancelled"]; - internal->cancelled = YES; - if (NO == internal->ready) - { - [self willChangeValueForKey: @"isReady"]; - internal->ready = YES; - [self didChangeValueForKey: @"isReady"]; - } - [self didChangeValueForKey: @"isCancelled"]; - } - NS_HANDLER - { - [internal->lock unlock]; - NSLog(@"Problem cancelling operation: %@", localException); - return; - } - NS_ENDHANDLER - } - [internal->lock unlock]; - } -} - -- (void) dealloc -{ - if (internal != nil) - { - NSOperation *op; - - while ((op = [internal->dependencies lastObject]) != nil) - { - [self removeDependency: op]; - } - RELEASE(internal->dependencies); - RELEASE(internal->cond); - RELEASE(internal->lock); - GS_DESTROY_INTERNAL(NSOperation); - } - [super dealloc]; -} - -- (NSArray *) dependencies -{ - NSArray *a; - - if (internal->dependencies == nil) - { - a = empty; // OSX return an empty array - } - else - { - [internal->lock lock]; - a = [NSArray arrayWithArray: internal->dependencies]; - [internal->lock unlock]; - } - return a; -} - -- (id) init -{ - if ((self = [super init]) != nil) - { - GS_CREATE_INTERNAL(NSOperation); - internal->priority = NSOperationQueuePriorityNormal; - internal->threadPriority = 0.5; - internal->ready = YES; - internal->lock = [NSRecursiveLock new]; - internal->cond = [[NSConditionLock alloc] initWithCondition: 0]; - } - return self; -} - -- (BOOL) isCancelled -{ - return internal->cancelled; -} - -- (BOOL) isExecuting -{ - return internal->executing; -} - -- (BOOL) isFinished -{ - return internal->finished; -} - -- (BOOL) isConcurrent -{ - return internal->concurrent; -} - -- (BOOL) isReady -{ - return internal->ready; -} - -- (void) main; -{ - return; // OSX default implementation does nothing -} - -- (void) observeValueForKeyPath: (NSString *)keyPath - ofObject: (id)object - change: (NSDictionary *)change - context: (void *)context -{ - /* Some dependency has finished (or been removed) ... - * so we need to check to see if we are now ready unless we know we are. - * This is protected by locks so that an update due to an observed - * change in one thread won't interrupt anything in another thread. - */ - [internal->lock lock]; - if (NO == internal->ready) - { - NSEnumerator *en; - NSOperation *op; - - en = [internal->dependencies objectEnumerator]; - while ((op = [en nextObject]) != nil) - { - if (NO == [op isReady]) - break; - } - if (op == nil) - { - [self willChangeValueForKey: @"isReady"]; - internal->ready = YES; - [self didChangeValueForKey: @"isReady"]; - } - } - [internal->lock unlock]; -} - -- (NSOperationQueuePriority) queuePriority -{ - return internal->priority; -} - -- (void) removeDependency: (NSOperation *)op -{ - [internal->lock lock]; - NS_DURING - { - if (NSNotFound != [internal->dependencies indexOfObjectIdenticalTo: op]) - { - [op removeObserver: self - forKeyPath: @"isFinished"]; - [self willChangeValueForKey: @"dependencies"]; - [internal->dependencies removeObject: op]; - if (NO == internal->ready) - { - /* The dependency may cause us to become ready ... - * fake an observation so we can deal with that. - */ - [self observeValueForKeyPath: @"isFinished" - ofObject: op - change: nil - context: nil]; - } - [self didChangeValueForKey: @"dependencies"]; - } - } - NS_HANDLER - { - [internal->lock unlock]; - NSLog(@"Problem removing dependency: %@", localException); - return; - } - NS_ENDHANDLER - [internal->lock unlock]; -} - -- (void) setQueuePriority: (NSOperationQueuePriority)pri -{ - if (pri <= NSOperationQueuePriorityVeryLow) - pri = NSOperationQueuePriorityVeryLow; - else if (pri <= NSOperationQueuePriorityLow) - pri = NSOperationQueuePriorityLow; - else if (pri < NSOperationQueuePriorityHigh) - pri = NSOperationQueuePriorityNormal; - else if (pri < NSOperationQueuePriorityVeryHigh) - pri = NSOperationQueuePriorityHigh; - else - pri = NSOperationQueuePriorityVeryHigh; - - if (pri != internal->priority) - { - [internal->lock lock]; - if (pri != internal->priority) - { - NS_DURING - { - [self willChangeValueForKey: @"queuePriority"]; - internal->priority = pri; - [self didChangeValueForKey: @"queuePriority"]; - } - NS_HANDLER - { - [internal->lock unlock]; - NSLog(@"Problem setting priority: %@", localException); - return; - } - NS_ENDHANDLER - } - [internal->lock unlock]; - } -} - -- (void) setThreadPriority: (double)pri -{ - if (pri > 1) pri = 1; - else if (pri < 0) pri = 0; - internal->threadPriority = pri; -} - -- (void) start -{ - CREATE_AUTORELEASE_POOL(pool); - double prio = [NSThread threadPriority]; - - [internal->lock lock]; - NS_DURING - { - if (YES == [self isConcurrent]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] called on concurrent operation", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - if (YES == [self isExecuting]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] called on executing operation", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - if (YES == [self isFinished]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] called on finished operation", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - if (NO == [self isReady]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] called on operation which is not ready", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - - [self willChangeValueForKey: @"isExecuting"]; - internal->executing = YES; - [self didChangeValueForKey: @"isExecuting"]; - } - NS_HANDLER - { - [internal->lock unlock]; - [localException raise]; - } - NS_ENDHANDLER - [internal->lock unlock]; - - NS_DURING - { - if (NO == [self isCancelled]) - { - [NSThread setThreadPriority: internal->threadPriority]; - [self main]; - } - } - NS_HANDLER - { - [NSThread setThreadPriority: prio]; - [localException raise]; - } - NS_ENDHANDLER; - - [internal->lock lock]; - NS_DURING - { - /* Notify KVO system of changes to isExecuting and isFinished - */ - [self willChangeValueForKey: @"isExecuting"]; - [self willChangeValueForKey: @"isFinished"]; - internal->executing = NO; - internal->finished = YES; - [self didChangeValueForKey: @"isFinished"]; - [self didChangeValueForKey: @"isExecuting"]; - [internal->cond lock]; - [internal->cond unlockWithCondition: 1]; - } - NS_HANDLER - { - [internal->lock unlock]; - [localException raise]; - } - NS_ENDHANDLER - [internal->lock unlock]; - RELEASE(pool); -} - -- (double) threadPriority -{ - return internal->threadPriority; -} - -- (void) waitUntilFinished -{ - [internal->cond lockWhenCondition: 1]; // Wait for finish - [internal->cond unlockWithCondition: 1]; // Signal any other watchers -} -@end - - -#undef GSInternal -#define GSInternal NSOperationQueueInternal -#include "GSInternal.h" -GS_PRIVATE_INTERNAL(NSOperationQueue) - - -@interface NSOperationQueue (Private) -+ (void) _mainQueue; -- (void) observeValueForKeyPath: (NSString *)keyPath - ofObject: (id)object - change: (NSDictionary *)change - context: (void *)context; -- (void) _thread; -- (void) _updateThreads; -@end - -static NSInteger maxThreads = 200; // FIXME ... how many really? - -static NSComparisonResult -sortFunc(id o1, id o2, void *ctxt) -{ - NSOperationQueuePriority p1 = [o1 queuePriority]; - NSOperationQueuePriority p2 = [o2 queuePriority]; - - if (p1 < p2) return NSOrderedDescending; - if (p1 > p2) return NSOrderedAscending; - return NSOrderedSame; -} - -static NSString *threadKey = @"NSOperationQueue"; -static NSOperationQueue *mainQueue = nil; - -@implementation NSOperationQueue - -+ (id) currentQueue -{ - return [[[NSThread currentThread] threadDictionary] objectForKey: threadKey]; -} - -+ (void) initialize -{ - if (mainQueue == nil) - { - [self performSelectorOnMainThread: @selector(_mainQueue) - withObject: nil - waitUntilDone: YES]; - } -} - -+ (id) mainQueue -{ - return mainQueue; -} - -- (void) addOperation: (NSOperation *)op -{ - if (op == nil || NO == [op isKindOfClass: [NSOperation class]]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] object is not an NSOperation", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - [internal->lock lock]; - if (NSNotFound == [internal->operations indexOfObjectIdenticalTo: op] - && NO == [op isFinished]) - { - [op addObserver: self - forKeyPath: @"isReady" - options: NSKeyValueObservingOptionNew - context: NULL]; - [self willChangeValueForKey: @"operations"]; - [self willChangeValueForKey: @"operationCount"]; - [internal->operations addObject: op]; - [self didChangeValueForKey: @"operationCount"]; - [self didChangeValueForKey: @"operations"]; - if (YES == [op isReady]) - { - [self observeValueForKeyPath: @"isReady" - ofObject: op - change: nil - context: nil]; - } - } - [internal->lock unlock]; -} - -- (void) addOperations: (NSArray *)ops - waitUntilFinished: (BOOL)shouldWait -{ - NSUInteger total; - NSUInteger index; - - if (ops == nil || NO == [ops isKindOfClass: [NSArray class]]) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] object is not an NSArray", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - total = [ops count]; - if (total > 0) - { - BOOL invalidArg = NO; - GS_BEGINITEMBUF(buf, total, id) - NSUInteger toAdd = total; - - [ops getObjects: buf]; - for (index = 0; index < total; index++) - { - NSOperation *op = buf[index]; - - if (NO == [op isKindOfClass: [NSOperation class]]) - { - invalidArg = YES; - toAdd = 0; - break; - } - if (YES == [op isFinished]) - { - buf[index] = nil; - toAdd--; - } - } - if (toAdd > 0) - { - [internal->lock lock]; - [self willChangeValueForKey: @"operationCount"]; - [self willChangeValueForKey: @"operations"]; - for (index = 0; index < total; index++) - { - NSOperation *op = buf[index]; - - if (op == nil) - { - continue; // Not added - } - if (NSNotFound - != [internal->operations indexOfObjectIdenticalTo: op]) - { - buf[index] = nil; // Not added - toAdd--; - continue; - } - [op addObserver: self - forKeyPath: @"isReady" - options: NSKeyValueObservingOptionNew - context: NULL]; - [internal->operations addObject: op]; - if (NO == [op isReady]) - { - buf[index] = nil; // Not yet ready - } - } - [self didChangeValueForKey: @"operationCount"]; - [self didChangeValueForKey: @"operations"]; - for (index = 0; index < total; index++) - { - NSOperation *op = buf[index]; - - if (op != nil) - { - [self observeValueForKeyPath: @"isReady" - ofObject: op - change: nil - context: nil]; - } - } - [internal->lock unlock]; - } - GS_ENDITEMBUF() - if (YES == invalidArg) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] object at index %u is not an NSOperation", - NSStringFromClass([self class]), NSStringFromSelector(_cmd), - index]; - } - } - if (YES == shouldWait) - { - [self waitUntilAllOperationsAreFinished]; - } -} - -- (void) cancelAllOperations -{ - NSUInteger index; - NSOperation *o; - - [internal->cond lock]; - while ((o = [internal->waiting lastObject]) != nil) - { - [o removeObserver: self - forKeyPath: @"isReady"]; - [o cancel]; - [internal->waiting removeLastObject]; - } - [internal->cond unlockWithCondition: 0]; // Nothing waiting to execute - - [internal->lock lock]; - index = [internal->operations count]; - while (index-- > 0) - { - NSOperation *o; - - o = [internal->operations objectAtIndex: index]; - if (NO == [o isCancelled]) - { - [o removeObserver: self - forKeyPath: @"isReady"]; - [o cancel]; - } - } - [internal->lock unlock]; -} - -- (void) dealloc -{ - [internal->operations release]; - [internal->waiting release]; - [internal->name release]; - [internal->cond release]; - [internal->lock release]; - GS_DESTROY_INTERNAL(NSOperationQueue); - [super dealloc]; -} - -- (id) init -{ - if ((self = [super init]) != nil) - { - GS_CREATE_INTERNAL(NSOperationQueue); - internal->suspended = NO; - internal->count = NSOperationQueueDefaultMaxConcurrentOperationCount; - internal->operations = [NSMutableArray new]; - internal->waiting = [NSMutableArray new]; - internal->cond = [[NSConditionLock alloc] initWithCondition: 0]; - internal->lock = [NSRecursiveLock new]; - } - return self; -} - -- (BOOL) isSuspended -{ - return internal->suspended; -} - -- (NSInteger) maxConcurrentOperationCount -{ - return internal->count; -} - -- (NSString*) name -{ - NSString *s; - - [internal->lock lock]; - if (internal->name == nil) - { - internal->name - = [[NSString alloc] initWithFormat: @"NSOperation %p", self]; - } - s = [internal->name retain]; - [internal->lock unlock]; - return [s autorelease]; -} - -- (NSUInteger) operationCount -{ - NSUInteger c; - - [internal->lock lock]; - c = [internal->operations count]; - [internal->lock unlock]; - return c; -} - -- (NSArray *) operations -{ - NSArray *a; - - [internal->lock lock]; - a = [NSArray arrayWithArray: internal->operations]; - [internal->lock unlock]; - return a; -} - -- (void) setMaxConcurrentOperationCount: (NSInteger)cnt -{ - BOOL unSuspend = NO; - - if (cnt < 0 - && cnt != NSOperationQueueDefaultMaxConcurrentOperationCount) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] cannot set negative (%d) count", - NSStringFromClass([self class]), NSStringFromSelector(_cmd), cnt]; - } - [internal->lock lock]; - if (cnt != internal->count) - { - if (cnt > internal->count) - { - unSuspend = YES; // May need to add more threads. - } - [self willChangeValueForKey: @"maxConcurrentOperationCount"]; - internal->count = cnt; - [self didChangeValueForKey: @"maxConcurrentOperationCount"]; - } - [internal->lock unlock]; - if (YES == unSuspend) - { - [internal->cond lock]; - if ([internal->waiting count] > 0) - { - [internal->cond unlockWithCondition: 1]; - [self _updateThreads]; - } - else - { - [internal->cond unlockWithCondition: 0]; - } - } -} - -- (void) setName: (NSString*)s -{ - if (s == nil) s = @""; - [internal->lock lock]; - if (NO == [internal->name isEqual: s]) - { - [self willChangeValueForKey: @"name"]; - [internal->name release]; - internal->name = [s copy]; - [self didChangeValueForKey: @"name"]; - } - [internal->lock unlock]; -} - -- (void) setSuspended: (BOOL)flag -{ - BOOL unSuspend = NO; - - [internal->lock lock]; - if (flag != internal->suspended) - { - if (YES == flag) - { - unSuspend = YES; - } - [self willChangeValueForKey: @"suspended"]; - internal->suspended = flag; - [self didChangeValueForKey: @"suspended"]; - } - [internal->lock unlock]; - if (YES == unSuspend) - { - [internal->cond lock]; - if ([internal->waiting count] > 0) - { - [internal->cond unlockWithCondition: 1]; - [self _updateThreads]; - } - else - { - [internal->cond unlockWithCondition: 0]; - } - } -} - -- (void) waitUntilAllOperationsAreFinished -{ - NSOperation *op; - - [internal->lock lock]; - while ((op = [internal->operations lastObject]) != nil) - { - [op retain]; - [internal->lock unlock]; - [op waitUntilFinished]; - [op release]; - [internal->lock lock]; - } - [internal->lock unlock]; -} -@end - -@implementation NSOperationQueue (Private) - -+ (void) _mainQueue -{ - if (mainQueue == nil) - { - mainQueue = [self new]; - [[[NSThread currentThread] threadDictionary] setObject: mainQueue - forKey: threadKey]; - } -} - -- (void) observeValueForKeyPath: (NSString *)keyPath - ofObject: (id)object - change: (NSDictionary *)change - context: (void *)context -{ - [internal->cond lock]; - if (YES == [object isReady]) - { - if ([internal->waiting indexOfObjectIdenticalTo: object] == NSNotFound) - { - [internal->waiting addObject: object]; - } - } - else - { - NSUInteger index; - - index = [internal->waiting indexOfObjectIdenticalTo: object]; - if (index != NSNotFound) - { - [internal->waiting removeObjectAtIndex: index]; - } - } - if ([internal->waiting count] > 0) - { - [internal->cond unlockWithCondition: 1]; - [self _updateThreads]; - } - else - { - [internal->cond unlockWithCondition: 0]; - } -} - -- (void) _thread -{ - BOOL terminate = NO; - - /* Record which operation queue the current thread is running. - */ - [[[NSThread currentThread] threadDictionary] setObject: self - forKey: threadKey]; - - [internal->lock lock]; - while (NO == terminate) - { - NSOperation *op; - NSUInteger index; - NSDate *timeout; - - /* Unlock the queue while we are waiting for another operation - * to perform. - */ - [internal->lock unlock]; - - /* Wait for an operation to become available. - * If there's nothing to do within 5 seconds, we might terminate, - * but only if there are no operations still queued. - * The figure 5 was chosen because it seems to be what OSX 10.6 uses. - */ - timeout = [[NSDate alloc] initWithTimeIntervalSinceNow: 5.0]; - if (NO == [internal->cond lockWhenCondition: 1 beforeDate: timeout]) - { - terminate = YES; - } - [timeout release]; - if (NO == terminate) - { - op = nil; - - if ((unsigned)internal->threads > (unsigned)internal->count) - { - /* We know that the 'unlimited' thread count is -1 so an - * unsigned comparison is safe to tell is we need to end - * a thread. - */ - terminate = YES; // This thread is not needed - } - else if (internal->count != 0 && NO == internal->suspended - && [internal->waiting count] > 0) - { - /* If concurrent operations are permitted an the queue - * is not suspended, and there are operations waiting, - * then we can get one. - */ - [internal->waiting sortUsingFunction: sortFunc context: 0]; - op = [[internal->waiting objectAtIndex: 0] retain]; - [internal->waiting removeObjectAtIndex: 0]; - } - if ([internal->waiting count] == 0) - { - [internal->cond unlockWithCondition: 0]; - } - else - { - [internal->cond unlockWithCondition: 1]; - } - - /* Restore the queue lock - */ - [internal->lock lock]; - if (YES == [op isReady]) - { - if (NO == [op isCancelled]) - { - internal->idle--; - - /* Unlock the queue while the operation is executing. - */ - [internal->lock unlock]; - [op start]; - [op waitUntilFinished]; - - /* Lock the queue again to perform cleanup etc. - */ - [internal->lock lock]; - internal->idle++; - } - [self willChangeValueForKey: @"operations"]; - [self willChangeValueForKey: @"operationCount"]; - [internal->operations removeObjectIdenticalTo: op]; - [self didChangeValueForKey: @"operationCount"]; - [self didChangeValueForKey: @"operations"]; - } - [op release]; - } - else - { - /* Restore the queue lock so we can clean up operations in queue. - */ - [internal->lock lock]; - } - - /* And now make sure we clean up any finished operations. - */ - index = [internal->operations count]; - while (index-- > 0) - { - op = [internal->operations objectAtIndex: index]; - if (YES == [op isFinished]) - { - [self willChangeValueForKey: @"operations"]; - [self willChangeValueForKey: @"operationCount"]; - [internal->operations removeObjectAtIndex: index]; - [self didChangeValueForKey: @"operationCount"]; - [self didChangeValueForKey: @"operations"]; - } - } - if ([internal->operations count] > 0) - { - terminate = NO; // Still stuff to do - } - } - internal->idle--; - internal->threads--; - [internal->lock unlock]; -} - -/* Just check to see if a new thread needs to be started. - */ -- (void) _updateThreads -{ - [internal->lock lock]; - if (0 == internal->idle - && NO == [self isSuspended] - && [self maxConcurrentOperationCount] != 0 - && [internal->waiting count] > 0) - { - NSInteger total = internal->count; - - if (total == NSOperationQueueDefaultMaxConcurrentOperationCount) - { - total = maxThreads; // Limit number of allowed threads - } - if (internal->threads < total) - { - /* All threads are in use, but we don't have the maximum - * number of threads, so we can create a new one for the - * waiting operation. - */ - internal->threads++; - internal->idle++; - [NSThread detachNewThreadSelector: @selector(_thread) - toTarget: self - withObject: nil]; - } - } - [internal->lock unlock]; -} - -@end - diff --git a/Source/NSPage.m b/Source/NSPage.m index 5b91acb96..06c526e0f 100644 --- a/Source/NSPage.m +++ b/Source/NSPage.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,7 +25,10 @@ $Date$ $Revision$ */ -#import "common.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSZone.h" #include #ifdef HAVE_UNISTD_H #include @@ -35,11 +38,16 @@ #include #endif +#if __linux__ +#include +#include +#endif + #ifdef __CYGWIN__ #include #endif -#ifdef __MINGW__ +#ifdef __MINGW32__ #include static size_t getpagesize(void) @@ -69,27 +77,27 @@ getpagesize(void) /* Cache the size of a memory page here, so we don't have to make the getpagesize() system call repeatedly. */ -static NSUInteger ns_page_size = 0; +static unsigned ns_page_size = 0; /** * Return the number of bytes in a memory page. */ -NSUInteger +unsigned NSPageSize (void) { if (!ns_page_size) - ns_page_size = getpagesize (); + ns_page_size = (unsigned) getpagesize (); return ns_page_size; } /** * Return log base 2 of the number of bytes in a memory page. */ -NSUInteger +unsigned NSLogPageSize (void) { - NSUInteger tmp_page_size = NSPageSize(); - NSUInteger log = 0; + unsigned tmp_page_size = NSPageSize(); + unsigned log = 0; while (tmp_page_size >>= 1) log++; @@ -100,10 +108,10 @@ NSLogPageSize (void) * Round bytes down to the nearest multiple of the memory page size, * and return it. */ -NSUInteger -NSRoundDownToMultipleOfPageSize (NSUInteger bytes) +unsigned +NSRoundDownToMultipleOfPageSize (unsigned bytes) { - NSUInteger a = NSPageSize(); + unsigned a = NSPageSize(); return (bytes / a) * a; } @@ -112,10 +120,10 @@ NSRoundDownToMultipleOfPageSize (NSUInteger bytes) * Round bytes up to the nearest multiple of the memory page size, * and return it. */ -NSUInteger -NSRoundUpToMultipleOfPageSize (NSUInteger bytes) +unsigned +NSRoundUpToMultipleOfPageSize (unsigned bytes) { - NSUInteger a = NSPageSize(); + unsigned a = NSPageSize(); return ((bytes % a) ? ((bytes / a + 1) * a) : bytes); } @@ -127,7 +135,7 @@ NSRoundUpToMultipleOfPageSize (NSUInteger bytes) /** * Return the number of bytes of real (physical) memory available. */ -NSUInteger +unsigned NSRealMemoryAvailable () { #if __linux__ @@ -135,19 +143,18 @@ NSRealMemoryAvailable () if ((sysinfo(&info)) != 0) return 0; - return info.freeram; -#elif defined(__MINGW__) - MEMORYSTATUSEX memory; + return (unsigned) info.freeram; +#elif defined(__MINGW32__) + MEMORYSTATUS memory; - memory.dwLength = sizeof(memory); - GlobalMemoryStatusEx(&memory); - return memory.ullAvailPhys; + GlobalMemoryStatus(&memory); + return (unsigned)memory.dwAvailPhys; #elif defined(__BEOS__) system_info info; if (get_system_info(&info) != B_OK) return 0; - return (info.max_pages - info.used_pages) * B_PAGE_SIZE; + return (unsigned)(info.max_pages - info.used_pages) * B_PAGE_SIZE; #else fprintf (stderr, "NSRealMemoryAvailable() not implemented.\n"); return 0; @@ -156,49 +163,38 @@ NSRealMemoryAvailable () /** * Allocate memory for this process and return a pointer to it (or a null - * pointer on failure). The allocated memory is page aligned and the - * actual size of memory allocated is a multiple of the page size. + * pointer on failure). */ void * -NSAllocateMemoryPages (NSUInteger bytes) +NSAllocateMemoryPages (unsigned bytes) { - NSUInteger size = NSRoundUpToMultipleOfPageSize (bytes); void *where; -#if defined(__MINGW__) - where = VirtualAlloc(NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); -#elif __mach__ +#if __mach__ kern_return_t r; - r = vm_allocate (mach_task_self(), &where, (vm_size_t) size, 1); + r = vm_allocate (mach_task_self(), &where, (vm_size_t) bytes, 1); if (r != KERN_SUCCESS) return NULL; return where; -#elif HAVE_POSIX_MEMALIGN - if (posix_memalign(&where, NSPageSize(), size) != 0) - return NULL; #else - where = valloc (size); + where = objc_valloc (bytes); if (where == NULL) return NULL; -#endif memset (where, 0, bytes); return where; +#endif } /** * Deallocate memory which was previously allocated using the - * NSAllocateMemoryPages() function.
- * The bytes argument should be the same as the value passed - * to the NSAllocateMemoryPages() function. + * NSAllocateMemoryPages() function. */ void -NSDeallocateMemoryPages (void *ptr, NSUInteger bytes) +NSDeallocateMemoryPages (void *ptr, unsigned bytes) { -#if defined(__MINGW__) - VirtualFree(ptr, 0, MEM_RELEASE); -#elif __mach__ - vm_deallocate (mach_task_self (), ptr, NSRoundUpToMultipleOfPageSize (bytes)); +#if __mach__ + vm_deallocate (mach_task_self (), ptr, bytes); #else - free (ptr); + objc_free (ptr); #endif } @@ -207,7 +203,7 @@ NSDeallocateMemoryPages (void *ptr, NSUInteger bytes) * The value bytes specifies the length of the data copied. */ void -NSCopyMemoryPages (const void *src, void *dest, NSUInteger bytes) +NSCopyMemoryPages (const void *src, void *dest, unsigned bytes) { #if __mach__ kern_return_t r; diff --git a/Source/NSPathUtilities.m b/Source/NSPathUtilities.m index 028005f11..5f1a417fe 100644 --- a/Source/NSPathUtilities.m +++ b/Source/NSPathUtilities.m @@ -11,7 +11,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -20,7 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -54,30 +54,31 @@ */ -/* The following define is needed for Solaris get(pw/gr)(nam/uid)_r declartions - which default to pre POSIX declaration. */ -#define _POSIX_PTHREAD_SEMANTICS - -#import "common.h" +#include "config.h" +#include "GNUstepBase/preface.h" #include "objc-load.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSException.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSUserDefaults.h" -#import "GNUstepBase/NSString+GNUstepBase.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSString.h" +#include "Foundation/NSPathUtilities.h" +#include "Foundation/NSException.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSDebug.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSString.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSUserDefaults.h" +#include "GNUstepBase/GSCategories.h" -#import "GSPrivate.h" +#include "GSPrivate.h" #ifdef HAVE_UNISTD_H #include // for getuid() #endif #ifdef HAVE_PWD_H -#include // for getpwnam_r() and getpwuid_r() +#include // for getpwnam() #endif #include #include @@ -117,9 +118,8 @@ static NSString *gnustep_is_flattened = nil; #endif -#if defined(__MINGW__) +#if defined(__MINGW32__) -#include #include /* @@ -138,9 +138,8 @@ static NSString *gnustep_is_flattened = static NSString *gnustepConfigPath = nil; +static NSString *gnustepUserDir = nil; static NSString *gnustepUserHome = nil; -static NSString *gnustepUserID = nil; -static NSString *gnustepUserName = nil; static NSString *gnustepUserDefaultsDir = nil; static NSString *theUserName = nil; /* The user's login name */ @@ -239,10 +238,6 @@ static void ShutdownPathUtilities(void); }\ }) -/* Grab a path from the config file, making it relative to the config - * file location if it begins with './' or '../', and checking that the - * result is an absolute path. - */ #define ASSIGN_PATH(var, dictionary, key) ({\ id val = getPathConfig(dictionary, key);\ if (val != nil)\ @@ -253,23 +248,6 @@ static void ShutdownPathUtilities(void); }\ }) -/* Like ASSIGN_PATH(), but permits the result to be a relative path as that - * is what we normally use (the path is within the user's home directory). - */ -#define ASSIGN_USER(var, dictionary, key) ({\ - id val = [dictionary objectForKey: key];\ - if (val != nil)\ - {\ - val = getPath(val);\ - }\ - if (val != nil)\ - {\ - RELEASE(var);\ - var = RETAIN(val);\ - [dictionary removeObjectForKey: key];\ - }\ -}) - /* Conditionally assign lval to var only if var is nil */ #define TEST_ASSIGN(var, lval) ({\ if ((var == nil)&&(lval != nil))\ @@ -286,77 +264,6 @@ static void ShutdownPathUtilities(void); }\ }) -/* The user domain paths are normally located within the user's home directory, - * but if they are specified as absolute paths they can be anywhere you like. - * - */ -#define ASSIGN_USER_PATH(var, val) ({\ - if (nil == var) \ - {\ - ASSIGN(var, ([val isAbsolutePath] ? substUser(val) : \ - [gnustepUserHome stringByAppendingPathComponent: substUser(val)]));\ - }\ - }) - -/* For user domain paths, we allow '%u' as the username, '%i' as the userid, - * and '%%' as a '%' in cases where it would otherwise be treated as a - * username or userid. - */ -static NSString* -substUser(NSString *str) -{ - if (str != nil && [str rangeOfString: @"%"].length > 0) - { - NSMutableString *m = [[str mutableCopy] autorelease]; - int l = [m length]; - int i = 0; - BOOL percent = NO; - - while (i < l) - { - unichar c = [m characterAtIndex: i]; - - if (YES == percent) - { - NSString *s; - - if (c == '%') - { - s = @"%"; // Escaped percent - } - else if (c == 'i') - { - s = gnustepUserID; // User ID - } - else if (c == 'u') - { - s = gnustepUserName; // User name - } - else - { - s = nil; // No substitution - } - if (s != nil) - { - int diff = [s length] - 2; - - [m replaceCharactersInRange: NSMakeRange(i-1, 2) - withString: s]; - l += diff; - i += diff; - } - percent = NO; - } - else if (c == '%') - { - percent = YES; - } - i++; - } - str = m; - } - return str; -} /* Get a full path string */ static inline NSString * @@ -368,11 +275,6 @@ getPath(NSString *path) [path substringFromIndex: 2]]; path = [path stringByStandardizingPath]; } - else if ([path hasPrefix: @"../"] == YES) - { - path = [gnustepConfigPath stringByAppendingPathComponent: path]; - path = [path stringByStandardizingPath]; - } return path; } @@ -397,8 +299,8 @@ getPathConfig(NSDictionary *dict, NSString *key) unichar buf[3]; [path getCharacters: buf range: NSMakeRange(0, 3)]; - if ((buf[0] == '/' || buf[0] == '\\') && isalpha(buf[1]) - && (buf[2] == '/' || buf[2] == '\\')) + if ((buf[0] == '/' || bug[0] == '\\') && isalpha(buf[1]) + && (buf[2] == '/' || bug[2] == '\\')) { path = [NSString stringWithFormat: @"%c:%@", (char)buf[1], [path substringFromindex: 2]]; @@ -416,11 +318,12 @@ getPathConfig(NSDictionary *dict, NSString *key) static void ExtractValuesFromConfig(NSDictionary *config) { NSMutableDictionary *c = [config mutableCopy]; - id extra; + NSString *extra; /* * Move values out of the dictionary and into variables for rapid reference. */ + ASSIGN_IF_SET(gnustepUserDir, c, @"GNUSTEP_USER_DIR"); ASSIGN_IF_SET(gnustepUserDefaultsDir, c, @"GNUSTEP_USER_DEFAULTS_DIR"); ASSIGN_PATH(gnustepMakefiles, c, @"GNUSTEP_MAKEFILES"); @@ -465,28 +368,17 @@ static void ExtractValuesFromConfig(NSDictionary *config) ASSIGN_PATH(gnustepLocalDocumentationMan, c, @"GNUSTEP_LOCAL_DOC_MAN"); ASSIGN_PATH(gnustepLocalDocumentationInfo, c, @"GNUSTEP_LOCAL_DOC_INFO"); - ASSIGN_USER(gnustepUserDirApps, c, @"GNUSTEP_USER_DIR_APPS"); - TEST_ASSIGN(gnustepUserDirApps, @GNUSTEP_TARGET_USER_DIR_APPS); - ASSIGN_USER(gnustepUserDirAdminApps, c, @"GNUSTEP_USER_DIR_ADMIN_APPS"); - TEST_ASSIGN(gnustepUserDirAdminApps, @GNUSTEP_TARGET_USER_DIR_ADMIN_APPS); - ASSIGN_USER(gnustepUserDirWebApps, c, @"GNUSTEP_USER_DIR_WEB_APPS"); - TEST_ASSIGN(gnustepUserDirWebApps, @GNUSTEP_TARGET_USER_DIR_WEB_APPS); - ASSIGN_USER(gnustepUserDirTools, c, @"GNUSTEP_USER_DIR_TOOLS"); - TEST_ASSIGN(gnustepUserDirTools, @GNUSTEP_TARGET_USER_DIR_TOOLS); - ASSIGN_USER(gnustepUserDirAdminTools, c, @"GNUSTEP_USER_DIR_ADMIN_TOOLS"); - TEST_ASSIGN(gnustepUserDirAdminTools, @GNUSTEP_TARGET_USER_DIR_ADMIN_TOOLS); - ASSIGN_USER(gnustepUserDirLibrary, c, @"GNUSTEP_USER_DIR_LIBRARY"); - TEST_ASSIGN(gnustepUserDirLibrary, @GNUSTEP_TARGET_USER_DIR_LIBRARY); - ASSIGN_USER(gnustepUserDirLibraries, c, @"GNUSTEP_USER_DIR_LIBRARIES"); - TEST_ASSIGN(gnustepUserDirLibraries, @GNUSTEP_TARGET_USER_DIR_LIBRARIES); - ASSIGN_USER(gnustepUserDirHeaders, c, @"GNUSTEP_USER_DIR_HEADERS"); - TEST_ASSIGN(gnustepUserDirHeaders, @GNUSTEP_TARGET_USER_DIR_HEADERS); - ASSIGN_USER(gnustepUserDirDocumentation, c, @"GNUSTEP_USER_DIR_DOC"); - TEST_ASSIGN(gnustepUserDirDocumentation, @GNUSTEP_TARGET_USER_DIR_DOC); - ASSIGN_USER(gnustepUserDirDocumentationMan, c, @"GNUSTEP_USER_DIR_DOC_MAN"); - TEST_ASSIGN(gnustepUserDirDocumentationMan, @GNUSTEP_TARGET_USER_DIR_DOC_MAN); - ASSIGN_USER(gnustepUserDirDocumentationInfo, c, @"GNUSTEP_USER_DIR_DOC_INFO"); - TEST_ASSIGN(gnustepUserDirDocumentationInfo, @GNUSTEP_TARGET_USER_DIR_DOC_INFO); + ASSIGN_IF_SET(gnustepUserDirApps, c, @"GNUSTEP_USER_DIR_APPS"); + ASSIGN_IF_SET(gnustepUserDirAdminApps, c, @"GNUSTEP_USER_DIR_ADMIN_APPS"); + ASSIGN_IF_SET(gnustepUserDirWebApps, c, @"GNUSTEP_USER_DIR_WEB_APPS"); + ASSIGN_IF_SET(gnustepUserDirTools, c, @"GNUSTEP_USER_DIR_TOOLS"); + ASSIGN_IF_SET(gnustepUserDirAdminTools, c, @"GNUSTEP_USER_DIR_ADMIN_TOOLS"); + ASSIGN_IF_SET(gnustepUserDirLibrary, c, @"GNUSTEP_USER_DIR_LIBRARY"); + ASSIGN_IF_SET(gnustepUserDirLibraries, c, @"GNUSTEP_USER_DIR_LIBRARIES"); + ASSIGN_IF_SET(gnustepUserDirHeaders, c, @"GNUSTEP_USER_DIR_HEADERS"); + ASSIGN_IF_SET(gnustepUserDirDocumentation, c, @"GNUSTEP_USER_DIR_DOC"); + ASSIGN_IF_SET(gnustepUserDirDocumentationMan, c, @"GNUSTEP_USER_DIR_DOC_MAN"); + ASSIGN_IF_SET(gnustepUserDirDocumentationInfo, c, @"GNUSTEP_USER_DIR_DOC_INFO"); /* * The GNUSTEP_EXTRA field may contain a list of extra keys which @@ -498,11 +390,7 @@ static void ExtractValuesFromConfig(NSDictionary *config) NSEnumerator *enumerator; NSString *key; - if ([extra isKindOfClass: [NSString class]] == YES) - { - extra = [extra componentsSeparatedByString: @","]; - } - enumerator = [extra objectEnumerator]; + enumerator = [[extra componentsSeparatedByString: @","] objectEnumerator]; [c removeObjectForKey: @"GNUSTEP_EXTRA"]; while ((key = [enumerator nextObject]) != nil) { @@ -510,7 +398,6 @@ static void ExtractValuesFromConfig(NSDictionary *config) [c removeObjectForKey: key]; } } - [c removeObjectForKey: @"GNUSTEP_SYSTEM_DEFAULTS_FILE"]; /* * Remove any other dictionary entries we have used. @@ -522,7 +409,6 @@ static void ExtractValuesFromConfig(NSDictionary *config) [c removeObjectForKey: @"GNUSTEP_LOCAL_ROOT"]; [c removeObjectForKey: @"GNUSTEP_SYSTEM_ROOT"]; [c removeObjectForKey: @"GNUSTEP_NETWORK_ROOT"]; - [c removeObjectForKey: @"GNUSTEP_USER_DIR"]; if ([c count] > 0) { @@ -537,6 +423,10 @@ static void ExtractValuesFromConfig(NSDictionary *config) /* * Set default locations for user files if necessary. */ + if (gnustepUserDir == nil) + { + ASSIGN(gnustepUserDir, @GNUSTEP_TARGET_USER_DIR); + } if (gnustepUserDefaultsDir == nil) { ASSIGN(gnustepUserDefaultsDir, @GNUSTEP_TARGET_USER_DEFAULTS_DIR); @@ -581,17 +471,41 @@ static void ExtractValuesFromConfig(NSDictionary *config) * Set the GNUSTEP_USER_xxx variables from the user home and the * GNUSTEP_USER_DIR_xxx variables. */ - ASSIGN_USER_PATH(gnustepUserApps, gnustepUserDirApps); - ASSIGN_USER_PATH(gnustepUserAdminApps, gnustepUserDirAdminApps); - ASSIGN_USER_PATH(gnustepUserWebApps, gnustepUserDirWebApps); - ASSIGN_USER_PATH(gnustepUserTools, gnustepUserDirTools); - ASSIGN_USER_PATH(gnustepUserAdminTools, gnustepUserDirAdminTools); - ASSIGN_USER_PATH(gnustepUserLibrary, gnustepUserDirLibrary); - ASSIGN_USER_PATH(gnustepUserLibraries, gnustepUserDirLibraries); - ASSIGN_USER_PATH(gnustepUserHeaders, gnustepUserDirHeaders); - ASSIGN_USER_PATH(gnustepUserDocumentation, gnustepUserDocumentation); - ASSIGN_USER_PATH(gnustepUserDocumentationMan, gnustepUserDocumentationMan); - ASSIGN_USER_PATH(gnustepUserDocumentationInfo, gnustepUserDocumentationInfo); + ASSIGN(gnustepUserApps, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirApps]); + + ASSIGN(gnustepUserAdminApps, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirAdminApps]); + + ASSIGN(gnustepUserWebApps, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirWebApps]); + + ASSIGN(gnustepUserTools, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirTools]); + + ASSIGN(gnustepUserAdminTools, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirAdminTools]); + + ASSIGN(gnustepUserLibrary, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirLibrary]); + + ASSIGN(gnustepUserLibraries, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirLibraries]); + + ASSIGN(gnustepUserHeaders, + [gnustepUserHome stringByAppendingPathComponent: gnustepUserDirHeaders]); + + ASSIGN(gnustepUserDocumentation, + [gnustepUserHome stringByAppendingPathComponent: + gnustepUserDocumentation]); + + ASSIGN(gnustepUserDocumentationMan, + [gnustepUserHome stringByAppendingPathComponent: + gnustepUserDocumentationMan]); + + ASSIGN(gnustepUserDocumentationInfo, + [gnustepUserHome stringByAppendingPathComponent: + gnustepUserDocumentationInfo]); /* * Try to ensure that essential user directories exist. @@ -705,21 +619,18 @@ GNUstepConfig(NSDictionary *newConfig) /* * Special case ... if the config file location begins './' - * or '../' then we determine it's actual path by working - * relative to the gnustep-base library. + * then we determine it's actual path by working relative + * to the gnustep-base library. */ - if ([file hasPrefix: @"./"] == YES - || [file hasPrefix: @"../"] == YES) + if ([file hasPrefix: @"./"] == YES) { Class c = [NSProcessInfo class]; NSString *path = GSPrivateSymbolPath (c, 0); // Remove library name from path path = [path stringByDeletingLastPathComponent]; - if ([file hasPrefix: @"./"] == YES) - { - file = [file substringFromIndex: 2]; - } + // Remove ./ prefix from filename + file = [file substringFromIndex: 2]; // Join the two together file = [path stringByAppendingPathComponent: file]; } @@ -763,82 +674,9 @@ GNUstepConfig(NSDictionary *newConfig) } else { - NSString *defs; - gnustepConfigPath = RETAIN([file stringByDeletingLastPathComponent]); ParseConfigurationFile(file, conf, nil); - - defs = [gnustepConfigPath stringByAppendingPathComponent: - @"GlobalDefaults.plist"]; - if ([MGR() isReadableFileAtPath: defs] == YES) - { - NSDictionary *d; - NSDictionary *attributes; - - attributes = [MGR() fileAttributesAtPath: defs - traverseLink: YES]; - if (([attributes filePosixPermissions] - & (0022 & ATTRMASK)) != 0) - { -#if defined(__MINGW__) - fprintf(stderr, - "The file '%S' is writable by someone other than" - " its owner (permissions 0%lo).\nIgnoring it.\n", - [defs fileSystemRepresentation], - (long)[attributes filePosixPermissions]); -#else - fprintf(stderr, - "The file '%s' is writable by someone other than" - " its owner (permissions 0%lo).\nIgnoring it.\n", - [defs fileSystemRepresentation], - (long)[attributes filePosixPermissions]); -#endif - d = nil; - } - else - { - d = [NSDictionary dictionaryWithContentsOfFile: defs]; - } - - if (d != nil) - { - NSEnumerator *enumerator; - NSString *key; - id extra; - - extra = [conf objectForKey: @"GNUSTEP_EXTRA"]; - extra = [extra componentsSeparatedByString: @","]; - extra = [extra mutableCopy]; - if (extra == nil) - { - extra = [NSMutableArray new]; - } - enumerator = [d keyEnumerator]; - while ((key = [enumerator nextObject]) != nil) - { - if ([conf objectForKey: key] == nil) - { - [extra addObject: key]; - } - else - { - fprintf(stderr, "Key '%s' in '%s' duplicates" - " key in %s\n", [key UTF8String], - [defs UTF8String], [file UTF8String]); - } - } - [conf addEntriesFromDictionary: d]; - if ([extra count] > 0) - { - NSArray *c = [extra copy]; - - [conf setObject: c forKey: @"GNUSTEP_EXTRA"]; - RELEASE(c); - } - RELEASE(extra); - } - } } } else @@ -938,50 +776,14 @@ static void InitialisePathUtilities(void) /* Set up our root paths */ NS_DURING { + NSString *userName; NSMutableDictionary *config; [gnustep_global_lock lock]; - gnustepUserName = [NSUserName() copy]; -#if defined(__MINGW__) - { - union { - SID sid; - char dummy[1024]; - } s; - LPTSTR str; - unichar buf[1024]; - unichar dom[1024]; - SID_NAME_USE use; - DWORD bsize = 1024; - DWORD ssize = 1024; - - if (GetUserNameW(buf, &bsize) == 0 || buf[0] == '\0') - { - [NSException raise: NSInternalInconsistencyException - format: @"Unable to determine current user name: %@", - [NSError _last]]; - } - bsize = 1024; - if (LookupAccountNameW(0, buf, &s.sid, &ssize, dom, &bsize, &use) == 0) - { - [NSException raise: NSInternalInconsistencyException - format: @"Unable to determine current account: %@", - [NSError _last]]; - } - if (ConvertSidToStringSid(&s.sid, &str) == 0) - { - [NSException raise: NSInternalInconsistencyException - format: @"Unable to get current user ID string: %@", - [NSError _last]]; - } - gnustepUserID = [[NSString alloc] initWithUTF8String: str]; - } -#else - gnustepUserID = [[NSString alloc] initWithFormat: @"%ld", (long)getuid()]; -#endif + userName = NSUserName(); config = GNUstepConfig(nil); - GNUstepUserConfig(config, gnustepUserName); - gnustepUserHome = [NSHomeDirectoryForUser(gnustepUserName) copy]; + GNUstepUserConfig(config, userName); + ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(userName)); ExtractValuesFromConfig(config); [gnustep_global_lock unlock]; @@ -1001,8 +803,6 @@ static void InitialisePathUtilities(void) static void ShutdownPathUtilities(void) { DESTROY(gnustepUserHome); - DESTROY(gnustepUserID); - DESTROY(gnustepUserName); DESTROY(gnustepUserDefaultsDir); DESTROY(gnustepMakefiles); @@ -1116,7 +916,7 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict, if ([userName isEqual: fileOwner] == NO) { -#if defined(__MINGW__) +#if defined(__MINGW32__) fprintf(stderr, "The file '%S' is owned by '%s' but we expect it" " to be the personal config file of '%s'.\nIgnoring it.\n", [fileName fileSystemRepresentation], @@ -1132,16 +932,16 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict, } if (([attributes filePosixPermissions] & (0022 & ATTRMASK)) != 0) { -#if defined(__MINGW__) +#if defined(__MINGW32__) fprintf(stderr, "The file '%S' is writable by someone other than" " its owner (permissions 0%lo).\nIgnoring it.\n", [fileName fileSystemRepresentation], - (long)[attributes filePosixPermissions]); + [attributes filePosixPermissions]); #else fprintf(stderr, "The file '%s' is writable by someone other than" " its owner (permissions 0%lo).\nIgnoring it.\n", [fileName fileSystemRepresentation], - (long)[attributes filePosixPermissions]); + [attributes filePosixPermissions]); #endif return NO; } @@ -1372,6 +1172,7 @@ ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict, } NSZoneFree(NSDefaultMallocZone(), src); NSZoneFree(NSDefaultMallocZone(), dst); + return YES; } @@ -1422,7 +1223,7 @@ GSSetUserName(NSString *aName) NSString * NSUserName(void) { -#if defined(__MINGW__) +#if defined(__MINGW32__) if (theUserName == nil) { /* Use the LOGNAME environment variable if set. */ @@ -1464,26 +1265,10 @@ NSUserName(void) if (theUserName == nil || uid != olduid) { const char *loginName = 0; - char buf[BUFSIZ*10]; -#if defined(HAVE_GETPWUID_R) - struct passwd pwent; - struct passwd *p; - - if (getpwuid_r(uid, &pwent, buf, sizeof(buf), &p) == 0) - { - loginName = pwent.pw_name; - } -#else -#if defined(HAVE_GETPWUID) - struct passwd *pwent; - - [gnustep_global_lock lock]; - pwent = getpwuid (uid); - strcpy(buf, pwent->pw_name); - [gnustep_global_lock unlock]; - loginName = buf; +#ifdef HAVE_GETPWUID + struct passwd *pwent = getpwuid (uid); + loginName = pwent->pw_name; #endif /* HAVE_GETPWUID */ -#endif /* HAVE_GETPWUID_R */ olduid = uid; if (loginName) theUserName = [[NSString alloc] initWithCString: loginName]; @@ -1518,19 +1303,7 @@ NSHomeDirectoryForUser(NSString *loginName) { NSString *s = nil; -#if !defined(__MINGW__) -#if defined(HAVE_GETPWNAM_R) - struct passwd pw; - struct passwd *p; - char buf[BUFSIZ*10]; - - if (getpwnam_r([loginName cString], &pw, buf, sizeof(buf), &p) == 0 - && pw.pw_dir != 0) - { - s = [NSString stringWithUTF8String: pw.pw_dir]; - } -#else -#if defined(HAVE_GETPWNAM) +#if !defined(__MINGW32__) struct passwd *pw; [gnustep_global_lock lock]; @@ -1540,8 +1313,6 @@ NSHomeDirectoryForUser(NSString *loginName) s = [NSString stringWithUTF8String: pw->pw_dir]; } [gnustep_global_lock unlock]; -#endif -#endif #else if ([loginName isEqual: NSUserName()] == YES) { @@ -1552,15 +1323,10 @@ NSHomeDirectoryForUser(NSString *loginName) * for the user on Windows NT; * For OPENSTEP compatibility (and because USERPROFILE is usually * unusable because it contains spaces), we use HOMEPATH in - * preference to USERPROFILE, except when MINGW has set HOMEPATH to '\' - * which isn't very useful, so we prefer USERPROFILE in that case. + * preference to USERPROFILE. */ s = [e objectForKey: @"HOMEPATH"]; - if ([s isEqualToString:@"\\"] && [e objectForKey: @"USERPROFILE"] != nil) - { - s = [e objectForKey: @"USERPROFILE"]; - } - else if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':')) + if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':')) { s = [[e objectForKey: @"HOMEDRIVE"] stringByAppendingString: s]; } @@ -1595,11 +1361,11 @@ NSFullUserName(void) { if (theFullUserName == nil) { - NSString *userName = nil; -#if defined(__MINGW__) + NSString *userName = NSUserName(); +#if defined(__MINGW32__) struct _USER_INFO_2 *userInfo; - if (NetUserGetInfo(NULL, (unichar*)[NSUserName() cStringUsingEncoding: + if (NetUserGetInfo(NULL, (unichar*)[userName cStringUsingEncoding: NSUnicodeStringEncoding], 2, (LPBYTE*)&userInfo) == 0) { userName = [NSString stringWithCharacters: userInfo->usri2_full_name @@ -1607,32 +1373,15 @@ NSFullUserName(void) } #else #ifdef HAVE_PWD_H -#if defined(HAVE_GETPWNAM_R) - struct passwd pw; - struct passwd *p; - char buf[BUFSIZ*10]; - - if (getpwnam_r([NSUserName() cString], &pw, buf, sizeof(buf), &p) == 0) - { - userName = [NSString stringWithUTF8String: pw.pw_gecos]; - } -#else -#if defined(HAVE_GETPWNAM) struct passwd *pw; - [gnustep_global_lock lock]; pw = getpwnam([NSUserName() cString]); userName = [NSString stringWithUTF8String: pw->pw_gecos]; - [gnustep_global_lock lock]; -#endif /* HAVE_GETPWNAM */ -#endif /* HAVE_GETPWNAM_R */ +#else + NSLog(@"Warning: NSFullUserName not implemented\n"); + userName = NSUserName(); #endif /* HAVE_PWD_H */ #endif /* defined(__Win32__) else */ - if (userName == nil) - { - NSLog(@"Warning: NSFullUserName not implemented\n"); - userName = NSUserName(); - } ASSIGN(theFullUserName, userName); } return theFullUserName; @@ -1671,7 +1420,7 @@ GSDefaultsRootForUser(NSString *userName) defaultsDir = @GNUSTEP_TARGET_USER_DEFAULTS_DIR; } } -#if defined(__MINGW__) +#if defined(__MINGW32__) if ([defaultsDir rangeOfString: @":REGISTRY:"].length > 0) { return defaultsDir; // Just use windows registry. @@ -1706,7 +1455,7 @@ NSTemporaryDirectory(void) int perm; int owner; BOOL flag; -#if !defined(__MINGW__) +#if !defined(__MINGW32__) int uid; #else unichar buffer[1024]; @@ -1735,14 +1484,8 @@ NSTemporaryDirectory(void) { #if defined(__CYGWIN__) baseTempDirName = @"/cygdrive/c/"; -#elif defined(__MINGW__) +#elif defined(__MINGW32__) baseTempDirName = @"C:\\"; -#elif defined(__APPLE__) - /* - * Create temporary directory on /var/tmp since /tmp is - * cleaned regularly on Darwin by default - */ - baseTempDirName = @"/var/tmp"; #else baseTempDirName = @"/tmp"; #endif @@ -1774,9 +1517,9 @@ NSTemporaryDirectory(void) perm = perm & 0777; // Mateu Batle: secure temporary directories don't work in MinGW -#ifndef __MINGW__ +#ifndef __MINGW32__ -#if defined(__MINGW__) +#if defined(__MINGW32__) uid = owner; #else #ifdef HAVE_GETEUID @@ -1846,7 +1589,7 @@ NSOpenStepRootDirectory(void) #if defined(__CYGWIN__) root = @"/cygdrive/c/"; -#elif defined(__MINGW__) +#elif defined(__MINGW32__) root = @"C:\\"; #else root = @"/"; @@ -2035,15 +1778,6 @@ if (domainMask & mask) \ } break; - case NSDownloadsDirectory: - { - ADD_PATH(NSUserDomainMask, gnustepUserLibrary, @"Downloads"); - ADD_PATH(NSLocalDomainMask, gnustepLocalLibrary, @"Downloads"); - ADD_PATH(NSNetworkDomainMask, gnustepNetworkLibrary, @"Downloads"); - ADD_PATH(NSSystemDomainMask, gnustepSystemLibrary, @"Downloads"); - } - break; - case NSCachesDirectory: { /* Uff - at the moment the only place to put Caches seems to @@ -2223,6 +1957,6 @@ if (domainMask & mask) \ } } - IF_NO_GC(AUTORELEASE (paths);) + AUTORELEASE (paths); return paths; } diff --git a/Source/NSPipe.m b/Source/NSPipe.m index 59703b161..139fdd1ac 100644 --- a/Source/NSPipe.m +++ b/Source/NSPipe.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -24,12 +24,12 @@ $Date$ $Revision$ */ -#import "common.h" - -#define EXPOSE_NSPipe_IVARS 1 - -#import "Foundation/NSFileHandle.h" -#import "GSPrivate.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSObject.h" +#include "Foundation/NSFileHandle.h" +#include "Foundation/NSDebug.h" +#include "GSPrivate.h" #ifdef HAVE_UNISTD_H #include #endif @@ -57,8 +57,8 @@ - (void) dealloc { - RELEASE(_readHandle); - RELEASE(_writeHandle); + RELEASE(readHandle); + RELEASE(writeHandle); [super dealloc]; } @@ -67,15 +67,15 @@ self = [super init]; if (self != nil) { -#ifndef __MINGW__ +#ifndef __MINGW32__ int p[2]; if (pipe(p) == 0) { - _readHandle = [[NSFileHandle alloc] initWithFileDescriptor: p[0] + readHandle = [[NSFileHandle alloc] initWithFileDescriptor: p[0] + closeOnDealloc: YES]; + writeHandle = [[NSFileHandle alloc] initWithFileDescriptor: p[1] closeOnDealloc: YES]; - _writeHandle = [[NSFileHandle alloc] initWithFileDescriptor: p[1] - closeOnDealloc: YES]; } else { @@ -87,15 +87,15 @@ HANDLE readh, writeh; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = FALSE; + saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; if (CreatePipe(&readh, &writeh, &saAttr, 0) != 0) { - _readHandle = [[NSFileHandle alloc] initWithNativeHandle: readh + readHandle = [[NSFileHandle alloc] initWithNativeHandle: readh + closeOnDealloc: YES]; + writeHandle = [[NSFileHandle alloc] initWithNativeHandle: writeh closeOnDealloc: YES]; - _writeHandle = [[NSFileHandle alloc] initWithNativeHandle: writeh - closeOnDealloc: YES]; } else { @@ -112,7 +112,7 @@ */ - (NSFileHandle*) fileHandleForReading { - return _readHandle; + return readHandle; } /** @@ -120,7 +120,7 @@ */ - (NSFileHandle*) fileHandleForWriting { - return _writeHandle; + return writeHandle; } @end diff --git a/Source/NSPointerArray.m b/Source/NSPointerArray.m deleted file mode 100644 index 8d437a890..000000000 --- a/Source/NSPointerArray.m +++ /dev/null @@ -1,559 +0,0 @@ -/**Implementation for NSPointerArray for GNUStep - Copyright (C) 2009 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Date: 2009 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - - */ - -#import "common.h" -#import "Foundation/NSPointerArray.h" -#import "GNUstepBase/GSObjCRuntime.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSKeyedArchiver.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GSPrivate.h" -#import "NSConcretePointerFunctions.h" - - -static Class abstractClass = Nil; -static Class concreteClass = Nil; - -@interface NSConcretePointerArray : NSPointerArray -{ - PFInfo _pf; - NSUInteger _count; - void **_contents; - unsigned _capacity; - unsigned _grow_factor; -} -@end - - -@implementation NSPointerArray - -+ (id) allocWithZone: (NSZone*)z -{ - if (abstractClass == self) - { - return NSAllocateObject(concreteClass, 0, z); - } - return [super allocWithZone: z]; -} - -+ (void) initialize -{ - if (abstractClass == Nil) - { - abstractClass = [NSPointerArray class]; - concreteClass = [NSConcretePointerArray class]; - } -} - -+ (id) pointerArrayWithOptions: (NSPointerFunctionsOptions)options -{ - return AUTORELEASE([[self alloc] initWithOptions: options]); -} - -+ (id) pointerArrayWithPointerFunctions: (NSPointerFunctions *)functions -{ - return AUTORELEASE([[self alloc] initWithPointerFunctions: functions]); -} - -- (void) compact -{ - [self subclassResponsibility: _cmd]; -} - -- (id) copyWithZone: (NSZone*)zone -{ - [self subclassResponsibility: _cmd]; - return nil; -} - -- (NSUInteger) count -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (void) encodeWithCoder: (NSCoder*)aCoder -{ - [self subclassResponsibility: _cmd]; -} - -- (id) init -{ - return [self initWithOptions: 0]; -} - -- (id) initWithCoder: (NSCoder*)aCoder -{ - [self subclassResponsibility: _cmd]; - return nil; -} - -- (id) initWithOptions: (NSPointerFunctionsOptions)options -{ - NSPointerFunctions *functions; - - functions = [NSPointerFunctions pointerFunctionsWithOptions: options]; - return [self initWithPointerFunctions: functions]; -} - -- (id) initWithPointerFunctions: (NSPointerFunctions*)functions -{ - [self subclassResponsibility: _cmd]; - return nil; -} - -- (BOOL) isEqual: (id)other -{ - NSUInteger count; - - if (other == self) - { - return YES; - } - if ([other isKindOfClass: abstractClass] == NO) - { - return NO; - } - if ([other hash] != [self hash]) - { - return NO; - } - count = [self count]; - while (count-- > 0) - { -// FIXME - } - return YES; -} - -- (void) addPointer: (void*)pointer -{ - [self insertPointer: pointer atIndex: [self count]]; -} - -- (void) insertPointer: (void*)pointer atIndex: (NSUInteger)index -{ - [self subclassResponsibility: _cmd]; -} - -- (void*) pointerAtIndex: (NSUInteger)index -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (NSPointerFunctions*) pointerFunctions -{ - [self subclassResponsibility: _cmd]; - return nil; -} - -- (void) removePointerAtIndex: (NSUInteger)index -{ - [self subclassResponsibility: _cmd]; -} - -- (void) replacePointerAtIndex: (NSUInteger)index withPointer: (void*)item -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setCount: (NSUInteger)count -{ - [self subclassResponsibility: _cmd]; -} - -@end - -@implementation NSPointerArray (NSArrayConveniences) - -+ (id) pointerArrayWithStrongObjects -{ - return [self pointerArrayWithOptions: NSPointerFunctionsStrongMemory]; -} - -+ (id) pointerArrayWithWeakObjects -{ - return [self pointerArrayWithOptions: NSPointerFunctionsZeroingWeakMemory]; -} - -- (NSArray*) allObjects -{ - [self subclassResponsibility: _cmd]; - return nil; -} - -@end - -@implementation NSConcretePointerArray - -- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel -{ - NSDictionary *info; - NSException *exception; - NSString *reason; - - info = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithUnsignedInt: index], @"Index", - [NSNumber numberWithUnsignedInt: _count], @"Count", - self, @"Array", nil, nil]; - - reason = [NSString stringWithFormat: - @"Index %d is out of range %d (in '%@')", - index, _count, NSStringFromSelector(sel)]; - - exception = [NSException exceptionWithName: NSRangeException - reason: reason - userInfo: info]; - [exception raise]; -} - -- (void) compact -{ - NSUInteger i = _count; - - while (i-- > 0) - { - if (_contents[i] == 0) - { - NSUInteger j = i; - - while (j > 0 && _contents[j-1] != 0) - { - j--; - } - if (i < _count - 1) - { - memcpy(_contents + j, _contents + i + 1, - (_count - i) * sizeof(void*)); - } - _count = i = j; - } - } -} - -- (id) copyWithZone: (NSZone*)zone -{ - NSConcretePointerArray *c; - unsigned i; - - c = (NSConcretePointerArray*)NSCopyObject(self, 0, NSDefaultMallocZone()); - c->_capacity = c->_count; - c->_grow_factor = c->_capacity/2; -#if GS_WITH_GC - if (_pf.options & NSPointerFunctionsZeroingWeakMemory) - { - c->_contents = NSAllocateCollectable(sizeof(id) * _count, 0); - } - else - { - c->_contents = NSAllocateCollectable(sizeof(id) * _count, - NSScannedOption); - } -#else - c->_contents = NSZoneCalloc([self zone], _count, sizeof(id)); -#endif - for (i = 0; i < _count; i++) - { - pointerFunctionsAcquire(&_pf, &c->_contents[i], _contents[i]); - } - return c; -} - -- (NSUInteger) count -{ - return _count; -} - -- (void) dealloc -{ - [self finalize]; - if (_contents != 0) - { - NSZoneFree([self zone], _contents); - } - [super dealloc]; -} - -- (void) encodeWithCoder: (NSCoder*)aCoder -{ -/* FIXME ... how can we meaningfully encode the pointer functions??? - */ - [self notImplemented: _cmd]; - if ([aCoder allowsKeyedCoding]) - { - [super encodeWithCoder: aCoder]; - } - else - { - /* For performace we encode directly ... must exactly match the - * superclass implemenation. */ - [aCoder encodeValueOfObjCType: @encode(NSUInteger) - at: &_count]; - if (_count > 0) - { - [aCoder encodeArrayOfObjCType: @encode(id) - count: _count - at: _contents]; - } - } -} - -- (NSUInteger) hash -{ - return _count; -} - -- (id) initWithCoder: (NSCoder*)aCoder -{ -/* FIXME ... how can we meaningfully encode the pointer functions??? - */ - [self notImplemented: _cmd]; - if ([aCoder allowsKeyedCoding]) - { - self = [super initWithCoder: aCoder]; - } - else - { - /* for performance, we decode directly into memory rather than - * using the superclass method. Must exactly match superclass. */ - [aCoder decodeValueOfObjCType: @encode(NSUInteger) - at: &_count]; - if (_count > 0) - { -#if GS_WITH_GC - if (_pf.options & NSPointerFunctionsZeroingWeakMemory) - { - _contents = NSAllocateCollectable(sizeof(id) * _count, 0); - } - else - { - _contents = NSAllocateCollectable(sizeof(id) * _count, - NSScannedOption); - } -#else - _contents = NSZoneCalloc([self zone], _count, sizeof(id)); -#endif - if (_contents == 0) - { - [NSException raise: NSMallocException - format: @"Unable to make array"]; - } - [aCoder decodeArrayOfObjCType: @encode(id) - count: _count - at: _contents]; - } - } - return self; -} - -- (id) initWithOptions: (NSPointerFunctionsOptions)options -{ - NSConcretePointerFunctions *f; - - f = [[NSConcretePointerFunctions alloc] initWithOptions: options]; - self = [self initWithPointerFunctions: f]; - [f release]; - return self; -} - -- (id) initWithPointerFunctions: (NSPointerFunctions*)functions -{ - if (![functions isKindOfClass: [NSConcretePointerFunctions class]]) - { - static NSConcretePointerFunctions *defaultFunctions = nil; - - if (defaultFunctions == nil) - { - defaultFunctions - = [[NSConcretePointerFunctions alloc] initWithOptions: 0]; - } - functions = defaultFunctions; - } - memcpy(&_pf, &((NSConcretePointerFunctions*)functions)->_x, sizeof(_pf)); - return self; -} - -- (void) insertPointer: (void*)pointer atIndex: (NSUInteger)index -{ - NSUInteger i; - - if (index > _count) - { - [self _raiseRangeExceptionWithIndex: index from: _cmd]; - } - i = _count; - [self setCount: _count + 1]; - while (i > index) - { - _contents[i] = _contents[i-1]; - i--; - } - pointerFunctionsAcquire(&_pf, &_contents[index], pointer); -} - -- (BOOL) isEqual: (id)other -{ - NSUInteger count; - - if (other == self) - { - return YES; - } - if ([other isKindOfClass: abstractClass] == NO) - { - return NO; - } - if ([other hash] != [self hash]) - { - return NO; - } - count = [self count]; - while (count-- > 0) - { - if (pointerFunctionsEqual(&_pf, _contents[count], - [other pointerAtIndex: count]) == NO) - return NO; - } - return YES; -} - -- (void*) pointerAtIndex: (NSUInteger)index -{ - if (index >= _count) - { - [self _raiseRangeExceptionWithIndex: index from: _cmd]; - } - return _contents[index]; -} - -- (NSPointerFunctions*) pointerFunctions -{ - NSConcretePointerFunctions *pf = [NSConcretePointerFunctions new]; - - pf->_x = _pf; - return [pf autorelease]; -} - -- (void) removePointerAtIndex: (NSUInteger)index -{ - if (index >= _count) - { - [self _raiseRangeExceptionWithIndex: index from: _cmd]; - } - pointerFunctionsRelinquish(&_pf, &_contents[index]); - while (++index < _count) - { - _contents[index-1] = _contents[index]; - } - [self setCount: _count - 1]; -} - -- (void) replacePointerAtIndex: (NSUInteger)index withPointer: (void*)item -{ - if (index >= _count) - { - [self _raiseRangeExceptionWithIndex: index from: _cmd]; - } - pointerFunctionsReplace(&_pf, &_contents[index], item); -} - -- (void) setCount: (NSUInteger)count -{ - if (count > _count) - { - _count = count; - if (_count >= _capacity) - { - void **ptr; - size_t size; - size_t new_cap = _capacity; - size_t new_gf = _grow_factor ? _grow_factor : 2; - - while (new_cap + new_gf < _count) - { - new_cap += new_gf; - new_gf = new_cap/2; - } - size = (new_cap + new_gf)*sizeof(void*); - new_cap += new_gf; - new_gf = new_cap / 2; - if (_contents == 0) - { -#if GS_WITH_GC - ptr = (void**)NSZoneMalloc([self zone], size); -#else - if (_pf.options & NSPointerFunctionsZeroingWeakMemory) - { - ptr = (void**)NSAllocateCollectable(size, 0); - } - else - { - ptr = (void**)NSAllocateCollectable(size, NSScannedOption); - } -#endif - } - else - { -#if GS_WITH_GC - ptr = (void**)NSZoneRealloc([self zone], _contents, size); -#else - if (_pf.options & NSPointerFunctionsZeroingWeakMemory) - { - ptr = (void**)NSReallocateCollectable( - _contents, size, 0); - } - else - { - ptr = (void**)NSReallocateCollectable( - _contents, size, NSScannedOption); - } -#endif - } - if (ptr == 0) - { - [NSException raise: NSMallocException - format: @"Unable to grow array"]; - } - _contents = ptr; - _capacity = new_cap; - _grow_factor = new_gf; - } - } - else - { - while (count < _count) - { - _count--; - pointerFunctionsRelinquish(&_pf, &_contents[_count]); - } - } -} - -@end - diff --git a/Source/NSPointerFunctions.m b/Source/NSPointerFunctions.m deleted file mode 100644 index 23fa89eee..000000000 --- a/Source/NSPointerFunctions.m +++ /dev/null @@ -1,165 +0,0 @@ -/**Implementation for NSPointerFunctions for GNUStep - Copyright (C) 2009 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Date: 2009 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. - - */ - -#import "common.h" -#import "NSConcretePointerFunctions.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" - -static Class abstractClass = Nil; -static Class concreteClass = Nil; - -@implementation NSPointerFunctions - -+ (id) allocWithZone: (NSZone*)zone -{ - if (self == abstractClass) - { - return (id) NSAllocateObject(concreteClass, 0, zone); - } - return [super allocWithZone: zone]; -} - -+ (void) initialize -{ - if (abstractClass == nil) - { - abstractClass = [NSPointerFunctions class]; - concreteClass = [NSConcretePointerFunctions class]; - } -} - -+ (id) pointerFunctionsWithOptions: (NSPointerFunctionsOptions)options -{ - return AUTORELEASE([[self alloc] initWithOptions: options]); -} - -- (id) copyWithZone: (NSZone*)zone -{ - return NSCopyObject(self, 0, zone); -} - -- (id) initWithOptions: (NSPointerFunctionsOptions)options -{ - return [self subclassResponsibility: _cmd]; -} - -- (void* (*)(const void *item, - NSUInteger (*size)(const void *item), BOOL shouldCopy)) acquireFunction -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (NSString *(*)(const void *item)) descriptionFunction -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (NSUInteger (*)(const void *item, - NSUInteger (*size)(const void *item))) hashFunction -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (BOOL (*)(const void *item1, const void *item2, - NSUInteger (*size)(const void *item))) isEqualFunction -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (void (*)(const void *item, - NSUInteger (*size)(const void *item))) relinquishFunction -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (void) setAcquireFunction: (void* (*)(const void *item, - NSUInteger (*size)(const void *item), BOOL shouldCopy))func -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setDescriptionFunction: (NSString *(*)(const void *item))func -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setHashFunction: (NSUInteger (*)(const void *item, - NSUInteger (*size)(const void *item)))func -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setIsEqualFunction: (BOOL (*)(const void *item1, const void *item2, - NSUInteger (*size)(const void *item)))func -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setRelinquishFunction: (void (*)(const void *item, - NSUInteger (*size)(const void *item))) func -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setSizeFunction: (NSUInteger (*)(const void *item))func -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setUsesStrongWriteBarrier: (BOOL)flag -{ - [self subclassResponsibility: _cmd]; -} - -- (void) setUsesWeakReadAndWriteBarriers: (BOOL)flag -{ - [self subclassResponsibility: _cmd]; -} - -- (NSUInteger (*)(const void *item)) sizeFunction -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (BOOL) usesStrongWriteBarrier -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -- (BOOL) usesWeakReadAndWriteBarriers -{ - [self subclassResponsibility: _cmd]; - return 0; -} - -@end - diff --git a/Source/NSPort.m b/Source/NSPort.m index d1bd86c9a..3a5f50011 100644 --- a/Source/NSPort.m +++ b/Source/NSPort.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,19 +25,18 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSPort_IVARS 1 -#import "Foundation/NSException.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSPortCoder.h" -#import "Foundation/NSPortNameServer.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSUserDefaults.h" -#import "GSPrivate.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "config.h" +#include "Foundation/NSException.h" +#include "Foundation/NSString.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSPort.h" +#include "Foundation/NSPortCoder.h" +#include "Foundation/NSPortNameServer.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSUserDefaults.h" +#include "GSPrivate.h" @class NSMessagePort; @@ -50,16 +49,11 @@ @implementation NSPort -NSString * const NSInvalidReceivePortException - = @"NSInvalidReceivePortException"; -NSString * const NSInvalidSendPortException - = @"NSInvalidSendPortException"; -NSString * const NSPortReceiveException - = @"NSPortReceiveException"; -NSString * const NSPortSendException - = @"NSPortSendException"; -NSString * const NSPortTimeoutException - = @"NSPortTimeoutException"; +/** + * Exception raised if a timeout occurs during a port send or receive + * operation. + */ +NSString * const NSPortTimeoutException = @"NSPortTimeoutException"; static Class NSPort_abstract_class; static Class NSPort_concrete_class; @@ -82,8 +76,6 @@ static Class NSPort_concrete_class; { NSUserDefaults *defs; - GSMakeWeakPointer(self, "delegate"); - NSPort_abstract_class = self; NSPort_concrete_class = [NSMessagePort class]; @@ -104,7 +96,7 @@ static Class NSPort_concrete_class; return AUTORELEASE([self new]); } -+ (NSPort*) portWithMachPort: (NSInteger)machPort ++ (NSPort*) portWithMachPort: (int)machPort { return AUTORELEASE([[self alloc] initWithMachPort: machPort]); } @@ -136,13 +128,13 @@ static Class NSPort_concrete_class; if (obj != self) { - DESTROY(self); + RELEASE(self); self = RETAIN(obj); } return self; } -- (id) initWithMachPort: (NSInteger)machPort +- (id) initWithMachPort: (int)machPort { [self shouldNotImplement: _cmd]; return nil; @@ -154,13 +146,13 @@ static Class NSPort_concrete_class; */ - (void) invalidate { - CREATE_AUTORELEASE_POOL(arp); + NSAutoreleasePool *arp = [NSAutoreleasePool new]; _is_valid = NO; [[NSNotificationCenter defaultCenter] postNotificationName: NSPortDidBecomeInvalidNotification object: self]; - RELEASE(arp); + [arp release]; } - (BOOL) isValid @@ -168,7 +160,7 @@ static Class NSPort_concrete_class; return _is_valid; } -- (NSInteger) machPort +- (int) machPort { [self shouldNotImplement: _cmd]; return 0; @@ -222,7 +214,7 @@ static Class NSPort_concrete_class; [aLoop removePort: self forMode: aMode]; } -- (NSUInteger) reservedSpaceLength +- (unsigned) reservedSpaceLength { [self subclassResponsibility: _cmd]; return 0; @@ -231,7 +223,7 @@ static Class NSPort_concrete_class; - (BOOL) sendBeforeDate: (NSDate*)when components: (NSMutableArray*)components from: (NSPort*)receivingPort - reserved: (NSUInteger)length + reserved: (unsigned) length { return [self sendBeforeDate: when msgid: 0 @@ -241,10 +233,10 @@ static Class NSPort_concrete_class; } - (BOOL) sendBeforeDate: (NSDate*)when - msgid: (NSInteger)msgid + msgid: (int)msgid components: (NSMutableArray*)components from: (NSPort*)receivingPort - reserved: (NSUInteger)length + reserved: (unsigned)length { [self subclassResponsibility: _cmd]; return YES; @@ -252,3 +244,13 @@ static Class NSPort_concrete_class; @end +/* + * This is a callback method used by the NSRunLoop class to determine which + * descriptors to watch for the port. Subclasses override it. + */ +@implementation NSPort (GNUstep) +- (void) getFds: (NSInteger*)fds count: (NSInteger*)count +{ + *count = 0; +} +@end diff --git a/Source/NSPortCoder.m b/Source/NSPortCoder.m index b7a5ada9b..83883ffa1 100644 --- a/Source/NSPortCoder.m +++ b/Source/NSPortCoder.m @@ -15,7 +15,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -24,7 +24,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -33,14 +33,19 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSPortCoder_IVARS 1 -#import "Foundation/NSException.h" -#import "Foundation/NSByteOrder.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSData.h" -#import "Foundation/NSPort.h" +#include "config.h" +#include + +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSZone.h" +#include "Foundation/NSException.h" +#include "Foundation/NSByteOrder.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSData.h" +#include "Foundation/NSUtilities.h" +#include "Foundation/NSPort.h" +#include "Foundation/NSString.h" @class NSMutableDataMalloc; @interface NSMutableDataMalloc : NSObject // Help the compiler @@ -49,8 +54,6 @@ /* * Setup for inline operation of pointer map tables. */ -#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_INT -#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ | GSUNION_CLS | GSUNION_INT #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) @@ -59,13 +62,6 @@ #define GSI_MAP_EQUAL(M, X,Y) ((X).ptr == (Y).ptr) #define GSI_MAP_NOCLEAN 1 -#if GS_WITH_GC -#include -static GC_descr nodeDesc; // Type descriptor for map node. -#define GSI_MAP_NODES(M, X) \ -(GSIMapNode)GC_calloc_explicitly_typed(X, sizeof(GSIMapNode_t), nodeDesc) -#endif - #include "GNUstepBase/GSIMap.h" /* @@ -80,10 +76,10 @@ static GC_descr nodeDesc; // Type descriptor for map node. #define _IN_PORT_CODER_M -#import "Foundation/NSPortCoder.h" +#include "Foundation/NSPortCoder.h" #undef _IN_PORT_CODER_M -#import "GNUstepBase/DistributedObjects.h" +#include "GNUstepBase/DistributedObjects.h" typedef unsigned char uchar; @@ -265,12 +261,6 @@ typeCheck(char t1, char t2) #endif )) return; -/* HACK also allow float and double to be used interchangably as MacOS-X - * intorduced CGFloat, which may be aither a float or a double. - */ - if ((c == _C_FLT || c == _C_DBL) && (t1 == _C_FLT || t1 == _C_DBL)) - return; - [NSException raise: NSInternalInconsistencyException format: @"expected %s and got %s", typeToName1(t1), typeToName2(t2)]; @@ -365,14 +355,6 @@ static IMP _xRefImp; /* Serialize a crossref. */ _eTagImp = [mutableDataClass instanceMethodForSelector: eTagSel]; _xRefImp = [mutableDataClass instanceMethodForSelector: xRefSel]; mutableDictionaryClass = [NSMutableDictionary class]; -#if GS_WITH_GC - /* We create a typed memory descriptor for map nodes. - */ - GC_word w[GC_BITMAP_SIZE(GSIMapNode_t)] = {0}; - GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, key)); - GC_set_bit(w, GC_WORD_OFFSET(GSIMapNode_t, value)); - nodeDesc = GC_make_descriptor(w, GC_WORD_LEN(GSIMapNode_t)); -#endif } } @@ -384,7 +366,7 @@ static IMP _xRefImp; /* Serialize a crossref. */ coder = [self allocWithZone: NSDefaultMallocZone()]; coder = [coder initWithReceivePort: recv sendPort: send components: comp]; - IF_NO_GC(AUTORELEASE(coder);) + AUTORELEASE(coder); return coder; } @@ -597,8 +579,8 @@ static IMP _xRefImp; /* Serialize a crossref. */ if (c == 0) { NSLog(@"[%s %s] decoded nil class", - class_getName([self class]), - sel_getName(_cmd)); + GSNameFromClass([self class]), + GSNameFromSelector(_cmd)); } obj = [c allocWithZone: _zone]; GSIArrayAddItem(_objAry, (GSIArrayItem)obj); @@ -712,7 +694,7 @@ static IMP _xRefImp; /* Serialize a crossref. */ if (c == 0) { NSLog(@"[%s %s] decoded nil class", - class_getName([self class]), sel_getName(_cmd)); + GSNameFromClass([self class]), GSNameFromSelector(_cmd)); } classInfo = [GSClassInfo newWithClass: c andVersion: cver]; GSIArrayAddItem(_clsAry, (GSIArrayItem)((id)classInfo)); @@ -942,36 +924,12 @@ static IMP _xRefImp; /* Serialize a crossref. */ #endif case _GSC_FLT: typeCheck(*type, _GSC_FLT); - if (*type == _C_FLT) - { - (*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil); - } - else - { - float val; - - /* We found a float when expecting a double ... handle it. - */ - (*_dDesImp)(_src, dDesSel, &val, @encode(float), &_cursor, nil); - *(double*)address = (double)val; - } + (*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil); return; case _GSC_DBL: typeCheck(*type, _GSC_DBL); - if (*type == _C_DBL) - { - (*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil); - } - else - { - double val; - - /* We found a double when expecting a float ... handle it. - */ - (*_dDesImp)(_src, dDesSel, &val, @encode(double), &_cursor, nil); - *(float*)address = (float)val; - } + (*_dDesImp)(_src, dDesSel, address, type, &_cursor, nil); return; default: @@ -1525,9 +1483,9 @@ static IMP _xRefImp; /* Serialize a crossref. */ } while (done == NO) { - int tmp = class_getVersion(c); + int tmp = GSObjCVersion(c); unsigned version = tmp; - Class s = class_getSuperclass(c); + Class s = GSObjCSuper(c); if (tmp < 0) { @@ -1755,14 +1713,8 @@ static IMP _xRefImp; /* Serialize a crossref. */ /* * Set up map tables. */ -#if GS_WITH_GC - _clsMap - = (GSIMapTable)NSAllocateCollectable(sizeof(GSIMapTable_t)*4, - NSScannedOption); -#else _clsMap = (GSIMapTable)NSZoneMalloc(_zone, sizeof(GSIMapTable_t)*4); -#endif _cIdMap = &_clsMap[1]; _uIdMap = &_clsMap[2]; _ptrMap = &_clsMap[3]; @@ -1848,12 +1800,7 @@ static IMP _xRefImp; /* Serialize a crossref. */ */ if (firstTime == YES) { -#if GS_WITH_GC - _clsAry - = NSAllocateCollectable(sizeof(GSIArray_t)*3, NSScannedOption); -#else _clsAry = NSZoneMalloc(_zone, sizeof(GSIArray_t)*3); -#endif _objAry = &_clsAry[1]; _ptrAry = &_clsAry[2]; GSIArrayInitWithZoneAndCapacity(_clsAry, _zone, sizeC); @@ -1912,7 +1859,7 @@ static IMP _xRefImp; /* Serialize a crossref. */ return _version; } -- (NSInteger) versionForClassName: (NSString*)className +- (unsigned) versionForClassName: (NSString*)className { GSClassInfo *info = nil; unsigned version = NSNotFound; @@ -2045,7 +1992,7 @@ static IMP _xRefImp; /* Serialize a crossref. */ * use get_imp() because NSDistantObject doesn't implement * methodForSelector: */ - proxyImp = get_imp(object_getClass((id)proxyClass), + proxyImp = get_imp(GSObjCClass((id)proxyClass), @selector(proxyWithLocal:connection:)); } diff --git a/Source/NSPortMessage.m b/Source/NSPortMessage.m index c004b15d6..e82a9114d 100644 --- a/Source/NSPortMessage.m +++ b/Source/NSPortMessage.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,13 +25,12 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSPortMessage_IVARS 1 -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSData.h" -#import "Foundation/NSException.h" -#import "Foundation/NSPortMessage.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "config.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSData.h" +#include "Foundation/NSException.h" +#include "Foundation/NSPortMessage.h" +#include "Foundation/NSObjCRuntime.h" @implementation NSPortMessage diff --git a/Source/NSPortNameServer.m b/Source/NSPortNameServer.m index 565ba05c7..e23d1d35b 100644 --- a/Source/NSPortNameServer.m +++ b/Source/NSPortNameServer.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,15 +25,15 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSException.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSPortNameServer.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSUserDefaults.h" -#import "GSPortPrivate.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "config.h" +#include "Foundation/NSString.h" +#include "Foundation/NSException.h" +#include "Foundation/NSPort.h" +#include "Foundation/NSPortNameServer.h" +#include "Foundation/NSDebug.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSUserDefaults.h" +#include "GSPortPrivate.h" /** diff --git a/Source/NSPredicate.m b/Source/NSPredicate.m index b78caaaaa..31fe90094 100644 --- a/Source/NSPredicate.m +++ b/Source/NSPredicate.m @@ -3,63 +3,58 @@ Written by: Dr. H. Nikolaus Schaller Created: 2005 - Modifications: Fred Kiefer - Date: May 2007 - Modifications: Richard Frith-Macdoanld - Date: June 2007 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This library 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 Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include +#include +#include +#include -#define EXPOSE_NSComparisonPredicate_IVARS 1 -#define EXPOSE_NSCompoundPredicate_IVARS 1 -#define EXPOSE_NSExpression_IVARS 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include -#import "Foundation/NSComparisonPredicate.h" -#import "Foundation/NSCompoundPredicate.h" -#import "Foundation/NSExpression.h" -#import "Foundation/NSPredicate.h" +#include -#import "Foundation/NSArray.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSKeyValueCoding.h" -#import "Foundation/NSNull.h" -#import "Foundation/NSScanner.h" -#import "Foundation/NSValue.h" - -#import "GSPrivate.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" - -// For pow() -#include +#define NIMP [NSException raise: NSGenericException \ + format: @"%s(%s) has not implemented %s",\ + GSClassNameFromObject(self), GSObjCIsInstance(self) ? "instance" : "class",\ + GSNameFromSelector(_cmd)] @interface GSPredicateScanner : NSScanner { NSEnumerator *_args; // Not retained. + va_list _vargs; unsigned _retrieved; } - (id) initWithString: (NSString*)format args: (NSArray*)args; +- (id) initWithString: (NSString*)format + vargs: (va_list)vargs; - (id) nextArg; - (BOOL) scanPredicateKeyword: (NSString *) key; - (NSPredicate *) parse; @@ -74,7 +69,6 @@ - (NSExpression *) parseMultiplicationExpression; - (NSExpression *) parseAdditionExpression; - (NSExpression *) parseBinaryExpression; -- (NSExpression *) parseSimpleExpression; @end @@ -85,16 +79,27 @@ @end @interface GSAndCompoundPredicate : NSCompoundPredicate +{ + @public + NSArray *_subs; +} +- (id) _initWithSubpredicates: (NSArray *)list; @end @interface GSOrCompoundPredicate : NSCompoundPredicate +{ + @public + NSArray *_subs; +} +- (id) _initWithSubpredicates: (NSArray *)list; @end @interface GSNotCompoundPredicate : NSCompoundPredicate -@end - -@interface NSExpression (Private) -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables; +{ + @public + NSPredicate *_sub; +} +- (id) _initWithSubpredicate: (id)predicateOrList; @end @interface GSConstantValueExpression : NSExpression @@ -126,6 +131,7 @@ @public NSString *_function; NSArray *_args; + NSMutableArray *_eargs; // temporary space unsigned int _argc; SEL _selector; } @@ -140,153 +146,33 @@ NSPredicate *p; va_list va; - va_start(va, format); + va_start (va, format); p = [self predicateWithFormat: format arguments: va]; - va_end(va); + va_end (va); return p; } + (NSPredicate *) predicateWithFormat: (NSString *)format - argumentArray: (NSArray *)args + argumentArray: (NSArray *)args { GSPredicateScanner *s; NSPredicate *p; s = [[GSPredicateScanner alloc] initWithString: format - args: args]; + args: args]; p = [s parse]; RELEASE(s); return p; } + (NSPredicate *) predicateWithFormat: (NSString *)format - arguments: (va_list)args + arguments: (va_list)args { GSPredicateScanner *s; NSPredicate *p; - const char *ptr = [format UTF8String]; - NSMutableArray *arr = [NSMutableArray arrayWithCapacity: 10]; - while (*ptr != 0) - { - char c = *ptr++; - - if (c == '%') - { - c = *ptr; - switch (c) - { - case '%': - ptr++; - break; - - case 'K': - case '@': - ptr++; - [arr addObject: va_arg(args, id)]; - break; - - case 'c': - ptr++; - [arr addObject: [NSNumber numberWithChar: - (char)va_arg(args, NSInteger)]]; - break; - - case 'C': - ptr++; - [arr addObject: [NSNumber numberWithShort: - (short)va_arg(args, NSInteger)]]; - break; - - case 'd': - case 'D': - case 'i': - ptr++; - [arr addObject: [NSNumber numberWithInt: - va_arg(args, NSInteger)]]; - break; - - case 'o': - case 'O': - case 'u': - case 'U': - case 'x': - case 'X': - ptr++; - [arr addObject: [NSNumber numberWithUnsignedInt: - va_arg(args, NSUInteger)]]; - break; - - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - ptr++; - [arr addObject: [NSNumber numberWithDouble: - va_arg(args, double)]]; - break; - - case 'h': - ptr++; - if (*ptr != 0) - { - c = *ptr; - if (c == 'i') - { - [arr addObject: [NSNumber numberWithShort: - (short)va_arg(args, NSInteger)]]; - } - if (c == 'u') - { - [arr addObject: [NSNumber numberWithUnsignedShort: - (unsigned short)va_arg(args, NSInteger)]]; - } - } - break; - - case 'q': - ptr++; - if (*ptr != 0) - { - c = *ptr; - if (c == 'i') - { - [arr addObject: [NSNumber numberWithLongLong: - va_arg(args, long long)]]; - } - if (c == 'u' || c == 'x' || c == 'X') - { - [arr addObject: [NSNumber numberWithUnsignedLongLong: - va_arg(args, unsigned long long)]]; - } - } - break; - } - } - else if (c == '\'') - { - while (*ptr != 0) - { - if (*ptr++ == '\'') - { - break; - } - } - } - else if (c == '"') - { - while (*ptr != 0) - { - if (*ptr++ == '"') - { - break; - } - } - } - } s = [[GSPredicateScanner alloc] initWithString: format - args: arr]; + vargs: args]; p = [s parse]; RELEASE(s); return p; @@ -296,19 +182,17 @@ { if (value) { - return AUTORELEASE([GSTruePredicate new]); - } - else - { - return AUTORELEASE([GSFalsePredicate new]); - } + return (NSPredicate *)[GSTruePredicate new]; + } + return (NSPredicate *)[GSFalsePredicate new]; } // we don't ever instantiate NSPredicate - (id) copyWithZone: (NSZone *)z { - return NSCopyObject(self, 0, z); + [self subclassResponsibility: _cmd]; + return RETAIN(self); } - (BOOL) evaluateWithObject: (id)object @@ -330,23 +214,16 @@ - (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables { - return AUTORELEASE([self copy]); -} - -- (Class) classForCoder -{ - return [NSPredicate class]; + return [[self copy] autorelease]; } - (void) encodeWithCoder: (NSCoder *) coder; { - // FIXME [self subclassResponsibility: _cmd]; } - (id) initWithCoder: (NSCoder *) coder; { - // FIXME [self subclassResponsibility: _cmd]; return self; } @@ -354,10 +231,9 @@ @end @implementation GSTruePredicate - -- (id) copyWithZone: (NSZone *)z +- (id) copyWithZone: (NSZone *) z { - return RETAIN(self); + return [self retain]; } - (BOOL) evaluateWithObject: (id)object @@ -369,14 +245,12 @@ { return @"TRUEPREDICATE"; } - @end @implementation GSFalsePredicate - - (id) copyWithZone: (NSZone *)z { - return RETAIN(self); + return [self retain]; } - (BOOL) evaluateWithObject: (id)object @@ -388,92 +262,70 @@ { return @"FALSEPREDICATE"; } - @end @implementation NSCompoundPredicate + (NSPredicate *) andPredicateWithSubpredicates: (NSArray *)list { - return AUTORELEASE([[GSAndCompoundPredicate alloc] initWithType: NSAndPredicateType - subpredicates: list]); + return [[[GSAndCompoundPredicate alloc] _initWithSubpredicates: list] + autorelease]; } + (NSPredicate *) notPredicateWithSubpredicate: (NSPredicate *)predicate { - return AUTORELEASE([[GSNotCompoundPredicate alloc] - initWithType: NSNotPredicateType - subpredicates: [NSArray arrayWithObject: predicate]]); + return [[[GSNotCompoundPredicate alloc] _initWithSubpredicate: predicate] + autorelease]; } + (NSPredicate *) orPredicateWithSubpredicates: (NSArray *)list { - return AUTORELEASE([[GSOrCompoundPredicate alloc] initWithType: NSOrPredicateType - subpredicates: list]); + return [[[GSOrCompoundPredicate alloc] _initWithSubpredicates: list] + autorelease]; } - (NSCompoundPredicateType) compoundPredicateType { - return _type; + [self subclassResponsibility: _cmd]; + return 0; } - (id) initWithType: (NSCompoundPredicateType)type subpredicates: (NSArray *)list { - if ((self = [super init]) != nil) + [self release]; + switch (type) { - _type = type; - ASSIGN(_subs, list); + case NSAndPredicateType: + return [[GSAndCompoundPredicate alloc] _initWithSubpredicates: list]; + case NSOrPredicateType: + return [[GSOrCompoundPredicate alloc] _initWithSubpredicates: list]; + case NSNotPredicateType: + return [[GSNotCompoundPredicate alloc] _initWithSubpredicate: list]; + default: + return nil; } - return self; -} - -- (void) dealloc -{ - RELEASE(_subs); - [super dealloc]; } - (id) copyWithZone: (NSZone *)z { - return [[[self class] alloc] initWithType: _type subpredicates: _subs]; + [self subclassResponsibility: _cmd]; + return [self retain]; } - (NSArray *) subpredicates { - return _subs; -} - -- (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables -{ - unsigned int count = [_subs count]; - NSMutableArray *esubs = [NSMutableArray arrayWithCapacity: count]; - unsigned int i; - - for (i = 0; i < count; i++) - { - [esubs addObject: [[_subs objectAtIndex: i] - predicateWithSubstitutionVariables: variables]]; - } - - return [[[self class] alloc] initWithType: _type subpredicates: esubs]; -} - -- (Class) classForCoder -{ - return [NSCompoundPredicate class]; + [self subclassResponsibility: _cmd]; + return nil; } - (void) encodeWithCoder: (NSCoder *)coder { - // FIXME [self subclassResponsibility: _cmd]; } - (id) initWithCoder: (NSCoder *)coder { - // FIXME - [self subclassResponsibility: _cmd]; return self; } @@ -481,6 +333,27 @@ @implementation GSAndCompoundPredicate +- (id) _initWithSubpredicates: (NSArray *)list +{ + NSAssert ([list count] > 1, NSInvalidArgumentException); + if ((self = [super init]) != nil) + { + _subs = [list retain]; + } + return self; +} + +- (void) dealloc +{ + [_subs release]; + [super dealloc]; +} + +- (NSCompoundPredicateType) compoundPredicateType +{ + return NSAndPredicateType; +} + - (BOOL) evaluateWithObject: (id) object { NSEnumerator *e = [_subs objectEnumerator]; @@ -489,9 +362,9 @@ while ((p = [e nextObject]) != nil) { if ([p evaluateWithObject: object] == NO) - { - return NO; // any NO returns NO - } + { + return NO; // any NO returns NO + } } return YES; // all are true } @@ -507,43 +380,87 @@ { // when to add ()? -> if sub is compound and of type "or" if (cnt == 0) - { - fmt = [sub predicateFormat]; // first - } + { + fmt = [sub predicateFormat]; // first + } else - { - if (cnt == 1 - && [[_subs objectAtIndex: 0] - isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)[_subs objectAtIndex: 0] - compoundPredicateType] == NSOrPredicateType) - { - // we need () around first OR on left side - fmt = [NSString stringWithFormat: @"(%@)", fmt]; - } - if ([sub isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *) sub compoundPredicateType] - == NSOrPredicateType) - { - // we need () around right OR - fmt = [NSString stringWithFormat: @"%@ AND (%@)", - fmt, [sub predicateFormat]]; - } - else - { - fmt = [NSString stringWithFormat: @"%@ AND %@", - fmt, [sub predicateFormat]]; - } - } + { + if (cnt == 1 + && [[_subs objectAtIndex: 0] + isKindOfClass: [NSCompoundPredicate class]] + && [(NSCompoundPredicate *)[_subs objectAtIndex: 0] + compoundPredicateType] == NSOrPredicateType) + { + // we need () around first OR on left side + fmt = [NSString stringWithFormat: @"(%@)", fmt]; + } + if ([sub isKindOfClass: [NSCompoundPredicate class]] + && [(NSCompoundPredicate *) sub compoundPredicateType] + == NSOrPredicateType) + { + // we need () around right OR + fmt = [NSString stringWithFormat: @"%@ AND (%@)", + fmt, [sub predicateFormat]]; + } + else + { + fmt = [NSString stringWithFormat: @"%@ AND %@", + fmt, [sub predicateFormat]]; + } + } cnt++; } return fmt; } +- (NSArray *) subpredicates +{ + return _subs; +} + +- (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables +{ + GSAndCompoundPredicate *copy = [self copy]; + unsigned int count = [copy->_subs count]; + unsigned int i; + + for (i = 0; i < count; i++) + { + NSPredicate *rep; + + rep = [_subs objectAtIndex: i]; + rep = [rep predicateWithSubstitutionVariables: variables]; + [(NSMutableArray *)(copy->_subs) replaceObjectAtIndex: i + withObject: rep]; + } + return [copy autorelease]; +} + @end @implementation GSOrCompoundPredicate +- (id) _initWithSubpredicates: (NSArray *)list +{ + NSAssert ([list count] > 1, NSInvalidArgumentException); + if ((self = [super init]) != nil) + { + _subs = [list retain]; + } + return self; +} + +- (void) dealloc +{ + [_subs release]; + [super dealloc]; +} + +- (NSCompoundPredicateType) compoundPredicateType +{ + return NSOrPredicateType; +} + - (BOOL) evaluateWithObject: (id)object { NSEnumerator *e = [_subs objectEnumerator]; @@ -552,9 +469,9 @@ while ((p = [e nextObject]) != nil) { if ([p evaluateWithObject: object] == YES) - { - return YES; // any YES returns YES - } + { + return YES; // any YES returns YES + } } return NO; // none is true } @@ -568,40 +485,98 @@ while ((sub = [e nextObject]) != nil) { if ([fmt length] > 0) - { - fmt = [NSString stringWithFormat: @"%@ OR %@", - fmt, [sub predicateFormat]]; - } + { + fmt = [NSString stringWithFormat: @"%@ OR %@", + fmt, [sub predicateFormat]]; + } else - { - fmt = [sub predicateFormat]; // first - } + { + fmt = [sub predicateFormat]; // first + } } return fmt; } +- (NSArray *) subpredicates +{ + return _subs; +} + +- (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables +{ + GSOrCompoundPredicate *copy = [self copy]; + unsigned int count = [copy->_subs count]; + unsigned int i; + + for (i = 0; i < count; i++) + { + NSPredicate *rep; + + rep = [_subs objectAtIndex: i]; + rep = [rep predicateWithSubstitutionVariables: variables]; + [(NSMutableArray *)(copy->_subs) replaceObjectAtIndex: i withObject: rep]; + } + return [copy autorelease]; +} + @end @implementation GSNotCompoundPredicate +- (id) _initWithSubpredicate: (id)listOrPredicate +{ + if ((self = [super init]) != nil) + { + if ([listOrPredicate isKindOfClass: [NSArray class]]) + { + _sub = [[listOrPredicate objectAtIndex: 0] retain]; + } + else + { + _sub = [listOrPredicate retain]; + } + } + return self; +} + +- (void) dealloc +{ + [_sub release]; + [super dealloc]; +} + +- (NSCompoundPredicateType) compoundPredicateType +{ + return NSNotPredicateType; +} + - (BOOL) evaluateWithObject: (id)object { - NSPredicate *sub = [_subs objectAtIndex: 0]; - - return ![sub evaluateWithObject: object]; + return ![_sub evaluateWithObject: object]; } - (NSString *) predicateFormat { - NSPredicate *sub = [_subs objectAtIndex: 0]; - - if ([sub isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)sub compoundPredicateType] + if ([_sub isKindOfClass: [NSCompoundPredicate class]] + && [(NSCompoundPredicate *)_sub compoundPredicateType] != NSNotPredicateType) { - return [NSString stringWithFormat: @"NOT(%@)", [sub predicateFormat]]; + return [NSString stringWithFormat: @"NOT(%@)", [_sub predicateFormat]]; } - return [NSString stringWithFormat: @"NOT %@", [sub predicateFormat]]; + return [NSString stringWithFormat: @"NOT %@", [_sub predicateFormat]]; +} + +- (NSArray *) subpredicates +{ + return [NSArray arrayWithObject: _sub]; +} + +- (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables +{ + GSNotCompoundPredicate *copy = [self copy]; + + copy->_sub = [_sub predicateWithSubstitutionVariables: variables]; + return [copy autorelease]; } @end @@ -609,63 +584,21 @@ @implementation NSComparisonPredicate + (NSPredicate *) predicateWithLeftExpression: (NSExpression *)left - rightExpression: (NSExpression *)right - customSelector: (SEL) sel + rightExpression: (NSExpression *)right + customSelector: (SEL) sel { - return AUTORELEASE([[self alloc] initWithLeftExpression: left - rightExpression: right - customSelector: sel]); + return [[[self alloc] initWithLeftExpression: left + rightExpression: right customSelector: sel] autorelease]; } + (NSPredicate *) predicateWithLeftExpression: (NSExpression *)left - rightExpression: (NSExpression *)right - modifier: (NSComparisonPredicateModifier)modifier - type: (NSPredicateOperatorType)type - options: (NSUInteger)opts + rightExpression: (NSExpression *)right + modifier: (NSComparisonPredicateModifier)modifier + type: (NSPredicateOperatorType)type + options: (unsigned)opts { - return AUTORELEASE([[self alloc] initWithLeftExpression: left - rightExpression: right - modifier: modifier - type: type - options: opts]); -} - -- (NSPredicate *) initWithLeftExpression: (NSExpression *)left - rightExpression: (NSExpression *)right - customSelector: (SEL)sel -{ - if ((self = [super init]) != nil) - { - ASSIGN(_left, left); - ASSIGN(_right, right); - _selector = sel; - _type = NSCustomSelectorPredicateOperatorType; - } - return self; -} - -- (id) initWithLeftExpression: (NSExpression *)left - rightExpression: (NSExpression *)right - modifier: (NSComparisonPredicateModifier)modifier - type: (NSPredicateOperatorType)type - options: (NSUInteger)opts -{ - if ((self = [super init]) != nil) - { - ASSIGN(_left, left); - ASSIGN(_right, right); - _modifier = modifier; - _type = type; - _options = opts; - } - return self; -} - -- (void) dealloc; -{ - RELEASE(_left); - RELEASE(_right); - [super dealloc]; + return [[[self alloc] initWithLeftExpression: left rightExpression: right + modifier: modifier type: type options: opts] autorelease]; } - (NSComparisonPredicateModifier) comparisonPredicateModifier @@ -678,12 +611,50 @@ return _selector; } +- (NSPredicate *) initWithLeftExpression: (NSExpression *)left + rightExpression: (NSExpression *)right + customSelector: (SEL)sel +{ + if ((self = [super init]) != nil) + { + _left = [left retain]; + _right = [right retain]; + _selector = sel; + _type = NSCustomSelectorPredicateOperatorType; + } + return self; +} + +- (id) initWithLeftExpression: (NSExpression *)left + rightExpression: (NSExpression *)right + modifier: (NSComparisonPredicateModifier)modifier + type: (NSPredicateOperatorType)type + options: (unsigned)opts +{ + if ((self = [super init]) != nil) + { + _left = [left retain]; + _right = [right retain]; + _modifier = modifier; + _type = type; + _options = opts; + } + return self; +} + +- (void) dealloc; +{ + [_left release]; + [_right release]; + [super dealloc]; +} + - (NSExpression *) leftExpression { return _left; } -- (NSUInteger) options +- (unsigned) options { return _options; } @@ -707,302 +678,104 @@ switch (_modifier) { case NSDirectPredicateModifier: - break; + break; case NSAnyPredicateModifier: - modi = @"ANY "; - break; + modi = @"ANY "; break; case NSAllPredicateModifier: - modi = @"ALL"; - break; + modi = @"ALL"; break; default: - modi = @"?modifier?"; - break; + modi = @"?modifier?"; break; } switch (_type) { case NSLessThanPredicateOperatorType: - comp = @"<"; - break; + comp = @"<"; break; case NSLessThanOrEqualToPredicateOperatorType: - comp = @"<="; - break; + comp = @"<="; break; case NSGreaterThanPredicateOperatorType: - comp = @">="; - break; + comp = @">="; break; case NSGreaterThanOrEqualToPredicateOperatorType: - comp = @">"; - break; + comp = @">"; break; case NSEqualToPredicateOperatorType: - comp = @"="; - break; + comp = @"="; break; case NSNotEqualToPredicateOperatorType: - comp = @"!="; - break; + comp = @"!="; break; case NSMatchesPredicateOperatorType: - comp = @"MATCHES"; - break; + comp = @"MATCHES"; break; case NSLikePredicateOperatorType: - comp = @"LIKE"; - break; + comp = @"LIKE"; break; case NSBeginsWithPredicateOperatorType: - comp = @"BEGINSWITH"; - break; + comp = @"BEGINSWITH"; break; case NSEndsWithPredicateOperatorType: - comp = @"ENDSWITH"; - break; + comp = @"ENDSWITH"; break; case NSInPredicateOperatorType: - comp = @"IN"; - break; + comp = @"IN"; break; case NSCustomSelectorPredicateOperatorType: - comp = NSStringFromSelector(_selector); - break; - case NSContainsPredicateOperatorType: - comp = @"CONTAINS"; - break; - case NSBetweenPredicateOperatorType: - comp = @"BETWEEN"; - break; + { + comp = NSStringFromSelector (_selector); + } } switch (_options) { case NSCaseInsensitivePredicateOption: - opt = @"[c]"; - break; + opt = @"[c]"; break; case NSDiacriticInsensitivePredicateOption: - opt = @"[d]"; - break; + opt = @"[d]"; break; case NSCaseInsensitivePredicateOption - | NSDiacriticInsensitivePredicateOption: - opt = @"[cd]"; - break; + | NSDiacriticInsensitivePredicateOption: + opt = @"[cd]"; break; default: - opt = @"[?options?]"; - break; + opt = @"[?options?]"; break; } return [NSString stringWithFormat: @"%@%@ %@%@ %@", - modi, _left, comp, opt, _right]; + modi, _left, comp, opt, _right]; } - (NSPredicate *) predicateWithSubstitutionVariables: (NSDictionary *)variables { - NSExpression *left = [_left _expressionWithSubstitutionVariables: variables]; - NSExpression *right = [_right _expressionWithSubstitutionVariables: variables]; - - if (_type == NSCustomSelectorPredicateOperatorType) - { - return [NSComparisonPredicate predicateWithLeftExpression: left - rightExpression: right - customSelector: _selector]; - } - else - { - return [NSComparisonPredicate predicateWithLeftExpression: left - rightExpression: right - modifier: _modifier - type: _type - options: _options]; - } -} + NSComparisonPredicate *copy = [self copy]; -- (BOOL) _evaluateLeftValue: (id)leftResult rightValue: (id)rightResult -{ - unsigned compareOptions = 0; - BOOL leftIsNil; - BOOL rightIsNil; - - leftIsNil = (leftResult == nil || [leftResult isEqual: [NSNull null]]); - rightIsNil = (rightResult == nil || [rightResult isEqual: [NSNull null]]); - if (leftIsNil || rightIsNil) - { - /* One of the values is nil. The result is YES, - * if both are nil and equlality is requested. - */ - return ((leftIsNil == rightIsNil) - && ((_type == NSEqualToPredicateOperatorType) - || (_type == NSLessThanOrEqualToPredicateOperatorType) - || (_type == NSGreaterThanOrEqualToPredicateOperatorType))); - } - - // Change predicate options into string options. - if (!(_options & NSDiacriticInsensitivePredicateOption)) - { - compareOptions |= NSLiteralSearch; - } - if (_options & NSCaseInsensitivePredicateOption) - { - compareOptions |= NSCaseInsensitiveSearch; - } - - /* This is a very optimistic implementation, - * hoping that the values are of the right type. - */ - switch (_type) - { - case NSLessThanPredicateOperatorType: - return ([leftResult compare: rightResult] == NSOrderedAscending); - case NSLessThanOrEqualToPredicateOperatorType: - return ([leftResult compare: rightResult] != NSOrderedDescending); - case NSGreaterThanPredicateOperatorType: - return ([leftResult compare: rightResult] == NSOrderedDescending); - case NSGreaterThanOrEqualToPredicateOperatorType: - return ([leftResult compare: rightResult] != NSOrderedAscending); - case NSEqualToPredicateOperatorType: - return [leftResult isEqual: rightResult]; - case NSNotEqualToPredicateOperatorType: - return ![leftResult isEqual: rightResult]; - case NSMatchesPredicateOperatorType: - // FIXME: Missing implementation of matches. - return [leftResult compare: rightResult options: compareOptions] == NSOrderedSame; - case NSLikePredicateOperatorType: - // FIXME: Missing implementation of like. - return [leftResult compare: rightResult options: compareOptions] == NSOrderedSame; - case NSBeginsWithPredicateOperatorType: - { - NSRange range = NSMakeRange(0, [rightResult length]); - return ([leftResult compare: rightResult options: compareOptions range: range] == NSOrderedSame); - } - case NSEndsWithPredicateOperatorType: - { - NSRange range = NSMakeRange([leftResult length] - [rightResult length], [rightResult length]); - return ([leftResult compare: rightResult options: compareOptions range: range] == NSOrderedSame); - } - case NSInPredicateOperatorType: - // Handle special case where rightResult is a collection and leftResult an element of it. - if (![rightResult isKindOfClass: [NSString class]]) - { - NSEnumerator *e; - id value; - - if (![rightResult respondsToSelector: @selector(objectEnumerator)]) - { - [NSException raise: NSInvalidArgumentException - format: @"The right hand side for an IN operator must be a collection"]; - } - - e = [rightResult objectEnumerator]; - while ((value = [e nextObject])) - { - if ([value isEqual: leftResult]) - return YES; - } - - return NO; - } - return ([rightResult rangeOfString: leftResult options: compareOptions].location != NSNotFound); - case NSCustomSelectorPredicateOperatorType: - { - BOOL (*function)(id,SEL,id) = (BOOL (*)(id,SEL,id))[leftResult methodForSelector: _selector]; - return function(leftResult, _selector, rightResult); - } - default: - return NO; - } -} - -- (BOOL) evaluateWithObject: (id)object -{ - id leftValue = [_left expressionValueWithObject: object context: nil]; - id rightValue = [_right expressionValueWithObject: object context: nil]; - - if (_modifier == NSDirectPredicateModifier) - { - return [self _evaluateLeftValue: leftValue rightValue: rightValue]; - } - else - { - BOOL result = (_modifier == NSAllPredicateModifier); - NSEnumerator *e; - id value; - - if (![leftValue respondsToSelector: @selector(objectEnumerator)]) - { - [NSException raise: NSInvalidArgumentException - format: @"The left hand side for an ALL or ANY operator must be a collection"]; - } - - e = [leftValue objectEnumerator]; - while ((value = [e nextObject])) - { - BOOL eval = [self _evaluateLeftValue: value rightValue: rightValue]; - if (eval != result) - return eval; - } - - return result; - } -} - -- (id) copyWithZone: (NSZone *)z -{ - NSComparisonPredicate *copy; - - copy = (NSComparisonPredicate *)NSCopyObject(self, 0, z); - copy->_left = [_left copyWithZone: z]; - copy->_right = [_right copyWithZone: z]; - return copy; -} - -- (Class) classForCoder -{ - return [NSComparisonPredicate class]; -} - -- (void) encodeWithCoder: (NSCoder *)coder -{ - // FIXME - [self subclassResponsibility: _cmd]; -} - -- (id) initWithCoder: (NSCoder *)coder -{ - // FIXME - [self subclassResponsibility: _cmd]; - return self; + // FIXME ... perform substitution in the left and right expressions + return [copy autorelease]; } @end - - @implementation NSExpression + (NSExpression *) expressionForConstantValue: (id)obj { GSConstantValueExpression *e; - e = [[GSConstantValueExpression alloc] - initWithExpressionType: NSConstantValueExpressionType]; - ASSIGN(e->_obj, obj); - return AUTORELEASE(e); + e = [[[GSConstantValueExpression alloc] init] autorelease]; + e->_obj = [obj retain]; + return e; } + (NSExpression *) expressionForEvaluatedObject { - GSEvaluatedObjectExpression *e; - - e = [[GSEvaluatedObjectExpression alloc] - initWithExpressionType: NSEvaluatedObjectExpressionType]; - return AUTORELEASE(e); + return [[[GSEvaluatedObjectExpression alloc] init] autorelease]; } + (NSExpression *) expressionForFunction: (NSString *)name - arguments: (NSArray *)args + arguments: (NSArray *)args { GSFunctionExpression *e; NSString *s; - e = [[GSFunctionExpression alloc] initWithExpressionType: NSFunctionExpressionType]; + e = [[[GSFunctionExpression alloc] init] autorelease]; s = [NSString stringWithFormat: @"_eval_%@: context: ", name]; e->_selector = NSSelectorFromString(s); if (![e respondsToSelector: e->_selector]) { [NSException raise: NSInvalidArgumentException - format: @"Unknown function implementation: %@", name]; + format: @"Unknown function implementation: %@", name]; } - ASSIGN(e->_function, name); + e->_function = [name retain]; e->_argc = [args count]; - ASSIGN(e->_args, args); - return AUTORELEASE(e); + e->_args = [args retain]; + e->_eargs = [args copy]; // space for evaluated arguments + return e; } + (NSExpression *) expressionForKeyPath: (NSString *)path @@ -1014,34 +787,18 @@ [NSException raise: NSInvalidArgumentException format: @"Keypath is not NSString: %@", path]; } - e = [[GSKeyPathExpression alloc] - initWithExpressionType: NSKeyPathExpressionType]; - ASSIGN(e->_keyPath, path); - return AUTORELEASE(e); + e = [[[GSKeyPathExpression alloc] init] autorelease]; + e->_keyPath = [path retain]; + return e; } + (NSExpression *) expressionForVariable: (NSString *)string { GSVariableExpression *e; - e = [[GSVariableExpression alloc] - initWithExpressionType: NSVariableExpressionType]; - ASSIGN(e->_variable, string); - return AUTORELEASE(e); -} - -- (id) initWithExpressionType: (NSExpressionType)type -{ - if ((self = [super init]) != nil) - { - _type = type; - } - return self; -} - -- (id) copyWithZone: (NSZone *)z -{ - return NSCopyObject(self, 0, z); + e = [[[GSVariableExpression alloc] init] autorelease]; + e->_variable = [string retain]; + return e; } - (NSArray *) arguments @@ -1064,7 +821,8 @@ - (NSExpressionType) expressionType { - return _type; + [self subclassResponsibility: _cmd]; + return 0; } - (id) expressionValueWithObject: (id)object @@ -1098,25 +856,39 @@ return nil; } -- (Class) classForCoder +- (id) initWithExpressionType: (NSExpressionType)type { - return [NSExpression class]; + [self release]; + switch (type) + { + case NSConstantValueExpressionType: + return [[GSConstantValueExpression alloc] init]; + case NSEvaluatedObjectExpressionType: + return [[GSEvaluatedObjectExpression alloc] init]; + case NSVariableExpressionType: + return [[GSVariableExpression alloc] init]; + case NSKeyPathExpressionType: + return [[GSKeyPathExpression alloc] init]; + case NSFunctionExpressionType: + return [[GSFunctionExpression alloc] init]; + default: + return nil; + + } } -- (void) encodeWithCoder: (NSCoder *)coder +- (id) copyWithZone: (NSZone *)z { - // FIXME - [self subclassResponsibility: _cmd]; -} - -- (id) initWithCoder: (NSCoder *)coder -{ - // FIXME [self subclassResponsibility: _cmd]; return nil; } -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables +- (void) encodeWithCoder: (NSCoder *)coder +{ + [self subclassResponsibility: _cmd]; +} + +- (id) initWithCoder: (NSCoder *)coder { [self subclassResponsibility: _cmd]; return nil; @@ -1126,6 +898,11 @@ @implementation GSConstantValueExpression +- (NSArray *) arguments +{ + return nil; +} + - (id) constantValue { return _obj; @@ -1133,7 +910,12 @@ - (NSString *) description { - return [_obj description]; + return _obj; +} + +- (NSExpressionType) expressionType +{ + return NSConstantValueExpressionType; } - (id) expressionValueWithObject: (id)object @@ -1142,61 +924,127 @@ return _obj; } +- (NSString *) function +{ + return nil; +} + +- (NSString *) keyPath +{ + return nil; +} + +- (NSExpression *) operand +{ + return nil; +} + +- (NSString *) variable +{ + return nil; +} + - (void) dealloc { - RELEASE(_obj); + [_obj release]; [super dealloc]; } -- (id) copyWithZone: (NSZone*)zone -{ - GSConstantValueExpression *copy; - - copy = (GSConstantValueExpression *)[super copyWithZone: zone]; - copy->_obj = [_obj copyWithZone: zone]; - return copy; -} - -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables -{ - return self; -} - @end @implementation GSEvaluatedObjectExpression +- (NSArray *) arguments +{ + return nil; +} + +- (id) constantValue +{ + return nil; +} + - (NSString *) description { return @"SELF"; } +- (NSExpressionType) expressionType +{ + return NSEvaluatedObjectExpressionType; +} + - (id) expressionValueWithObject: (id)object context: (NSMutableDictionary *)context { return self; } -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables +- (NSString *) function { - return self; + return nil; +} + +- (NSString *) keyPath +{ + return nil; +} + +- (NSExpression *) operand +{ + return nil; +} + +- (NSString *) variable +{ + return nil; } @end @implementation GSVariableExpression +- (NSArray *) arguments +{ + return nil; +} + +- (id) constantValue +{ + return nil; +} + - (NSString *) description { return [NSString stringWithFormat: @"$%@", _variable]; } +- (NSExpressionType) expressionType +{ + return NSVariableExpressionType; +} + - (id) expressionValueWithObject: (id)object context: (NSMutableDictionary *)context { return [context objectForKey: _variable]; } +- (NSString *) function +{ + return nil; +} + +- (NSString *) keyPath +{ + return nil; +} + +- (NSExpression *) operand +{ + return nil; +} + - (NSString *) variable { return _variable; @@ -1204,73 +1052,66 @@ - (void) dealloc; { - RELEASE(_variable); + [_variable release]; [super dealloc]; } -- (id) copyWithZone: (NSZone*)zone -{ - GSVariableExpression *copy; - - copy = (GSVariableExpression *)[super copyWithZone: zone]; - copy->_variable = [_variable copyWithZone: zone]; - return copy; -} - -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables -{ - id result = [variables objectForKey: _variable]; - - if (result != nil) - { - return [NSExpression expressionForConstantValue: result]; - } - else - { - return self; - } -} - @end @implementation GSKeyPathExpression +- (NSArray *) arguments +{ + return nil; +} + +- (id) constantValue +{ + return nil; +} + - (NSString *) description { return _keyPath; } +- (NSExpressionType) expressionType +{ + return NSKeyPathExpressionType; +} + - (id) expressionValueWithObject: (id)object context: (NSMutableDictionary *)context { return [object valueForKeyPath: _keyPath]; } +- (NSString *) function +{ + return nil; +} + - (NSString *) keyPath { return _keyPath; } +- (NSExpression *) operand +{ + return nil; +} + +- (NSString *) variable +{ + return nil; +} + - (void) dealloc; { - RELEASE(_keyPath); + [_keyPath release]; [super dealloc]; } -- (id) copyWithZone: (NSZone*)zone -{ - GSKeyPathExpression *copy; - - copy = (GSKeyPathExpression *)[super copyWithZone: zone]; - copy->_keyPath = [_keyPath copyWithZone: zone]; - return copy; -} - -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables -{ - return self; -} - @end @implementation GSFunctionExpression @@ -1280,225 +1121,138 @@ return _args; } +- (id) constantValue +{ + return nil; +} + - (NSString *) description { - // FIXME: here we should recognize binary and unary operators + // here we should recognize binary and unary operators // and convert back to standard format // and add parentheses if required return [NSString stringWithFormat: @"%@(%@)", - [self function], _args]; + [NSStringFromSelector (_selector) substringFromIndex: 6], _args]; } +- (NSExpressionType) expressionType +{ + return NSFunctionExpressionType; +} + +- (id) expressionValueWithObject: (id)object + context: (NSMutableDictionary *)context +{ // apply method selector + unsigned int i; + + for (i = 0; i < _argc; i++) + { + id o; + + o = [_args objectAtIndex: i]; + o = [o expressionValueWithObject: object context: context]; + [_eargs replaceObjectAtIndex: i withObject: o]; + } + return [self performSelector: _selector + withObject: object + withObject: context]; +} + +- (id) _eval__chs: (id)object context: (NSMutableDictionary *)context +{ + return [NSNumber numberWithInt: -[[_eargs objectAtIndex: 0] intValue]]; +} + +- (id) _eval__first: (id)object context: (NSMutableDictionary *)context +{ + return [[_eargs objectAtIndex: 0] objectAtIndex: 0]; +} + +- (id) _eval__last: (id)object context: (NSMutableDictionary *)context +{ + return [[_eargs objectAtIndex: 0] lastObject]; +} + +- (id) _eval__index: (id)object context: (NSMutableDictionary *)context +{ + if ([[_eargs objectAtIndex: 0] isKindOfClass: [NSDictionary class]]) + return [[_eargs objectAtIndex: 0] objectForKey: [_eargs objectAtIndex: 1]]; + return [[_eargs objectAtIndex: 0] objectAtIndex: [[_eargs objectAtIndex: 1] unsignedIntValue]]; // raises exception if invalid +} + +- (id) _eval_count: (id)object context: (NSMutableDictionary *)context +{ + if (_argc != 1) + ; // error + return [NSNumber numberWithUnsignedInt: [[_eargs objectAtIndex: 0] count]]; +} + +- (id) _eval_avg: (NSArray *)expressions + context: (NSMutableDictionary *)context +{ + NIMP; + return [NSNumber numberWithDouble: 0.0]; +} + +- (id) _eval_sum: (NSArray *)expressions + context: (NSMutableDictionary *)context +{ + NIMP; + return [NSNumber numberWithDouble: 0.0]; +} + +- (id) _eval_min: (NSArray *)expressions + context: (NSMutableDictionary *)context +{ + NIMP; + return [NSNumber numberWithDouble: 0.0]; +} + +- (id) _eval_max: (NSArray *)expressions + context: (NSMutableDictionary *)context +{ + NIMP; + return [NSNumber numberWithDouble: 0.0]; +} + +// add arithmetic functions: average, median, mode, stddev, sqrt, log, ln, exp, floor, ceiling, abs, trunc, random, randomn, now + - (NSString *) function { return _function; } -- (id) expressionValueWithObject: (id)object - context: (NSMutableDictionary *)context -{ - // temporary space - NSMutableArray *eargs = [NSMutableArray arrayWithCapacity: _argc]; - unsigned int i; +- (NSString *) keyPath +{ + return nil; +} - for (i = 0; i < _argc; i++) - { - [eargs addObject: [[_args objectAtIndex: i] - expressionValueWithObject: object context: context]]; - } - // apply method selector - return [self performSelector: _selector - withObject: eargs]; +- (NSExpression *) operand +{ + return nil; +} + +- (NSString *) variable +{ + return nil; } - (void) dealloc; { - RELEASE(_args); - RELEASE(_function); + [_args release]; + [_eargs release]; + [_function release]; [super dealloc]; } -- (id) copyWithZone: (NSZone*)zone -{ - GSFunctionExpression *copy; - - copy = (GSFunctionExpression *)[super copyWithZone: zone]; - copy->_function = [_function copyWithZone: zone]; - copy->_args = [_args copyWithZone: zone]; - return copy; -} - -- (id) _expressionWithSubstitutionVariables: (NSDictionary *)variables -{ - NSMutableArray *args = [NSMutableArray arrayWithCapacity: _argc]; - unsigned int i; - - for (i = 0; i < _argc; i++) - { - [args addObject: [[_args objectAtIndex: i] - _expressionWithSubstitutionVariables: variables]]; - } - - return [NSExpression expressionForFunction: _function arguments: args]; -} - -- (id) _eval__chs: (NSArray *)expressions -{ - return [NSNumber numberWithInt: -[[expressions objectAtIndex: 0] intValue]]; -} - -- (id) _eval__first: (NSArray *)expressions -{ - return [[expressions objectAtIndex: 0] objectAtIndex: 0]; -} - -- (id) _eval__last: (NSArray *)expressions -{ - return [[expressions objectAtIndex: 0] lastObject]; -} - -- (id) _eval__index: (NSArray *)expressions -{ - id left = [expressions objectAtIndex: 0]; - id right = [expressions objectAtIndex: 1]; - - if ([left isKindOfClass: [NSDictionary class]]) - { - return [left objectForKey: right]; - } - else - { - // raises exception if invalid - return [left objectAtIndex: [right unsignedIntValue]]; - } -} - -- (id) _eval__pow: (NSArray *)expressions -{ - id left = [expressions objectAtIndex: 0]; - id right = [expressions objectAtIndex: 1]; - - return [NSNumber numberWithDouble: pow([left doubleValue], [right doubleValue])]; -} - -- (id) _eval__mul: (NSArray *)expressions -{ - id left = [expressions objectAtIndex: 0]; - id right = [expressions objectAtIndex: 1]; - - return [NSNumber numberWithDouble: [left doubleValue] * [right doubleValue]]; -} - -- (id) _eval__div: (NSArray *)expressions -{ - id left = [expressions objectAtIndex: 0]; - id right = [expressions objectAtIndex: 1]; - - return [NSNumber numberWithDouble: [left doubleValue] / [right doubleValue]]; -} - -- (id) _eval__add: (NSArray *)expressions -{ - id left = [expressions objectAtIndex: 0]; - id right = [expressions objectAtIndex: 1]; - - return [NSNumber numberWithDouble: [left doubleValue] + [right doubleValue]]; -} - -- (id) _eval__sub: (NSArray *)expressions -{ - id left = [expressions objectAtIndex: 0]; - id right = [expressions objectAtIndex: 1]; - - return [NSNumber numberWithDouble: [left doubleValue] - [right doubleValue]]; -} - -- (id) _eval_count: (NSArray *)expressions -{ - NSAssert(_argc == 1, NSInternalInconsistencyException); - return [NSNumber numberWithUnsignedInt: - [[expressions objectAtIndex: 0] count]]; -} - -- (id) _eval_avg: (NSArray *)expressions -{ - unsigned int i; - double sum = 0.0; - - for (i = 0; i < _argc; i++) - { - sum += [[expressions objectAtIndex: i] doubleValue]; - } - return [NSNumber numberWithDouble: sum / _argc]; -} - -- (id) _eval_sum: (NSArray *)expressions -{ - unsigned int i; - double sum = 0.0; - - for (i = 0; i < _argc; i++) - { - sum += [[expressions objectAtIndex: i] doubleValue]; - } - return [NSNumber numberWithDouble: sum]; -} - -- (id) _eval_min: (NSArray *)expressions -{ - unsigned int i; - double min = 0.0; - double cur; - - if (_argc > 0) - { - min = [[expressions objectAtIndex: 0] doubleValue]; - } - - for (i = 1; i < _argc; i++) - { - cur = [[expressions objectAtIndex: i] doubleValue]; - if (min > cur) - { - min = cur; - } - } - return [NSNumber numberWithDouble: min]; -} - -- (id) _eval_max: (NSArray *)expressions -{ - unsigned int i; - double max = 0.0; - double cur; - - if (_argc > 0) - { - max = [[expressions objectAtIndex: 0] doubleValue]; - } - - for (i = 1; i < _argc; i++) - { - cur = [[expressions objectAtIndex: i] doubleValue]; - if (max < cur) - { - max = cur; - } - } - return [NSNumber numberWithDouble: max]; -} - -// add arithmetic functions: average, median, mode, stddev, sqrt, log, ln, exp, floor, ceiling, abs, trunc, random, randomn, now - @end - - @implementation NSArray (NSPredicate) - (NSArray *) filteredArrayUsingPredicate: (NSPredicate *)predicate { NSMutableArray *result; + NSEnumerator *e = [self objectEnumerator]; id object; @@ -1506,82 +1260,19 @@ while ((object = [e nextObject]) != nil) { if ([predicate evaluateWithObject: object] == YES) - { - [result addObject: object]; // passes filter - } + { + [result addObject: object]; // passes filter + } } - return [result makeImmutableCopyOnFail: NO]; + return result; // we could/should convert to a non-mutable copy } @end -@implementation NSMutableArray (NSPredicate) - -- (void) filterUsingPredicate: (NSPredicate *)predicate -{ - unsigned count = [self count]; - - while (count-- > 0) - { - id object = [self objectAtIndex: count]; - - if ([predicate evaluateWithObject: object] == NO) - { - [self removeObjectAtIndex: count]; - } - } -} - -@end - -@implementation NSSet (NSPredicate) - -- (NSSet *) filteredSetUsingPredicate: (NSPredicate *)predicate -{ - NSMutableSet *result; - NSEnumerator *e = [self objectEnumerator]; - id object; - - result = [NSMutableSet setWithCapacity: [self count]]; - while ((object = [e nextObject]) != nil) - { - if ([predicate evaluateWithObject: object] == YES) - { - [result addObject: object]; // passes filter - } - } - return [result makeImmutableCopyOnFail: NO]; -} - -@end - -@implementation NSMutableSet (NSPredicate) - -- (void) filterUsingPredicate: (NSPredicate *)predicate -{ - NSMutableSet *rejected; - NSEnumerator *e = [self objectEnumerator]; - id object; - - rejected = [NSMutableSet setWithCapacity: [self count]]; - while ((object = [e nextObject]) != nil) - { - if ([predicate evaluateWithObject: object] == NO) - { - [rejected addObject: object]; - } - } - [self minusSet: rejected]; -} - -@end - - - @implementation GSPredicateScanner - (id) initWithString: (NSString*)format - args: (NSArray*)args + args: (NSArray*)args { self = [super initWithString: format]; if (self != nil) @@ -1591,9 +1282,48 @@ return self; } +- (id) initWithString: (NSString*)format + vargs: (va_list)vargs +{ + self = [super initWithString: format]; + if (self != nil) + { +#ifdef __va_copy + __va_copy(_vargs, vargs); +#else + _vargs = vargs; +#endif + } + return self; +} + - (id) nextArg { - return [_args nextObject]; + id o; + + if (_args != nil) + { + o = [_args nextObject]; + } + else + { + unsigned i; + va_list ap; + +#ifdef __va_copy + __va_copy(ap, _vargs); +#else + ap = _vargs; +#endif + + for (i = 0; i < _retrieved; i++) + { + o = va_arg(ap, id); + } + _retrieved++; + o = va_arg(ap, id); + } + return o; } - (BOOL) scanPredicateKeyword: (NSString *)key @@ -1608,14 +1338,6 @@ // no match return NO; } - - if ([self isAtEnd]) - { - // ok - return YES; - } - - // Does the next character still belong to the token? c = [[self string] characterAtIndex: [self scanLocation]]; if (![[NSCharacterSet alphanumericCharacterSet] characterIsMember: c]) { @@ -1631,19 +1353,9 @@ - (NSPredicate *) parse { - NSPredicate *r = nil; - - NS_DURING - { - r = [self parsePredicate]; - } - NS_HANDLER - { - NSLog(@"Parsing failed for %@ with %@", [self string], localException); - [localException raise]; - } - NS_ENDHANDLER + NSPredicate *r; + r = [self parsePredicate]; if (![self isAtEnd]) { [NSException raise: NSInvalidArgumentException @@ -1662,43 +1374,42 @@ { NSPredicate *l = [self parseOr]; - while ([self scanPredicateKeyword: @"AND"] - || [self scanPredicateKeyword: @"&&"]) + while ([self scanPredicateKeyword: @"AND"]) { NSPredicate *r = [self parseOr]; if ([r isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)r compoundPredicateType] - == NSAndPredicateType) + && [(NSCompoundPredicate *)r compoundPredicateType] + == NSAndPredicateType) { - // merge - if ([l isKindOfClass:[NSCompoundPredicate class]] - && [(NSCompoundPredicate *)l compoundPredicateType] - == NSAndPredicateType) - { - [(NSMutableArray *)[(NSCompoundPredicate *)l subpredicates] - addObjectsFromArray: [(NSCompoundPredicate *)r subpredicates]]; - } - else - { - [(NSMutableArray *)[(NSCompoundPredicate *)r subpredicates] - insertObject: l atIndex: 0]; - l = r; - } - } + // merge + if ([l isKindOfClass:[NSCompoundPredicate class]] + && [(NSCompoundPredicate *)l compoundPredicateType] + == NSAndPredicateType) + { + [(NSMutableArray *)[(NSCompoundPredicate *)l subpredicates] + addObjectsFromArray: [(NSCompoundPredicate *)r subpredicates]]; + } + else + { + [(NSMutableArray *)[(NSCompoundPredicate *)r subpredicates] + insertObject: l atIndex: 0]; + l = r; + } + } else if ([l isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)l compoundPredicateType] - == NSAndPredicateType) + && [(NSCompoundPredicate *)l compoundPredicateType] + == NSAndPredicateType) { - // add to l - [(NSMutableArray *)[(NSCompoundPredicate *)l subpredicates] - addObject: r]; - } + // add to l + [(NSMutableArray *)[(NSCompoundPredicate *)l subpredicates] + addObject: r]; + } else { - l = [NSCompoundPredicate andPredicateWithSubpredicates: - [NSArray arrayWithObjects: l, r, nil]]; - } + l = [NSCompoundPredicate andPredicateWithSubpredicates: + [NSArray arrayWithObjects:l, r, nil]]; + } } return l; } @@ -1711,17 +1422,17 @@ if (![self scanString: @")" intoString: NULL]) { - [NSException raise: NSInvalidArgumentException - format: @"Missing ) in compound predicate"]; - } + [NSException raise: NSInvalidArgumentException + format: @"Missing ) in compound predicate"]; + } return r; } - if ([self scanPredicateKeyword: @"NOT"] || [self scanPredicateKeyword: @"!"]) + if ([self scanPredicateKeyword: @"NOT"]) { // -> NOT NOT x or NOT (y) return [NSCompoundPredicate - notPredicateWithSubpredicate: [self parseNot]]; + notPredicateWithSubpredicate: [self parseNot]]; } if ([self scanPredicateKeyword: @"TRUEPREDICATE"]) @@ -1740,42 +1451,41 @@ { NSPredicate *l = [self parseNot]; - while ([self scanPredicateKeyword: @"OR"] - || [self scanPredicateKeyword: @"||"]) + while ([self scanPredicateKeyword: @"OR"]) { NSPredicate *r = [self parseNot]; if ([r isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)r compoundPredicateType] - == NSOrPredicateType) + && [(NSCompoundPredicate *)r compoundPredicateType] + == NSOrPredicateType) { - // merge - if ([l isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)l compoundPredicateType] - == NSOrPredicateType) - { - [(NSMutableArray *)[(NSCompoundPredicate *)l subpredicates] - addObjectsFromArray: [(NSCompoundPredicate *)r subpredicates]]; - } - else - { - [(NSMutableArray *)[(NSCompoundPredicate *)r subpredicates] - insertObject: l atIndex: 0]; - l = r; - } - } + // merge + if ([l isKindOfClass: [NSCompoundPredicate class]] + && [(NSCompoundPredicate *)l compoundPredicateType] + == NSOrPredicateType) + { + [(NSMutableArray *)[(NSCompoundPredicate *)l subpredicates] + addObjectsFromArray: [(NSCompoundPredicate *)r subpredicates]]; + } + else + { + [(NSMutableArray *)[(NSCompoundPredicate *)r subpredicates] + insertObject: l atIndex: 0]; + l = r; + } + } else if ([l isKindOfClass: [NSCompoundPredicate class]] - && [(NSCompoundPredicate *)l compoundPredicateType] - == NSOrPredicateType) + && [(NSCompoundPredicate *)l compoundPredicateType] + == NSOrPredicateType) { - [(NSMutableArray *) [(NSCompoundPredicate *) l subpredicates] - addObject:r]; - } + [(NSMutableArray *) [(NSCompoundPredicate *) l subpredicates] + addObject:r]; + } else { - l = [NSCompoundPredicate orPredicateWithSubpredicates: - [NSArray arrayWithObjects: l, r, nil]]; - } + l = [NSCompoundPredicate orPredicateWithSubpredicates: + [NSArray arrayWithObjects: l, r, nil]]; + } } return l; } @@ -1787,10 +1497,8 @@ NSPredicateOperatorType type = 0; unsigned opts = 0; NSExpression *left; - NSExpression *right; NSPredicate *p; BOOL negate = NO; - BOOL swap = NO; if ([self scanPredicateKeyword: @"ANY"]) { @@ -1811,35 +1519,31 @@ negate = YES; } - left = [self parseExpression]; - if ([self scanString: @"!=" intoString: NULL] - || [self scanString: @"<>" intoString: NULL]) - { - type = NSNotEqualToPredicateOperatorType; - } - else if ([self scanString: @"<=" intoString: NULL] - || [self scanString: @"=<" intoString: NULL]) - { - type = NSLessThanOrEqualToPredicateOperatorType; - } - else if ([self scanString: @">=" intoString: NULL] - || [self scanString: @"=>" intoString: NULL]) - { - type = NSGreaterThanOrEqualToPredicateOperatorType; - } - else if ([self scanString: @"<" intoString: NULL]) + left = [self parseBinaryExpression]; + if ([self scanString: @"<" intoString: NULL]) { type = NSLessThanPredicateOperatorType; } + else if ([self scanString: @"<=" intoString: NULL]) + { + type = NSLessThanOrEqualToPredicateOperatorType; + } else if ([self scanString: @">" intoString: NULL]) { type = NSGreaterThanPredicateOperatorType; } - else if ([self scanString: @"==" intoString: NULL] - || [self scanString: @"=" intoString: NULL]) + else if ([self scanString: @">=" intoString: NULL]) + { + type = NSGreaterThanOrEqualToPredicateOperatorType; + } + else if ([self scanString: @"=" intoString: NULL]) { type = NSEqualToPredicateOperatorType; } + else if ([self scanString: @"!=" intoString: NULL]) + { + type = NSNotEqualToPredicateOperatorType; + } else if ([self scanPredicateKeyword: @"MATCHES"]) { type = NSMatchesPredicateOperatorType; @@ -1860,55 +1564,17 @@ { type = NSInPredicateOperatorType; } - else if ([self scanPredicateKeyword: @"CONTAINS"]) - { - type = NSInPredicateOperatorType; - swap = YES; - } - else if ([self scanPredicateKeyword: @"BETWEEN"]) - { - // Requires special handling to transfer into AND of - // two normal comparison predicates - NSExpression *exp = [self parseSimpleExpression]; - NSArray *a = (NSArray *)[exp constantValue]; - NSNumber *lower, *upper; - NSExpression *lexp, *uexp; - NSPredicate *lp, *up; - - if (![a isKindOfClass: [NSArray class]]) - { - [NSException raise: NSInvalidArgumentException - format: @"BETWEEN operator requires array argument"]; - } - - lower = [a objectAtIndex: 0]; - upper = [a objectAtIndex: 1]; - lexp = [NSExpression expressionForConstantValue: lower]; - uexp = [NSExpression expressionForConstantValue: upper]; - lp = [NSComparisonPredicate predicateWithLeftExpression: left - rightExpression: lexp - modifier: modifier - type: NSGreaterThanPredicateOperatorType - options: opts]; - up = [NSComparisonPredicate predicateWithLeftExpression: left - rightExpression: uexp - modifier: modifier - type: NSLessThanPredicateOperatorType - options: opts]; - return [NSCompoundPredicate andPredicateWithSubpredicates: - [NSArray arrayWithObjects: lp, up, nil]]; - } else { [NSException raise: NSInvalidArgumentException - format: @"Invalid comparison predicate: %@", + format: @"Invalid comparison predicate: %@", [[self string] substringFromIndex: [self scanLocation]]]; } if ([self scanString: @"[cd]" intoString: NULL]) { opts = NSCaseInsensitivePredicateOption - | NSDiacriticInsensitivePredicateOption; + | NSDiacriticInsensitivePredicateOption; } else if ([self scanString: @"[c]" intoString: NULL]) { @@ -1919,41 +1585,25 @@ opts = NSDiacriticInsensitivePredicateOption; } - right = [self parseExpression]; - if (swap == YES) - { - NSExpression *tmp = left; - - left = right; - right = tmp; - } - p = [NSComparisonPredicate predicateWithLeftExpression: left - rightExpression: right - modifier: modifier - type: type - options: opts]; + rightExpression: [self parseBinaryExpression] + modifier: modifier + type: type + options: opts]; return negate ? [NSCompoundPredicate notPredicateWithSubpredicate: p] : p; } - (NSExpression *) parseExpression -{ -// return [self parseAdditionExpression]; - return [self parseBinaryExpression]; -} - -- (NSExpression *) parseSimpleExpression { static NSCharacterSet *_identifier; - unsigned location; - NSString *ident; - double dbl; + NSString *ident; + double dbl; if ([self scanDouble: &dbl]) { return [NSExpression expressionForConstantValue: - [NSNumber numberWithDouble: dbl]]; + [NSNumber numberWithDouble: dbl]]; } // FIXME: handle integer, hex constants, 0x 0o 0b @@ -1969,9 +1619,9 @@ if (![self scanString: @")" intoString: NULL]) { - [NSException raise: NSInvalidArgumentException - format: @"Missing ) in expression"]; - } + [NSException raise: NSInvalidArgumentException + format: @"Missing ) in expression"]; + } return arg; } @@ -1981,41 +1631,40 @@ if ([self scanString: @"}" intoString: NULL]) { - // empty - return [NSExpression expressionForConstantValue: a]; - } + // empty + // FIXME + return nil; + } // first element [a addObject: [self parseExpression]]; while ([self scanString: @"," intoString: NULL]) { - // more elements - [a addObject: [self parseExpression]]; - } + // more elements + [a addObject: [self parseExpression]]; + } if (![self scanString: @"}" intoString: NULL]) { - [NSException raise: NSInvalidArgumentException - format: @"Missing } in aggregate"]; - } - return [NSExpression expressionForConstantValue: a]; + [NSException raise: NSInvalidArgumentException + format: @"Missing } in aggregate"]; + } + // FIXME + return nil; } - if ([self scanPredicateKeyword: @"NULL"] - || [self scanPredicateKeyword: @"NIL"]) + if ([self scanPredicateKeyword: @"NULL"]) { return [NSExpression expressionForConstantValue: [NSNull null]]; } - if ([self scanPredicateKeyword: @"TRUE"] - || [self scanPredicateKeyword: @"YES"]) + if ([self scanPredicateKeyword: @"TRUE"]) { return [NSExpression expressionForConstantValue: - [NSNumber numberWithBool: YES]]; + [NSNumber numberWithBool: YES]]; } - if ([self scanPredicateKeyword: @"FALSE"] - || [self scanPredicateKeyword: @"NO"]) + if ([self scanPredicateKeyword: @"FALSE"]) { return [NSExpression expressionForConstantValue: - [NSNumber numberWithBool: NO]]; + [NSNumber numberWithBool: NO]]; } if ([self scanPredicateKeyword: @"SELF"]) { @@ -2028,116 +1677,34 @@ if (![var keyPath]) { - [NSException raise: NSInvalidArgumentException - format: @"Invalid variable identifier: %@", var]; - } - return [NSExpression expressionForVariable: [var keyPath]]; + [NSException raise: NSInvalidArgumentException + format: @"Invalid variable identifier: %@", var]; + } + return [NSExpression expressionForVariable:[var keyPath]]; } - location = [self scanLocation]; - - if ([self scanString: @"%" intoString: NULL]) + if ([self scanPredicateKeyword: @"%K"]) { - if ([self isAtEnd] == NO) - { - unichar c = [[self string] characterAtIndex: [self scanLocation]]; + return [NSExpression expressionForKeyPath: [self nextArg]]; + } - switch (c) - { - case '%': // '%%' is treated as '%' - location = [self scanLocation]; - break; - - case 'K': - [self setScanLocation: [self scanLocation] + 1]; - return [NSExpression expressionForKeyPath: - [self nextArg]]; - - case '@': - case 'c': - case 'C': - case 'd': - case 'D': - case 'i': - case 'o': - case 'O': - case 'u': - case 'U': - case 'x': - case 'X': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - [self setScanLocation: [self scanLocation] + 1]; - return [NSExpression expressionForConstantValue: - [self nextArg]]; - - case 'h': - [self scanString: @"h" intoString: NULL]; - if ([self isAtEnd] == NO) - { - c = [[self string] characterAtIndex: [self scanLocation]]; - if (c == 'i' || c == 'u') - { - [self setScanLocation: [self scanLocation] + 1]; - return [NSExpression expressionForConstantValue: - [self nextArg]]; - } - } - break; - - case 'q': - [self scanString: @"q" intoString: NULL]; - if ([self isAtEnd] == NO) - { - c = [[self string] characterAtIndex: [self scanLocation]]; - if (c == 'i' || c == 'u' || c == 'x' || c == 'X') - { - [self setScanLocation: [self scanLocation] + 1]; - return [NSExpression expressionForConstantValue: - [self nextArg]]; - } - } - break; - } - } - - [self setScanLocation: location]; + if ([self scanPredicateKeyword: @"%@"]) + { + return [NSExpression expressionForConstantValue: [self nextArg]]; } + // FIXME: other formats if ([self scanString: @"\"" intoString: NULL]) { - NSCharacterSet *skip = [self charactersToBeSkipped]; - NSString *str = nil; - - [self setCharactersToBeSkipped: nil]; - if ([self scanUpToString: @"\"" intoString: &str] == NO) - { - [self setCharactersToBeSkipped: skip]; - [NSException raise: NSInvalidArgumentException - format: @"Invalid double quoted literal at %u", location]; - } - [self setCharactersToBeSkipped: skip]; - [self scanString: @"\"" intoString: NULL]; + NSString *str = @"string constant"; + return [NSExpression expressionForConstantValue: str]; } if ([self scanString: @"'" intoString: NULL]) { - NSCharacterSet *skip = [self charactersToBeSkipped]; - NSString *str = nil; + NSString *str = @"string constant"; - [self setCharactersToBeSkipped: nil]; - if ([self scanUpToString: @"'" intoString: &str] == NO) - { - [self setCharactersToBeSkipped: skip]; - [NSException raise: NSInvalidArgumentException - format: @"Invalid single quoted literal at %u", location]; - } - [self setCharactersToBeSkipped: skip]; - [self scanString: @"'" intoString: NULL]; return [NSExpression expressionForConstantValue: str]; } @@ -2147,28 +1714,29 @@ if (![e keyPath]) { - [NSException raise: NSInvalidArgumentException - format: @"Invalid keypath identifier: %@", e]; - } + [NSException raise: NSInvalidArgumentException + format: @"Invalid keypath identifier: %@", e]; + } // prefix with keypath return [NSExpression expressionForKeyPath: - [NSString stringWithFormat: @"@%@", [e keyPath]]]; + [NSString stringWithFormat: @"@%@", [e keyPath]]]; } // skip # as prefix (reserved words) [self scanString: @"#" intoString: NULL]; if (!_identifier) { - ASSIGN(_identifier, [NSCharacterSet characterSetWithCharactersInString: - @"_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"]); + _identifier = [NSCharacterSet characterSetWithCharactersInString: + @"_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"]; + RETAIN(_identifier); } if (![self scanCharactersFromSet: _identifier intoString: &ident]) { [NSException raise: NSInvalidArgumentException - format: @"Missing identifier: %@", - [[self string] substringFromIndex: [self scanLocation]]]; + format: @"Missing identifier: %@", + [[self string] substringFromIndex: [self scanLocation]]]; } return [NSExpression expressionForKeyPath: ident]; @@ -2176,102 +1744,102 @@ - (NSExpression *) parseFunctionalExpression { - NSExpression *left = [self parseSimpleExpression]; + NSExpression *left = [self parseExpression]; while (YES) { if ([self scanString: @"(" intoString: NULL]) { // function - this parser allows for (max)(a, b, c) to be properly - // recognized and even (%K)(a, b, c) if %K evaluates to "max" - NSMutableArray *args = [NSMutableArray arrayWithCapacity: 5]; + // recognized and even (%K)(a, b, c) if %K evaluates to "max" + NSMutableArray *args = [NSMutableArray arrayWithCapacity: 5]; - if (![left keyPath]) - { - [NSException raise: NSInvalidArgumentException - format: @"Invalid function identifier: %@", left]; - } + if (![left keyPath]) + { + [NSException raise: NSInvalidArgumentException + format: @"Invalid function identifier: %@", left]; + } - if (![self scanString: @")" intoString: NULL]) - { - // any arguments - // first argument - [args addObject: [self parseExpression]]; - while ([self scanString: @"," intoString: NULL]) - { - // more arguments - [args addObject: [self parseExpression]]; - } + if (![self scanString: @")" intoString: NULL]) + { + // any arguments + // first argument + [args addObject: [self parseExpression]]; + while ([self scanString: @"," intoString: NULL]) + { + // more arguments + [args addObject: [self parseExpression]]; + } - if (![self scanString: @")" intoString: NULL]) - { - [NSException raise: NSInvalidArgumentException - format: @"Missing ) in function arguments"]; - } - } - left = [NSExpression expressionForFunction: [left keyPath] - arguments: args]; - } + if (![self scanString: @")" intoString: NULL]) + { + [NSException raise: NSInvalidArgumentException + format: @"Missing ) in function arguments"]; + } + } + left = [NSExpression expressionForFunction: [left keyPath] + arguments: args]; + } else if ([self scanString: @"[" intoString: NULL]) { - // index expression - if ([self scanPredicateKeyword: @"FIRST"]) - { - left = [NSExpression expressionForFunction: @"_first" - arguments: [NSArray arrayWithObject: [self parseExpression]]]; - } - else if ([self scanPredicateKeyword: @"LAST"]) - { - left = [NSExpression expressionForFunction: @"_last" - arguments: [NSArray arrayWithObject: [self parseExpression]]]; - } - else if ([self scanPredicateKeyword: @"SIZE"]) - { - left = [NSExpression expressionForFunction: @"count" - arguments: [NSArray arrayWithObject: [self parseExpression]]]; - } - else - { - left = [NSExpression expressionForFunction: @"_index" - arguments: [NSArray arrayWithObjects: left, - [self parseExpression], nil]]; - } - if (![self scanString: @"]" intoString: NULL]) - { - [NSException raise: NSInvalidArgumentException - format: @"Missing ] in index argument"]; - } - } + // index expression + if ([self scanPredicateKeyword: @"FIRST"]) + { + left = [NSExpression expressionForFunction: @"_first" + arguments: [NSArray arrayWithObject: [self parseExpression]]]; + } + else if ([self scanPredicateKeyword: @"LAST"]) + { + left = [NSExpression expressionForFunction: @"_last" + arguments: [NSArray arrayWithObject: [self parseExpression]]]; + } + else if ([self scanPredicateKeyword: @"SIZE"]) + { + left = [NSExpression expressionForFunction: @"count" + arguments: [NSArray arrayWithObject: [self parseExpression]]]; + } + else + { + left = [NSExpression expressionForFunction: @"_index" + arguments: [NSArray arrayWithObjects: left, + [self parseExpression], nil]]; + } + if (![self scanString: @"]" intoString: NULL]) + { + [NSException raise: NSInvalidArgumentException + format: @"Missing ] in index argument"]; + } + } else if ([self scanString: @"." intoString: NULL]) { - // keypath - this parser allows for (a).(b.c) - // to be properly recognized - // and even %K.((%K)) if the first %K evaluates to "a" and the - // second %K to "b.c" - NSExpression *right; + // keypath - this parser allows for (a).(b.c) + // to be properly recognized + // and even %K.((%K)) if the first %K evaluates to "a" and the + // second %K to "b.c" + NSExpression *right; - if (![left keyPath]) - { - [NSException raise: NSInvalidArgumentException - format: @"Invalid left keypath: %@", left]; - } - right = [self parseExpression]; - if (![right keyPath]) - { - [NSException raise: NSInvalidArgumentException - format: @"Invalid right keypath: %@", left]; - } + if (![left keyPath]) + { + [NSException raise: NSInvalidArgumentException + format: @"Invalid left keypath: %@", left]; + } + right = [self parseExpression]; + if (![right keyPath]) + { + [NSException raise: NSInvalidArgumentException + format: @"Invalid right keypath: %@", left]; + } - // concatenate - left = [NSExpression expressionForKeyPath: - [NSString stringWithFormat: @"%@.%@", - [left keyPath], [right keyPath]]]; - } + // concatenate + left = [NSExpression expressionForKeyPath: + [NSString stringWithFormat: @"%@.%@", + [left keyPath], [right keyPath]]]; + } else { - // done with suffixes - return left; - } + // done with suffixes + return left; + } } } @@ -2285,14 +1853,13 @@ if ([self scanString: @"**" intoString: NULL]) { - right = [self parseFunctionalExpression]; - left = [NSExpression expressionForFunction: @"_pow" - arguments: [NSArray arrayWithObjects: left, right, nil]]; - } + right = [self parseFunctionalExpression]; + // FIXME + } else { - return left; - } + return left; + } } } @@ -2306,20 +1873,18 @@ if ([self scanString: @"*" intoString: NULL]) { - right = [self parsePowerExpression]; - left = [NSExpression expressionForFunction: @"_mul" - arguments: [NSArray arrayWithObjects: left, right, nil]]; - } + right = [self parsePowerExpression]; + // FIXME + } else if ([self scanString: @"/" intoString: NULL]) { - right = [self parsePowerExpression]; - left = [NSExpression expressionForFunction: @"_div" - arguments: [NSArray arrayWithObjects: left, right, nil]]; - } + right = [self parsePowerExpression]; + // FIXME + } else { - return left; - } + return left; + } } } @@ -2333,20 +1898,18 @@ if ([self scanString: @"+" intoString: NULL]) { - right = [self parseMultiplicationExpression]; - left = [NSExpression expressionForFunction: @"_add" - arguments: [NSArray arrayWithObjects: left, right, nil]]; - } + right = [self parseMultiplicationExpression]; + // FIXME + } else if ([self scanString: @"-" intoString: NULL]) { - right = [self parseMultiplicationExpression]; - left = [NSExpression expressionForFunction: @"_sub" - arguments: [NSArray arrayWithObjects: left, right, nil]]; - } + right = [self parseMultiplicationExpression]; + // FIXME + } else { - return left; - } + return left; + } } } @@ -2360,15 +1923,15 @@ if ([self scanString: @":=" intoString: NULL]) // assignment { - // check left to be a variable? - right = [self parseAdditionExpression]; - // FIXME - } + // check left to be a variable? + right = [self parseAdditionExpression]; + } else - { - return left; - } + { + return left; + } } } + @end diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 8953d4842..6a0f335df 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,7 +17,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -54,7 +54,8 @@ * - To the NEXTSTEP/GNUStep community *************************************************************************/ -#import "common.h" +#include "config.h" +#include "GNUstepBase/preface.h" #ifdef HAVE_UNISTD_H #include #endif @@ -64,19 +65,8 @@ #endif /* HAVE_STRERROR */ #include +#include #include - -#ifdef HAVE_WINDOWS_H -# include -#endif - -#ifdef HAVE_SYS_SIGNAL_H -#include -#endif -#ifdef HAVE_SIGNAL_H -#include -#endif - #include #ifdef HAVE_SYS_FCNTL_H #include @@ -89,11 +79,8 @@ #include #include #include -#endif /* HAVE_KVM_ENV */ - -#ifdef HAVE_SYS_SYSCTL_H #include -#endif +#endif /* HAVE_KVM_ENV */ #if HAVE_PROCFS_H #define id _procfs_avoid_id_collision @@ -101,21 +88,22 @@ #undef id #endif -#import "GNUstepBase/GSConfig.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSBundle.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSLock.h" -#import "GNUstepBase/NSProcessInfo+GNUstepBase.h" -#import "GNUstepBase/NSString+GNUstepBase.h" +#include "GNUstepBase/GSConfig.h" +#include "Foundation/NSString.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSBundle.h" +#include "Foundation/NSSet.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSException.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSHost.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSDebug.h" +#include "GNUstepBase/GSCategories.h" -#import "GSPrivate.h" +#include "GSPrivate.h" @interface NSBundle (Private) + (NSString*) _gnustep_target_os; @@ -215,10 +203,12 @@ static unsigned int _operatingSystem = 0; static NSString *_operatingSystemName = nil; static NSString *_operatingSystemVersion = nil; +// Array of debug levels set. +static NSMutableSet *_debug_set = nil; + // Flag to indicate that fallbackInitialisation was executed. static BOOL fallbackInitialisation = NO; -static NSMutableSet *mySet = nil; /************************************************************************* *** Implementing the gnustep_base_user_main function *************************************************************************/ @@ -243,7 +233,7 @@ _gnu_process_args(int argc, char *argv[], char *env[]) } else { -#if defined(__MINGW__) +#if defined(__MINGW32__) unichar *buffer; int buffer_size = 0; int needed_size = 0; @@ -285,7 +275,7 @@ _gnu_process_args(int argc, char *argv[], char *env[]) /* Getting the process name */ IF_NO_GC(RELEASE(_gnu_processName)); _gnu_processName = [arg0 lastPathComponent]; -#if defined(__MINGW__) +#if defined(__MINGW32__) /* On windows we remove any .exe extension for consistency with app names * under unix */ @@ -301,18 +291,19 @@ _gnu_process_args(int argc, char *argv[], char *env[]) IF_NO_GC(RETAIN(_gnu_processName)); /* Copy the argument list */ -#if defined(__MINGW__) +#if defined(__MINGW32__) { unichar **argvw = CommandLineToArgvW(GetCommandLineW(), &argc); NSString *str; + NSMutableSet *mySet; id obj_argv[argc]; int added = 1; + mySet = [NSMutableSet new]; + /* Copy the zero'th argument to the argument list */ obj_argv[0] = arg0; - if (mySet == nil) mySet = [NSMutableSet new]; - for (i = 1; i < argc; i++) { str = [NSString stringWithCharacters: argvw[i] length: wcslen(argvw[i])]; @@ -328,21 +319,24 @@ _gnu_process_args(int argc, char *argv[], char *env[]) IF_NO_GC(RELEASE(_gnu_arguments)); _gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added]; + IF_NO_GC(RELEASE(_debug_set)); + _debug_set = mySet; RELEASE(arg0); } #else if (argv) { NSString *str; + NSMutableSet *mySet; id obj_argv[argc]; int added = 1; NSStringEncoding enc = GSPrivateDefaultCStringEncoding(); + mySet = [NSMutableSet new]; + /* Copy the zero'th argument to the argument list */ obj_argv[0] = arg0; - if (mySet == nil) mySet = [NSMutableSet new]; - for (i = 1; i < argc; i++) { str = [NSString stringWithCString: argv[i] encoding: enc]; @@ -355,6 +349,8 @@ _gnu_process_args(int argc, char *argv[], char *env[]) IF_NO_GC(RELEASE(_gnu_arguments)); _gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added]; + IF_NO_GC(RELEASE(_debug_set)); + _debug_set = mySet; RELEASE(arg0); } #endif @@ -365,7 +361,7 @@ _gnu_process_args(int argc, char *argv[], char *env[]) NSMutableArray *values = [NSMutableArray new]; NSStringEncoding enc = GSPrivateDefaultCStringEncoding(); -#if defined(__MINGW__) +#if defined(__MINGW32__) if (fallbackInitialisation == NO) { unichar *base; @@ -528,11 +524,6 @@ static char **_gnu_noobjc_env = NULL; if (!vectors) { fprintf(stderr, "Error: libkvm does not return arguments for the current process\n"); - fprintf(stderr, "this may be due to a bug (undocumented feature) in libkvm\n"); - fprintf(stderr, "which fails to get arguments unless /proc is mounted.\n"); - fprintf(stderr, "If so, you can mount the /proc filesystem or reconfigure/build\n"); - fprintf(stderr, "gnustep-base with --enable-fake-main as a workaround, and\n"); - fprintf(stderr, "should report the bug to the maintainer of libkvm on your operating system.\n"); abort(); } @@ -561,7 +552,7 @@ static char **_gnu_noobjc_env = NULL; // Read commandline proc_file_name = (char*)objc_malloc(sizeof(char) * 2048); - sprintf(proc_file_name, "/proc/%d/psinfo", (int)getpid()); + sprintf(proc_file_name, "/proc/%d/psinfo", (int) getpid()); ifp = fopen(proc_file_name, "r"); if (ifp == NULL) @@ -670,7 +661,7 @@ static char **_gnu_noobjc_env = NULL; // Read commandline proc_file_name = (char *)objc_malloc(sizeof(char) * 2048); - sprintf(proc_file_name, "/proc/%d/cmdline", (int)getpid()); + sprintf(proc_file_name, "/proc/%d/cmdline", (int) getpid()); /* * We read the /proc file thrice. @@ -777,10 +768,6 @@ static char **_gnu_noobjc_env = NULL; proc_fs_error: #ifdef HAVE_STRERROR - /* Don't care about thread safety of strerror() here as this is only - * called in the initial thread and there shouldn't be any other - * threads at this point. - */ fprintf(stderr, "Couldn't open file %s when starting gnustep-base; %s\n", proc_file_name, strerror(errno)); #else /* !HAVE_FUNCTION_STRERROR */ @@ -844,18 +831,15 @@ _gnu_noobjc_free_vars(void) if (self == [NSProcessInfo class] && !_gnu_processName && !_gnu_arguments && !_gnu_environment) { - if(_gnu_noobjc_argv == 0 || _gnu_noobjc_env == 0) - { - _NSLog_printf_handler(_GNU_MISSING_MAIN_FUNCTION_CALL); - exit(1); - } + NSAssert(_gnu_noobjc_argv && _gnu_noobjc_env, + _GNU_MISSING_MAIN_FUNCTION_CALL); _gnu_process_args(_gnu_noobjc_argc, _gnu_noobjc_argv, _gnu_noobjc_env); _gnu_noobjc_free_vars(); } } #else /*! HAVE_PROCFS !HAVE_LOAD_METHOD !HAVE_KVM_ENV */ -#ifdef __MINGW__ +#ifdef __MINGW32__ /* For WindowsAPI Library, we know the global variables (argc, etc) */ + (void) initialize { @@ -882,26 +866,6 @@ extern char **__libc_argv; #else #ifndef GS_PASS_ARGUMENTS #undef main -/* The gnustep_base_user_main function is declared 'weak' so that the linker - * should actually use the one compiled as the program's 'main' function. - * The internal version gets called only if the program does not implement - * the function (ie the prgram was compiled with the wrong version of - * GSConfig.h included/imported). The other possible reason for the internal - * function to be called would be a compiler/linker issue (eg 'weak' not - * supported). - */ -int gnustep_base_user_main () __attribute__((weak)); -int gnustep_base_user_main (int argc, char *argv[], char *env[]) -{ - fprintf(stderr, "\nGNUSTEP Internal Error:\n" -"The GNUstep function to establish the argv and environment variables could\n" -"not find the main function of your program.\n" -"Perhaps your program failed to #include or\n" -" (or included/imported a different version of the\n" -"header from the one supplied with this copy of the gnustep-base library)?\n" -"If that is not the case, Please report the error to bug-gnustep@gnu.org.\n"); - exit(1); -} int main(int argc, char *argv[], char *env[]) { #ifdef NeXT_RUNTIME @@ -912,7 +876,7 @@ int main(int argc, char *argv[], char *env[]) sizeof(_NSConstantStringClassReference)); #endif -#if defined(__MINGW__) +#if defined(__MINGW32__) WSADATA lpWSAData; // Initialize Windows Sockets @@ -921,7 +885,7 @@ int main(int argc, char *argv[], char *env[]) printf("Could not startup Windows Sockets\n"); exit(1); } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ #ifdef __MS_WIN__ _MB_init_runtime(); @@ -933,7 +897,7 @@ int main(int argc, char *argv[], char *env[]) return gnustep_base_user_main(argc, argv, env); } #endif /* !GS_PASS_ARGUMENTS */ -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ #endif /* HAS_LOAD_METHOD && HAS_PROCFS */ @@ -944,54 +908,17 @@ int main(int argc, char *argv[], char *env[]) if (!(_gnu_processName && _gnu_arguments && _gnu_environment)) { _NSLog_printf_handler(_GNU_MISSING_MAIN_FUNCTION_CALL); - exit(1); + [NSException raise: NSInternalInconsistencyException + format: _GNU_MISSING_MAIN_FUNCTION_CALL]; } if (!_gnu_sharedProcessInfoObject) { _gnu_sharedProcessInfoObject = [[_NSConcreteProcessInfo alloc] init]; - [gnustep_global_lock lock]; - if (mySet != nil) - { - NSEnumerator *e = [mySet objectEnumerator]; - NSMutableSet *s = [_gnu_sharedProcessInfoObject debugSet]; - id o; - - while ((o = [e nextObject]) != nil) - { - [s addObject: o]; - } - [mySet release]; - mySet = nil; - } - [gnustep_global_lock unlock]; } - return _gnu_sharedProcessInfoObject; } -+ (BOOL) _exists: (int)pid -{ - if (pid > 0) - { -#if defined(__MINGW__) - HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION,0,pid); - if (h == NULL && GetLastError() != ERROR_ACCESS_DENIED) - { - return NO; - } - CloseHandle(h); -#else - if (kill(pid, 0) < 0 && errno == ESRCH) - { - return NO; - } -#endif - return YES; - } - return NO; -} - - (NSArray *) arguments { return _gnu_arguments; @@ -1018,7 +945,7 @@ int main(int argc, char *argv[], char *env[]) pid = [self processIdentifier]; start = (unsigned long)GSTimeNow(); host = [[self hostName] stringByReplacingString: @"." withString: @"_"]; - IF_NO_GC(RETAIN(host);) + RETAIN(host); } count = counter++; [gnustep_global_lock unlock]; @@ -1045,7 +972,7 @@ static void determineOperatingSystem() NSString *os = nil; BOOL parseOS = YES; -#if defined(__MINGW__) +#if defined(__MINGW32__) OSVERSIONINFOW osver; osver.dwOSVersionInfoSize = sizeof(osver); @@ -1087,7 +1014,7 @@ static void determineOperatingSystem() } } #endif /* HAVE_SYS_UTSNAME_H */ -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ if (_operatingSystemVersion == nil) { @@ -1174,7 +1101,7 @@ static void determineOperatingSystem() } } -- (NSUInteger) operatingSystem +- (unsigned int) operatingSystem { if (_operatingSystem == 0) { @@ -1205,7 +1132,7 @@ static void determineOperatingSystem() { int pid; -#if defined(__MINGW__) +#if defined(__MINGW32__) pid = (int)GetCurrentProcessId(); #else pid = (int)getpid(); @@ -1220,192 +1147,56 @@ static void determineOperatingSystem() - (void) setProcessName: (NSString *)newName { - if (newName && [newName length]) - { - [_gnu_processName autorelease]; - _gnu_processName = [newName copyWithZone: [self zone]]; - } + if (newName && [newName length]) { + [_gnu_processName autorelease]; + _gnu_processName = [newName copyWithZone: [self zone]]; + } return; } -- (NSUInteger) processorCount -{ - static NSUInteger procCount = 0; - static BOOL beenHere = NO; - - if (beenHere == NO) - { -#if defined(__MINGW__) - SYSTEM_INFO info; - - GetSystemInfo(&info); - return info.dwNumberOfProcessors; -#elif defined(_SC_NPROCESSORS_CONF) - procCount = sysconf(_SC_NPROCESSORS_CONF); -#elif defined(HAVE_SYSCTLBYNAME) - int val; - size_t len = sizeof(val); - - if (sysctlbyname("hw.ncpu", &val, &len, 0, 0) == 0) - { - procCount = val; - } -#elif defined(HAVE_PROCFS) - NSFileManager *fileManager = [NSFileManager defaultManager]; - - if ([fileManager fileExistsAtPath: @"/proc/cpuinfo"]) - { - NSString *cpuInfo; - NSArray *a; - unsigned i; - - cpuInfo = [NSString stringWithContentsOfFile: @"/proc/cpuinfo"]; - a = [cpuInfo componentsSeparatedByCharactersInSet: - [NSCharacterSet whitespaceAndNewlineCharacterSet]]; - // syntax is processor : # - // count up each one - for (i = 0; i < [a count]; ++i) - { - if ([[a objectAtIndex: i] isEqualToString: @"processor"]) - { - if (((i+1) < [a count]) - && [[a objectAtIndex: i+1] isEqualToString: @":"]) - { - procCount++; - } - } - } - } -#else -#warning "no known way to determine number of processors on this system" -#endif - - beenHere = YES; - if (procCount == 0) - { - NSLog(@"Cannot determine processor count."); - } - } - return procCount; -} - -- (NSUInteger) activeProcessorCount -{ -#if defined(__MINGW__) - SYSTEM_INFO info; - int index; - int count = 0; - - GetSystemInfo(&info); - for (index = 0; index < 32; index++) - { - if (info.dwActiveProcessorMask & (1< -#import "GNUstepBase/GSMime.h" +#include +#include "GNUstepBase/preface.h" +#include "GNUstepBase/GSMime.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSByteOrder.h" -#import "Foundation/NSCalendarDate.h" -#import "Foundation/NSCharacterSet.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSPropertyList.h" -#import "Foundation/NSSerialization.h" -#import "Foundation/NSTimeZone.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSNull.h" -#import "Foundation/NSXMLParser.h" -#import "GNUstepBase/Unicode.h" -#import "GNUstepBase/NSProcessInfo+GNUstepBase.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GNUstepBase/NSString+GNUstepBase.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSByteOrder.h" +#include "Foundation/NSCalendarDate.h" +#include "Foundation/NSCharacterSet.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSException.h" +#include "Foundation/NSPropertyList.h" +#include "Foundation/NSSerialization.h" +#include "Foundation/NSString.h" +#include "Foundation/NSTimeZone.h" +#include "Foundation/NSUserDefaults.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSDebug.h" +#include "Foundation/NSXMLParser.h" +#include "GNUstepBase/Unicode.h" -#import "GSPrivate.h" - -@class GSSloppyXMLParser; - -#define inrange(ch,min,max) ((ch)>=(min) && (ch)<=(max)) -#define char2num(ch) \ -inrange(ch,'0','9') \ -? ((ch)-0x30) \ -: (inrange(ch,'a','f') \ -? ((ch)-0x57) : ((ch)-0x37)) - -/* - * Cache classes. - */ -static Class NSArrayClass; -static Class NSDataClass; -static Class NSDateClass; -static Class NSDictionaryClass; -static Class NSNumberClass; -static Class NSStringClass; -static Class NSMutableStringClass; -static Class GSStringClass; -static Class GSMutableStringClass; +#include "GSPrivate.h" extern BOOL GSScanDouble(unichar*, unsigned, double*); @@ -87,9 +64,6 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*); NSString *key; BOOL inArray; BOOL inDictionary; - BOOL inString; - BOOL parsed; - BOOL success; id plist; NSPropertyListMutabilityOptions opts; } @@ -109,10 +83,6 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*); namespaceURI: (NSString *)namespaceURI qualifiedName: (NSString *)qName; - (id) result; -- (void) unescape; -@end - -@interface GSSloppyXMLParser : NSXMLParser @end @implementation GSXMLPListParser @@ -132,7 +102,8 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*); { if ((self = [super init]) != nil) { - theParser = [[GSSloppyXMLParser alloc] initWithData: data]; + stack = [[NSMutableArray alloc] initWithCapacity: 10]; + theParser = [[NSXMLParser alloc] initWithData: data]; [theParser setDelegate: self]; opts = options; } @@ -140,18 +111,13 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*); } - (void) parser: (NSXMLParser *)parser -foundCharacters: (NSString *)string + foundCharacters: (NSString *)string { - [value appendString: string]; -} - -- (void) parser: (NSXMLParser *)parser -foundIgnorableWhitespace: (NSString *)string -{ - if (YES == inString) + if (value == nil) { - [value appendString: string]; + value = [[NSMutableString alloc] initWithCapacity: 50]; } + [value appendString: string]; } - (void) parser: (NSXMLParser *)parser @@ -164,12 +130,6 @@ foundIgnorableWhitespace: (NSString *)string { NSMutableDictionary *d; - if (key == nil) - { - key = RETAIN([NSNull null]); - } - [stack addObject: key]; - DESTROY(key); d = [[NSMutableDictionary alloc] initWithCapacity: 10]; [stack addObject: d]; RELEASE(d); @@ -180,22 +140,12 @@ foundIgnorableWhitespace: (NSString *)string { NSMutableArray *a; - if (key == nil) - { - key = RETAIN([NSNull null]); - } - [stack addObject: key]; - DESTROY(key); a = [[NSMutableArray alloc] initWithCapacity: 10]; [stack addObject: a]; RELEASE(a); inArray = YES; inDictionary = NO; } - else if ([elementName isEqualToString: @"string"] == YES) - { - inString = YES; - } } - (void) parser: (NSXMLParser *)parser @@ -205,12 +155,11 @@ foundIgnorableWhitespace: (NSString *)string { BOOL inContainer = NO; - inString = NO; if ([elementName isEqualToString: @"dict"] == YES) { inContainer = YES; } - else if ([elementName isEqualToString: @"array"] == YES) + if ([elementName isEqualToString: @"array"] == YES) { inContainer = YES; } @@ -225,25 +174,19 @@ foundIgnorableWhitespace: (NSString *)string { ASSIGN(plist, [[stack lastObject] makeImmutableCopyOnFail: NO]); } - [stack removeLastObject]; inArray = NO; inDictionary = NO; - ASSIGN(key, [stack lastObject]); - [stack removeLastObject]; - if ((id)key == (id)[NSNull null]) - { - DESTROY(key); - } if ([stack count] > 0) { id last; + [stack removeLastObject]; last = [stack lastObject]; - if ([last isKindOfClass: NSArrayClass] == YES) + if ([last isKindOfClass: [NSArray class]] == YES) { inArray = YES; } - else if ([last isKindOfClass: NSDictionaryClass] == YES) + else if ([last isKindOfClass: [NSDictionary class]] == YES) { inDictionary = YES; } @@ -251,9 +194,8 @@ foundIgnorableWhitespace: (NSString *)string } else if ([elementName isEqualToString: @"key"] == YES) { - [self unescape]; - ASSIGNCOPY(key, value); - [value setString: @""]; + ASSIGN(key, [value makeImmutableCopyOnFail: NO]); + DESTROY(value); return; } else if ([elementName isEqualToString: @"data"]) @@ -293,14 +235,27 @@ foundIgnorableWhitespace: (NSString *)string { id o; - [self unescape]; if (opts == NSPropertyListMutableContainersAndLeaves) { - o = [value mutableCopy]; + if (value == nil) + { + o = [NSMutableString string]; + } + else + { + o = value; + } } else { - o = [value copy]; + if (value == nil) + { + o = @""; + } + else + { + o = [value makeImmutableCopyOnFail: NO]; + } } ASSIGN(plist, o); } @@ -322,7 +277,7 @@ foundIgnorableWhitespace: (NSString *)string } else if ([elementName isEqualToString: @"plist"]) { - [value setString: @""]; + DESTROY(value); return; } else // invalid tag @@ -346,19 +301,12 @@ foundIgnorableWhitespace: (NSString *)string [(NSMutableDictionary*)[stack lastObject] setObject: plist forKey: key]; DESTROY(key); } - [value setString: @""]; + DESTROY(value); } - (BOOL) parse { - if (parsed == NO) - { - parsed = YES; - stack = [[NSMutableArray alloc] initWithCapacity: 10]; - value = [[NSMutableString alloc] initWithCapacity: 50]; - success = [theParser parse]; - } - return success; + return [theParser parse]; } - (id) result @@ -366,56 +314,6 @@ foundIgnorableWhitespace: (NSString *)string return plist; } -- (void) unescape -{ - id o; - NSRange r; - - /* Convert any \Uxxxx sequences to unicode characters. - */ - r = NSMakeRange(0, [value length]); - while (r.length >= 6) - { - r = [value rangeOfString: @"\\U" options: NSLiteralSearch range: r]; - if (r.length == 2 && [value length] >= r.location + 6) - { - unichar c; - unichar v; - - c = [value characterAtIndex: r.location + 2]; - if (isxdigit(c)) - { - v = char2num(c); - c = [value characterAtIndex: r.location + 3]; - if (isxdigit(c)) - { - v <<= 4; - v |= char2num(c); - c = [value characterAtIndex: r.location + 4]; - if (isxdigit(c)) - { - v <<= 4; - v |= char2num(c); - c = [value characterAtIndex: r.location + 5]; - if (isxdigit(c)) - { - v <<= 4; - v |= char2num(c); - o = [NSString alloc]; - o = [o initWithCharacters: &v length: 1]; - r.length += 4; - [value replaceCharactersInRange: r withString: o]; - [o release]; - r.location++; - r.length = 0; - } - } - } - } - r = NSMakeRange(NSMaxRange(r), [value length] - NSMaxRange(r)); - } - } -} @end @@ -428,22 +326,21 @@ foundIgnorableWhitespace: (NSString *)string NSData *data; unsigned offset_size; // Number of bytes per table entry unsigned index_size; // Number of bytes per table entry - unsigned object_count; // Number of objects - unsigned root_index; // Index of root object unsigned table_start; // Start address of object table + unsigned table_len; // Length of object table } - (id) initWithData: (NSData*)plData mutability: (NSPropertyListMutabilityOptions)m; - (id) rootObject; -- (id) objectAtIndex: (NSUInteger)index; +- (id) objectAtIndex: (unsigned)index; @end @interface BinaryPLGenerator : NSObject { NSMutableData *dest; - NSMapTable *objectList; + NSMutableArray *objectList; NSMutableArray *objectsToDoList; id root; @@ -465,6 +362,14 @@ foundIgnorableWhitespace: (NSString *)string @end +/* + * Cache classes and method implementations for speed. + */ +static Class NSDataClass; +static Class NSStringClass; +static Class NSMutableStringClass; +static Class GSStringClass; +static Class GSMutableStringClass; static Class plArray; static id (*plAdd)(id, SEL, id) = 0; @@ -472,99 +377,49 @@ static id (*plAdd)(id, SEL, id) = 0; static Class plDictionary; static id (*plSet)(id, SEL, id, id) = 0; -/* Bitmap of 'quotable' characters ... those characters which must be - * inside a quoted string if written to an old style property list. - */ -static const unsigned char quotables[32] = { - '\xff', - '\xff', - '\xff', - '\xff', - '\x85', - '\x13', - '\x00', - '\x78', - '\x00', - '\x00', - '\x00', - '\x38', - '\x01', - '\x00', - '\x00', - '\xa8', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', - '\xff', -}; - -/* Bitmap of characters considered white space if in an old style property - * list. This is the same as the set given by the isspace() function in the - * POSIX locale, but (for cross-locale portability of property list files) - * is fixed, rather than locale dependent. - */ -static const unsigned char whitespace[32] = { - '\x00', - '\x3f', - '\x00', - '\x00', - '\x01', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', - '\x00', -}; #define IS_BIT_SET(a,i) ((((a) & (1<<(i)))) > 0) -#define GS_IS_QUOTABLE(X) IS_BIT_SET(quotables[(X)/8], (X) % 8) +static unsigned const char *hexdigitsBitmapRep = NULL; +#define GS_IS_HEXDIGIT(X) IS_BIT_SET(hexdigitsBitmapRep[(X)/8], (X) % 8) -#define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespace[(X)/8], (X) % 8) +static void setupHexdigits(void) +{ + if (hexdigitsBitmapRep == NULL) + { + NSCharacterSet *hexdigits; + NSData *bitmap; + hexdigits = [NSCharacterSet characterSetWithCharactersInString: + @"0123456789abcdefABCDEF"]; + bitmap = RETAIN([hexdigits bitmapRepresentation]); + hexdigitsBitmapRep = [bitmap bytes]; + } +} + +static NSCharacterSet *quotables = nil; static NSCharacterSet *oldQuotables = nil; static NSCharacterSet *xmlQuotables = nil; +static unsigned const char *quotablesBitmapRep = NULL; +#define GS_IS_QUOTABLE(X) IS_BIT_SET(quotablesBitmapRep[(X)/8], (X) % 8) + static void setupQuotables(void) { - if (oldQuotables == nil) + if (quotablesBitmapRep == NULL) { NSMutableCharacterSet *s; + NSData *bitmap; + s = [[NSCharacterSet characterSetWithCharactersInString: + @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + @"abcdefghijklmnopqrstuvwxyz!#$%&*+-./:?@|~_^"] + mutableCopy]; + [s invert]; + quotables = [s copy]; + RELEASE(s); + bitmap = RETAIN([quotables bitmapRepresentation]); + quotablesBitmapRep = [bitmap bytes]; s = [[NSCharacterSet characterSetWithCharactersInString: @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" @"abcdefghijklmnopqrstuvwxyz$./_"] @@ -585,6 +440,41 @@ static void setupQuotables(void) } } +static unsigned const char *whitespaceBitmapRep = NULL; +#define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespaceBitmapRep[(X)/8], (X) % 8) + +static void setupWhitespace(void) +{ + if (whitespaceBitmapRep == NULL) + { + NSCharacterSet *whitespace; + NSData *bitmap; + +/* + We can not use whitespaceAndNewlineCharacterSet here as this would lead + to a recursion, as this also reads in a property list. + whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; +*/ + whitespace = [NSCharacterSet characterSetWithCharactersInString: + @" \t\r\n\f\b"]; + + bitmap = RETAIN([whitespace bitmapRepresentation]); + whitespaceBitmapRep = [bitmap bytes]; + } +} + +#ifdef HAVE_LIBXML +#include "GNUstepBase/GSXML.h" +static int XML_ELEMENT_NODE; +#endif + +#define inrange(ch,min,max) ((ch)>=(min) && (ch)<=(max)) +#define char2num(ch) \ +inrange(ch,'0','9') \ +? ((ch)-0x30) \ +: (inrange(ch,'a','f') \ +? ((ch)-0x57) : ((ch)-0x37)) + typedef struct { const unsigned char *ptr; unsigned end; @@ -704,7 +594,7 @@ static inline id parseQuotedString(pldata* pld) } else if (escaped > 1) { - if (hex && isxdigit(c)) + if (hex && GS_IS_HEXDIGIT(c)) { shrink++; escaped++; @@ -775,7 +665,7 @@ static inline id parseQuotedString(pldata* pld) return nil; } length = temp_length - shrink; - chars = NSAllocateCollectable(sizeof(unichar) * length, 0); + chars = NSZoneMalloc(NSDefaultMallocZone(), sizeof(unichar) * length); escaped = 0; hex = NO; for (j = 0, k = 0; j < temp_length; j++) @@ -798,7 +688,7 @@ static inline id parseQuotedString(pldata* pld) } else if (escaped > 1) { - if (hex && isxdigit(c)) + if (hex && GS_IS_HEXDIGIT(c)) { chars[k] <<= 4; chars[k] |= char2num(c); @@ -897,7 +787,7 @@ static inline id parseUnquotedString(pldata *pld) } length = pld->pos - start; - chars = NSAllocateCollectable(sizeof(unichar) * length, 0); + chars = NSZoneMalloc(NSDefaultMallocZone(), sizeof(unichar) * length); for (i = 0; i < length; i++) { chars[i] = pld->ptr[start + i]; @@ -1173,8 +1063,8 @@ static id parsePlItem(pldata* pld) data = [[NSMutableData alloc] initWithCapacity: 0]; skipSpace(pld); while (pld->pos < max - && isxdigit(pld->ptr[pld->pos]) - && isxdigit(pld->ptr[pld->pos+1])) + && GS_IS_HEXDIGIT(pld->ptr[pld->pos]) + && GS_IS_HEXDIGIT(pld->ptr[pld->pos+1])) { unsigned char byte; @@ -1231,6 +1121,217 @@ static id parsePlItem(pldata* pld) return result; } +#ifdef HAVE_LIBXML +static GSXMLNode* +elementNode(GSXMLNode* node) +{ + while (node != nil) + { + if ([node type] == XML_ELEMENT_NODE) + { + break; + } + node = [node next]; + } + return node; +} + +static id +nodeToObject(GSXMLNode* node, NSPropertyListMutabilityOptions o, NSString **e) +{ + CREATE_AUTORELEASE_POOL(arp); + id result = nil; + + node = elementNode(node); + if (node != nil) + { + NSString *name; + NSString *content; + GSXMLNode *children; + BOOL isKey = NO; + + name = [node name]; + children = [node firstChild]; + content = [children content]; + children = elementNode(children); + + isKey = [name isEqualToString: @"key"]; + if (isKey == YES || [name isEqualToString: @"string"] == YES) + { + if (content == nil) + { + content = @""; + } + else + { + NSRange r; + + r = [content rangeOfString: @"\\"]; + if (r.length == 1) + { + unsigned len = [content length]; + unichar buf[len]; + unsigned pos = r.location; + + [content getCharacters: buf]; + while (pos < len) + { + if (++pos < len) + { + if ((buf[pos] == 'u' || buf[pos] == 'U') + && (len >= pos + 4)) + { + unichar val = 0; + unsigned i; + BOOL ok = YES; + + for (i = 1; i < 5; i++) + { + unichar c = buf[pos + i]; + + if (c >= '0' && c <= '9') + { + val = (val << 4) + c - '0'; + } + else if (c >= 'A' && c <= 'F') + { + val = (val << 4) + c - 'A' + 10; + } + else if (c >= 'a' && c <= 'f') + { + val = (val << 4) + c - 'a' + 10; + } + else + { + ok = NO; + } + } + if (ok == YES) + { + len -= 5; + memcpy(&buf[pos], &buf[pos+5], + (len - pos) * sizeof(unichar)); + buf[pos - 1] = val; + } + } + while (pos < len && buf[pos] != '\\') + { + pos++; + } + } + } + if (isKey == NO + && o == NSPropertyListMutableContainersAndLeaves) + { + content = [NSMutableString stringWithCharacters: buf + length: len]; + } + else + { + content = [NSString stringWithCharacters: buf + length: len]; + } + } + } + result = content; + } + else if ([name isEqualToString: @"true"]) + { + result = [NSNumber numberWithBool: YES]; + } + else if ([name isEqualToString: @"false"]) + { + result = [NSNumber numberWithBool: NO]; + } + else if ([name isEqualToString: @"integer"]) + { + if (content == nil) + { + content = @"0"; + } + result = [NSNumber numberWithInt: [content intValue]]; + } + else if ([name isEqualToString: @"real"]) + { + if (content == nil) + { + content = @"0.0"; + } + result = [NSNumber numberWithDouble: [content doubleValue]]; + } + else if ([name isEqualToString: @"date"]) + { + if (content == nil) + { + content = @""; + } + if ([content hasSuffix: @"Z"] == YES && [content length] == 20) + { + result = [NSCalendarDate dateWithString: content + calendarFormat: @"%Y-%m-%dT%H:%M:%SZ"]; + } + else + { + result = [NSCalendarDate dateWithString: content + calendarFormat: @"%Y-%m-%d %H:%M:%S %z"]; + } + } + else if ([name isEqualToString: @"data"]) + { + result = [GSMimeDocument decodeBase64: + [content dataUsingEncoding: NSASCIIStringEncoding]]; + if (o == NSPropertyListMutableContainersAndLeaves) + { + result = AUTORELEASE([result mutableCopy]); + } + } + // container class + else if ([name isEqualToString: @"array"]) + { + NSMutableArray *container = [plArray array]; + + while (children != nil) + { + id val; + + val = nodeToObject(children, o, e); + [container addObject: val]; + children = [children nextElement]; + } + result = container; + if (o == NSPropertyListImmutable) + { + [result makeImmutableCopyOnFail: NO]; + } + } + else if ([name isEqualToString: @"dict"]) + { + NSMutableDictionary *container = [plDictionary dictionary]; + + while (children != nil) + { + NSString *key; + id val; + + key = nodeToObject(children, o, e); + children = [children nextElement]; + val = nodeToObject(children, o, e); + children = [children nextElement]; + [container setObject: val forKey: key]; + } + result = container; + if (o == NSPropertyListImmutable) + { + [result makeImmutableCopyOnFail: NO]; + } + } + } + RETAIN(result); + RELEASE(arp); + return AUTORELEASE(result); +} +#endif + id GSPropertyListFromStringsFormat(NSString *string) { @@ -1448,7 +1549,7 @@ PString(NSString *obj, NSMutableData *output) } else { - ustring = NSAllocateCollectable(sizeof(unichar) * length, 0); + ustring = NSZoneMalloc(NSDefaultMallocZone(), length*sizeof(unichar)); } end = &ustring[length]; [obj getCharacters: ustring]; @@ -1571,7 +1672,7 @@ PString(NSString *obj, NSMutableData *output) static void XString(NSString* obj, NSMutableData *output) { - static const char *hexdigits = "0123456789ABCDEF"; + static char *hexdigits = "0123456789ABCDEF"; unsigned end; end = [obj length]; @@ -1588,11 +1689,8 @@ XString(NSString* obj, NSMutableData *output) unsigned len; unsigned rpos; unsigned wpos; - BOOL osx; - osx = GSPrivateDefaultsFlag(GSMacOSXCompatible); - - base = NSAllocateCollectable(sizeof(unichar) * end, 0); + base = NSZoneMalloc(NSDefaultMallocZone(), end * sizeof(unichar)); [obj getCharacters: base]; for (len = rpos = 0; rpos < end; rpos++) { @@ -1615,14 +1713,7 @@ XString(NSString* obj, NSMutableData *output) if ((c < 0x20 && (c != 0x09 && c != 0x0A && c != 0x0D)) || (c > 0xD7FF && c < 0xE000) || c > 0xFFFD) { - if (osx) - { - len += 8; // Illegal in XML - } - else - { - len += 6; // Non-standard escape - } + len += 6; } else { @@ -1631,7 +1722,7 @@ XString(NSString* obj, NSMutableData *output) break; } } - map = NSAllocateCollectable(sizeof(unichar) * len, 0); + map = NSZoneMalloc(NSDefaultMallocZone(), len * sizeof(unichar)); for (wpos = rpos = 0; rpos < end; rpos++) { c = base[rpos]; @@ -1677,40 +1768,12 @@ XString(NSString* obj, NSMutableData *output) if ((c < 0x20 && (c != 0x09 && c != 0x0A && c != 0x0D)) || (c > 0xD7FF && c < 0xE000) || c > 0xFFFD) { - if (osx) - { - /* Use XML style character entity references for - * OSX compatibility, even though this is an - * illegal character code and a standards complient - * XML parser will barf when it tries to read it. - * The OSX property list parser does not implement - * the XML standard and accepts at least some - * illegal characters. - */ - map[wpos++] = '&'; - map[wpos++] = '#'; - map[wpos++] = 'x'; - map[wpos++] = hexdigits[(c>>12) & 0xf]; - map[wpos++] = hexdigits[(c>>8) & 0xf]; - map[wpos++] = hexdigits[(c>>4) & 0xf]; - map[wpos++] = hexdigits[c & 0xf]; - map[wpos++] = ';'; - } - else - { - /* We need to be able to encode characters in a - * property list which are illegal in XML (even - * when encoded as numeric entities with the - * &#...; format. So we use the same \Uxxxx - * format is in old style property lists. - */ - map[wpos++] = '\\'; - map[wpos++] = 'U'; - map[wpos++] = hexdigits[(c>>12) & 0xf]; - map[wpos++] = hexdigits[(c>>8) & 0xf]; - map[wpos++] = hexdigits[(c>>4) & 0xf]; - map[wpos++] = hexdigits[c & 0xf]; - } + map[wpos++] = '\\'; + map[wpos++] = 'U'; + map[wpos++] = hexdigits[(c>>12) & 0xf]; + map[wpos++] = hexdigits[(c>>8) & 0xf]; + map[wpos++] = hexdigits[(c>>4) & 0xf]; + map[wpos++] = hexdigits[c & 0xf]; } else { @@ -1771,11 +1834,7 @@ static void OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, NSPropertyListFormat x, NSMutableData *dest) { - if (NSStringClass == 0) - { - [NSPropertyListSerialization class]; // Force initialisation - } - if ([obj isKindOfClass: NSStringClass]) + if ([obj isKindOfClass: [NSString class]]) { if (x == NSPropertyListXMLFormat_v1_0) { @@ -1788,7 +1847,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, PString(obj, dest); } } - else if ([obj isKindOfClass: NSNumberClass]) + else if ([obj isKindOfClass: [NSNumber class]]) { const char *t = [obj objCType]; @@ -1868,7 +1927,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, } } } - else if ([obj isKindOfClass: NSDataClass]) + else if ([obj isKindOfClass: [NSData class]]) { if (x == NSPropertyListXMLFormat_v1_0) { @@ -1905,7 +1964,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, dst[j++] = '>'; } } - else if ([obj isKindOfClass: NSDateClass]) + else if ([obj isKindOfClass: [NSDate class]]) { static NSTimeZone *z = nil; @@ -1938,7 +1997,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, PString(obj, dest); } } - else if ([obj isKindOfClass: NSArrayClass]) + else if ([obj isKindOfClass: [NSArray class]]) { const char *iBaseString; const char *iSizeString; @@ -2035,7 +2094,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, } } } - else if ([obj isKindOfClass: NSDictionaryClass]) + else if ([obj isKindOfClass: [NSDictionary class]]) { const char *iBaseString; const char *iSizeString; @@ -2076,51 +2135,41 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, for (i = 0; i < numKeys; i++) { keys[i] = [keyArray objectAtIndex: i]; - plists[i] = [(NSDictionary*)obj objectForKey: keys[i]]; } } else { [keyArray getObjects: keys]; - for (i = 0; i < numKeys; i++) - { - plists[i] = (*myObj)(obj, objSel, keys[i]); - } } if (x == NSPropertyListXMLFormat_v1_0) { /* This format can only use strings as keys. */ + lastClass = [NSString class]; for (i = 0; i < numKeys; i++) { - if ([keys[i] isKindOfClass: NSStringClass] == NO) + if ([keys[i] isKindOfClass: lastClass] == NO) { [NSException raise: NSInvalidArgumentException - format: @"Bad key (%@) in property list: '%@'", - NSStringFromClass([keys[i] class]), keys[i]]; + format: @"Bad key in property list: '%@'", keys[i]]; } } } - else if (numKeys == 0) - { - canCompare = NO; - } else { /* All keys must respond to -compare: for sorting. */ - lastClass = NSStringClass; for (i = 0; i < numKeys; i++) { - if (object_getClass(keys[i]) == lastClass) + if (GSObjCClass(keys[i]) == lastClass) continue; - if ([keys[i] isKindOfClass: NSStringClass] == NO) + if ([keys[i] respondsToSelector: @selector(compare:)] == NO) { canCompare = NO; break; } - lastClass = object_getClass(keys[i]); + lastClass = GSObjCClass(keys[i]); } } @@ -2160,7 +2209,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, Class x; NSComparisonResult r; - x = object_getClass(a); + x = GSObjCClass(a); if (x != lastClass) { lastClass = x; @@ -2176,16 +2225,8 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, badComparison = YES; } #endif - - /* Swap keys and values. - */ keys[d + stride] = b; keys[d] = a; - a = plists[d + stride]; - b = plists[d]; - plists[d + stride] = b; - plists[d] = a; - if (stride > d) { break; @@ -2214,6 +2255,21 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, #endif } + if (isProxy == YES) + { + for (i = 0; i < numKeys; i++) + { + plists[i] = [(NSDictionary*)obj objectForKey: keys[i]]; + } + } + else + { + for (i = 0; i < numKeys; i++) + { + plists[i] = (*myObj)(obj, objSel, keys[i]); + } + } + if (x == NSPropertyListXMLFormat_v1_0) { [dest appendBytes: "\n" length: 7]; @@ -2298,13 +2354,16 @@ static BOOL classInitialized = NO; { classInitialized = YES; +#if HAVE_LIBXML + /* + * Cache XML node information. + */ + XML_ELEMENT_NODE = [GSXMLNode typeFromDescription: @"XML_ELEMENT_NODE"]; +#endif + NSStringClass = [NSString class]; NSMutableStringClass = [NSMutableString class]; NSDataClass = [NSData class]; - NSDateClass = [NSDate class]; - NSNumberClass = [NSNumber class]; - NSArrayClass = [NSArray class]; - NSDictionaryClass = [NSDictionary class]; GSStringClass = [GSString class]; GSMutableStringClass = [GSMutableString class]; @@ -2316,7 +2375,10 @@ static BOOL classInitialized = NO; plSet = (id (*)(id, SEL, id, id)) [plDictionary instanceMethodForSelector: @selector(setObject:forKey:)]; + setupHexdigits(); setupQuotables(); + setupWhitespace(); + } } @@ -2375,7 +2437,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, { *str = AUTORELEASE([GSMutableString new]); } - else if (object_getClass(*str) != [GSMutableString class]) + else if (GSObjCClass(*str) != [GSMutableString class]) { [NSException raise: NSInvalidArgumentException format: @"Illegal object (%@) at argument 0", *str]; @@ -2465,7 +2527,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, { error = @"nil data argument passed to method"; } - else if ([data isKindOfClass: NSDataClass] == NO) + else if ([data isKindOfClass: [NSData class]] == NO) { error = @"non-NSData data argument passed to method"; } @@ -2515,19 +2577,46 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, { case NSPropertyListXMLFormat_v1_0: { - GSXMLPListParser *parser; +#if HAVE_LIBXML + GSXMLParser *parser; + GSXMLNode *node; - parser = [GSXMLPListParser alloc]; - parser = AUTORELEASE([parser initWithData: data - mutability: anOption]); - if ([parser parse] == YES) + parser = [GSXMLParser parser]; + [parser substituteEntities: YES]; + [parser doValidityChecking: YES]; + if ([parser parse: data] == NO || [parser parse: nil] == NO) { - result = AUTORELEASE(RETAIN([parser result])); + error = @"failed to parse as valid XML matching DTD"; } - else if (error == nil) + node = [[parser document] root]; + if (error == nil && [[node name] isEqualToString: @"plist"] == NO) { error = @"failed to parse as XML property list"; } + if (error == nil) + { + result = nodeToObject([node firstChild], anOption, &error); + } +#endif + /* The libxml based parser is stricter than the fallback + * parser, so if parsing failed using that, we can try again. + */ + if (result == nil) + { + GSXMLPListParser *parser; + + parser = [GSXMLPListParser alloc]; + parser = AUTORELEASE([parser initWithData: data + mutability: anOption]); + if ([parser parse] == YES) + { + result = AUTORELEASE(RETAIN([parser result])); + } + else if (error == nil) + { + error = @"failed to parse as XML property list"; + } + } } break; @@ -2687,9 +2776,9 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, } - (id) initWithData: (NSData*)plData - mutability: (NSPropertyListMutabilityOptions)m + mutability: (NSPropertyListMutabilityOptions)m; { - unsigned length; + unsigned length; length = [plData length]; if (length < 32) @@ -2698,46 +2787,35 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, } else { - unsigned char postfix[32]; + unsigned char postfix[32]; - [plData getBytes: postfix range: NSMakeRange(length - 32, 32)]; + // FIXME: Get more of the details + [plData getBytes: postfix range: NSMakeRange(length-32, 32)]; offset_size = postfix[6]; index_size = postfix[7]; - // FIXME: Looks like the following are actually 8 byte values. - // But taking the lower 4 bytes is currently sufficient. - object_count = (postfix[12] << 24) + (postfix[13] << 16) - + (postfix[14] << 8) + postfix[15]; - root_index = (postfix[20] << 24) + (postfix[21] << 16) - + (postfix[22] << 8) + postfix[23]; table_start = (postfix[28] << 24) + (postfix[29] << 16) + (postfix[30] << 8) + postfix[31]; - if (offset_size < 1 || offset_size > 4) { - unsigned saved = offset_size; - - DESTROY(self); // Bad format [NSException raise: NSGenericException - format: @"Unknown offset size %d", saved]; + format: @"Unknown table size %d", offset_size]; + DESTROY(self); // Bad format } else if (index_size < 1 || index_size > 4) { - unsigned saved = index_size; + unsigned saved = offset_size; DESTROY(self); // Bad format [NSException raise: NSGenericException format: @"Unknown table size %d", saved]; } - else if (root_index >= object_count) - { - DESTROY(self); // Bad format - } else if (table_start > length - 32) { DESTROY(self); // Bad format } else { + table_len = length - table_start - 32; ASSIGN(data, plData); _bytes = (const unsigned char*)[data bytes]; mutability = m; @@ -2749,7 +2827,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, - (unsigned long) offsetForIndex: (unsigned)index { - if (index >= object_count) + if (index > table_len) { [NSException raise: NSRangeException format: @"Object table index out of bounds %d.", index]; @@ -2875,10 +2953,10 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, - (id) rootObject { - return [self objectAtIndex: root_index]; + return [self objectAtIndex: 0]; } -- (id) objectAtIndex: (NSUInteger)index +- (id) objectAtIndex: (unsigned)index { unsigned char next; unsigned counter = [self offsetForIndex: index]; @@ -3010,7 +3088,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, char *buffer; len = [self readCountAt: &counter]; - buffer = NSAllocateCollectable(len + 1, 0); + buffer = NSZoneMalloc(NSDefaultMallocZone(), len+1); [data getBytes: buffer range: NSMakeRange(counter, len)]; buffer[len] = '\0'; if (mutability == NSPropertyListMutableContainersAndLeaves) @@ -3055,7 +3133,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, unichar *buffer; len = [self readCountAt: &counter]; - buffer = NSAllocateCollectable(sizeof(unichar) * len, 0); + buffer = NSZoneMalloc(NSDefaultMallocZone(), sizeof(unichar)*len); [data getBytes: buffer range: NSMakeRange(counter, sizeof(unichar)*len)]; for (i = 0; i < len; i++) @@ -3124,7 +3202,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, id *objects; len = [self readCountAt: &counter]; - objects = NSAllocateCollectable(sizeof(id) * len, NSScannedOption); + objects = NSZoneMalloc(NSDefaultMallocZone(), sizeof(id) * len); for (i = 0; i < len; i++) { @@ -3189,8 +3267,8 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, id *values; len = [self readCountAt: &counter]; - keys = NSAllocateCollectable(sizeof(id) * len * 2, NSScannedOption); - values = keys + len; + keys = NSZoneMalloc(NSDefaultMallocZone(), sizeof(id)*len); + values = NSZoneMalloc(NSDefaultMallocZone(), sizeof(id)*len); for (i = 0; i < len; i++) { int oid = [self readObjectIndexAt: &counter]; @@ -3218,6 +3296,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, forKeys: keys count: len]; } + NSZoneFree(NSDefaultMallocZone(), values); NSZoneFree(NSDefaultMallocZone(), keys); } else @@ -3231,28 +3310,6 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, @end -/* Test two items for equality ... boith are objects. - * If either is an NSNumber, we insist that they are the same class - * so that numbers with the same numeric value but different classes - * are not treated as the same number (that confuses OSXs decoding). - */ -static BOOL -isEqualFunc(const void *item1, const void *item2, - NSUInteger (*size)(const void *item)) -{ - id o1 = (id)item1; - id o2 = (id)item2; - - if ([o1 isKindOfClass: [NSNumber class]] - || [o2 isKindOfClass: [NSNumber class]]) - { - if ([o1 class] != [o2 class]) - { - return NO; - } - } - return [o1 isEqual: o2]; -} @implementation BinaryPLGenerator @@ -3292,9 +3349,6 @@ isEqualFunc(const void *item1, const void *item2, - (void) setup { - NSPointerFunctions *k; - NSPointerFunctions *v; - [dest setLength: 0]; if (index_size == 1) { @@ -3313,20 +3367,13 @@ isEqualFunc(const void *item1, const void *item2, table_size = UINT_MAX; } - table = NSZoneMalloc(0, table_size * sizeof(int)); + table = objc_malloc(table_size * sizeof(int)); objectsToDoList = [[NSMutableArray alloc] init]; - k = [NSPointerFunctions pointerFunctionsWithOptions: - NSPointerFunctionsObjectPersonality]; - [k setIsEqualFunction: isEqualFunc]; - v = [NSPointerFunctions pointerFunctionsWithOptions: - NSPointerFunctionsIntegerPersonality|NSPointerFunctionsOpaqueMemory]; - objectList = [[NSMapTable alloc] initWithKeyPointerFunctions: k - valuePointerFunctions: v - capacity: 1000]; + objectList = [[NSMutableArray alloc] init]; [objectsToDoList addObject: root]; - [objectList setObject: (id)1 forKey: root]; + [objectList addObject: root]; } - (void) cleanup @@ -3335,7 +3382,7 @@ isEqualFunc(const void *item1, const void *item2, DESTROY(objectList); if (table != NULL) { - NSZoneFree(0, table); + objc_free(table); table = NULL; } } @@ -3357,15 +3404,14 @@ isEqualFunc(const void *item1, const void *item2, - (void) markOffset: (unsigned int) offset for: (id)object { - int oid; + unsigned int oid; - oid = (NSInteger)[objectList objectForKey: object]; - if (oid <= 0) + oid = [objectList indexOfObject: object]; + if (oid == NSNotFound) { [NSException raise: NSGenericException format: @"Unknown object %@.", object]; } - oid--; if (oid >= table_size) { [NSException raise: NSRangeException @@ -3413,7 +3459,7 @@ isEqualFunc(const void *item1, const void *item2, len = [objectList count]; size = offset_size * len; - buffer = NSZoneMalloc(0, size); + buffer = objc_malloc(size); if (offset_size == 1) { @@ -3463,7 +3509,7 @@ isEqualFunc(const void *item1, const void *item2, } [dest appendBytes: buffer length: size]; - NSZoneFree(0, buffer); + objc_free(buffer); } - (void) writeMetaData @@ -3485,7 +3531,6 @@ isEqualFunc(const void *item1, const void *item2, meta[13] = (len >> 16) % 256; meta[14] = (len >> 8) % 256; meta[15] = len % 256; - // root index is always 0, no need to write it meta[28] = (table_start >> 24); meta[29] = (table_start >> 16) % 256; meta[30] = (table_start >> 8) % 256; @@ -3494,22 +3539,22 @@ isEqualFunc(const void *item1, const void *item2, [dest appendBytes: meta length: 32]; } -- (NSInteger) indexForObject: (id)object +- (unsigned int) indexForObject: (id)object { - NSInteger index; + unsigned int index; - index = (NSInteger)[objectList objectForKey: object]; - if (index <= 0) + index = [objectList indexOfObject: object]; + if (index == NSNotFound) { index = [objectList count]; - [objectList setObject: (id)(++index) forKey: object]; + [objectList addObject: object]; [objectsToDoList addObject: object]; } - return index - 1; + return index; } -- (void) storeIndex: (NSInteger)index +- (void) storeIndex: (unsigned int)index { if (index_size == 1) { @@ -3651,7 +3696,7 @@ isEqualFunc(const void *item1, const void *item2, code = 0x6F; [dest appendBytes: &code length: 1]; - buffer = NSZoneMalloc(0, sizeof(unichar)*(len + 1)); + buffer = objc_malloc(sizeof(unichar)*(len + 1)); [self storeCount: len]; [string getCharacters: buffer]; for (i = 0; i < len; i++) @@ -3659,7 +3704,7 @@ isEqualFunc(const void *item1, const void *item2, buffer[i] = NSSwapHostShortToBig(buffer[i]); } [dest appendBytes: buffer length: sizeof(unichar)*len]; - NSZoneFree(0, buffer); + objc_free(buffer); } } } @@ -3795,7 +3840,7 @@ isEqualFunc(const void *item1, const void *item2, for (i = 0; i < len; i++) { id obj; - NSInteger oid; + unsigned int oid; obj = [array objectAtIndex: i]; oid = [self indexForObject: obj]; @@ -3863,7 +3908,7 @@ isEqualFunc(const void *item1, const void *item2, for (i = 0; i < len; i++) { id obj; - NSInteger oid; + unsigned int oid; obj = [keys objectAtIndex: i]; oid = [self indexForObject: obj]; @@ -3873,7 +3918,7 @@ isEqualFunc(const void *item1, const void *item2, for (i = 0; i < len; i++) { id obj; - NSInteger oid; + unsigned int oid; obj = [objects objectAtIndex: i]; oid = [self indexForObject: obj]; @@ -3886,27 +3931,27 @@ isEqualFunc(const void *item1, const void *item2, { [self markOffset: [dest length] for: object]; - if ([object isKindOfClass: NSStringClass]) + if ([object isKindOfClass: [NSString class]]) { [self storeString: object]; } - else if ([object isKindOfClass: NSDataClass]) + else if ([object isKindOfClass: [NSData class]]) { [self storeData: object]; } - else if ([object isKindOfClass: NSNumberClass]) + else if ([object isKindOfClass: [NSNumber class]]) { [self storeNumber: object]; } - else if ([object isKindOfClass: NSDateClass]) + else if ([object isKindOfClass: [NSDate class]]) { [self storeDate: object]; } - else if ([object isKindOfClass: NSArrayClass]) + else if ([object isKindOfClass: [NSArray class]]) { [self storeArray: object]; } - else if ([object isKindOfClass: NSDictionaryClass]) + else if ([object isKindOfClass: [NSDictionary class]]) { [self storeDictionary: object]; } diff --git a/Source/NSProtocolChecker.m b/Source/NSProtocolChecker.m index 8d3765831..64a39c011 100644 --- a/Source/NSProtocolChecker.m +++ b/Source/NSProtocolChecker.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,12 +27,12 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSProtocolChecker_IVARS 1 -#import "Foundation/NSProtocolChecker.h" -#import "Foundation/NSException.h" -#import "Foundation/NSInvocation.h" -#import "Foundation/NSMethodSignature.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSProtocolChecker.h" +#include "Foundation/NSException.h" +#include "Foundation/NSInvocation.h" +#include "Foundation/NSMethodSignature.h" #include /** @@ -74,10 +74,8 @@ - (struct objc_method_description*) _methodDescription: (SEL)aSelector { - extern struct objc_method_description - *GSDescriptionForInstanceMethod(Protocol *self, SEL aSel); - extern struct objc_method_description - *GSDescriptionForClassMethod(Protocol *self, SEL aSel); + extern struct objc_method_description *GSDescriptionForInstanceMethod(); + extern struct objc_method_description *GSDescriptionForClassMethod(); if (_myProtocol != nil && _myTarget != nil) { @@ -91,7 +89,7 @@ */ if (GSObjCIsInstance(_myTarget)) { - if ((uintptr_t)object_getClass(_myProtocol) == 0x2) + if ((uintptr_t)GSObjCClass(_myProtocol) == 0x2) { mth = GSDescriptionForInstanceMethod(_myProtocol, aSelector); } @@ -102,7 +100,7 @@ } else { - if ((uintptr_t)object_getClass(_myProtocol) == 0x2) + if ((uintptr_t)GSObjCClass(_myProtocol) == 0x2) { mth = GSDescriptionForClassMethod(_myProtocol, aSelector); } @@ -198,14 +196,14 @@ * signature of methodSignatureForSelector:, so we hack in * the signature required manually :-( */ - if (sel_isEqual(aSelector, _cmd)) + if (sel_eq(aSelector, _cmd)) { static NSMethodSignature *sig = nil; if (sig == nil) { sig = [NSMethodSignature signatureWithObjCTypes: "@@::"]; - IF_NO_GC(RETAIN(sig);) + RETAIN(sig); } return sig; } @@ -227,7 +225,7 @@ return [NSMethodSignature signatureWithObjCTypes: types]; } - c = object_getClass(self); + c = GSObjCClass(self); mth = GSGetMethod(c, aSelector, YES, YES); if (mth == 0) { diff --git a/Source/NSProxy.m b/Source/NSProxy.m index 307071c37..872feb1e9 100644 --- a/Source/NSProxy.m +++ b/Source/NSProxy.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,14 +25,21 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSInvocation.h" -#import "Foundation/NSProxy.h" -#import "Foundation/NSMethodSignature.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSException.h" -#import "Foundation/NSDistantObject.h" -#import "Foundation/NSPortCoder.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSInvocation.h" +#include "Foundation/NSProxy.h" +#include "Foundation/NSMethodSignature.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSException.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSDistantObject.h" +#include "Foundation/NSPortCoder.h" + +#ifdef HAVE_LIMITS_H +/* For UINT_MAX */ +#include +#endif @class NSDistantObject; @@ -137,7 +144,7 @@ extern BOOL __objc_responds_to(id, SEL); [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - return get_imp(object_getClass((id)self), aSelector); + return get_imp(GSObjCClass((id)self), aSelector); } /** @@ -194,7 +201,7 @@ extern BOOL __objc_responds_to(id, SEL); /** * Returns the maximum unsigned integer value. */ -+ (NSUInteger) retainCount ++ (unsigned int) retainCount { return UINT_MAX; } @@ -204,7 +211,7 @@ extern BOOL __objc_responds_to(id, SEL); */ + (Class) superclass { - return class_getSuperclass(self); + return GSObjCSuper(self); } /** @@ -268,7 +275,7 @@ extern BOOL __objc_responds_to(id, SEL); - (NSString*) description { return [NSString stringWithFormat: @"<%s %lx>", - GSClassNameFromObject(self), (size_t)self]; + GSClassNameFromObject(self), (unsigned long)self]; } /** @@ -291,13 +298,13 @@ extern BOOL __objc_responds_to(id, SEL); { [NSException raise: NSInvalidArgumentException format: @"NSProxy should not implement '%s'", - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; } /** * Returns the address of the receiver ... so it can be stored in a dictionary. */ -- (NSUInteger) hash +- (unsigned int) hash { /* * Ideally we would shift left to lose any zero bits produced by the @@ -306,7 +313,7 @@ extern BOOL __objc_responds_to(id, SEL); * In the absence of detailed information, pick a reasonable value * assuming the object will be aligned to an eight byte boundary. */ - return ((NSUInteger)(uintptr_t)self)>>3; + return ((unsigned)(uintptr_t)self)>>3; } /** @@ -316,7 +323,7 @@ extern BOOL __objc_responds_to(id, SEL); { [NSException raise: NSGenericException format: @"subclass %s should override %s", GSClassNameFromObject(self), - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; return self; } @@ -381,7 +388,7 @@ extern BOOL __objc_responds_to(id, SEL); - (id) notImplemented: (SEL)aSel { [NSException raise: NSGenericException - format: @"NSProxy notImplemented %s", sel_getName(aSel)]; + format: @"NSProxy notImplemented %s", GSNameFromSelector(aSel)]; return self; } @@ -397,7 +404,7 @@ extern BOOL __objc_responds_to(id, SEL); { return nil; } - mth = GSGetMethod(object_getClass(self), aSelector, YES, YES); + mth = GSGetMethod(GSObjCClass(self), aSelector, YES, YES); if (mth != 0) { const char *types = mth->method_types; @@ -420,7 +427,7 @@ extern BOOL __objc_responds_to(id, SEL); { [NSException raise: NSGenericException format: @"invalid selector passed to %s", - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; return nil; } return (*msg)(self, aSelector); @@ -435,7 +442,7 @@ extern BOOL __objc_responds_to(id, SEL); { [NSException raise: NSGenericException format: @"invalid selector passed to %s", - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; return nil; } return (*msg)(self, aSelector, anObject); @@ -451,7 +458,7 @@ extern BOOL __objc_responds_to(id, SEL); { [NSException raise: NSGenericException format: @"invalid selector passed to %s", - sel_getName(_cmd)]; + GSNameFromSelector(_cmd)]; return nil; } return (*msg)(self, aSelector, anObject, anotherObject); @@ -491,7 +498,7 @@ extern BOOL __objc_responds_to(id, SEL); * use get_imp() because NSDistantObject doesn't implement * methodForSelector: */ - proxyImp = get_imp(object_getClass((id)proxyClass), + proxyImp = get_imp(GSObjCClass((id)proxyClass), @selector(proxyWithLocal:connection:)); } @@ -543,7 +550,7 @@ extern BOOL __objc_responds_to(id, SEL); /** * Return the retain count for the receiver. */ -- (NSUInteger) retainCount +- (unsigned int) retainCount { return _retain_count + 1; } diff --git a/Source/NSRange.m b/Source/NSRange.m index 568092088..390b42aa9 100644 --- a/Source/NSRange.m +++ b/Source/NSRange.m @@ -7,7 +7,7 @@ * This file is part of the GNUstep Base Library. * * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public + * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * @@ -16,7 +16,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public + * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02111 USA. @@ -25,12 +25,13 @@ $Date$ $Revision$ */ -#import "common.h" +#include "config.h" #define IN_NSRANGE_M 1 -#import "Foundation/NSException.h" -#import "Foundation/NSRange.h" -#import "Foundation/NSScanner.h" +#include "Foundation/NSException.h" +#include "Foundation/NSString.h" +#include "Foundation/NSRange.h" +#include "Foundation/NSScanner.h" @class NSString; diff --git a/Source/NSRegularExpression.m b/Source/NSRegularExpression.m new file mode 100644 index 000000000..521d0ac55 --- /dev/null +++ b/Source/NSRegularExpression.m @@ -0,0 +1,624 @@ +/** Implementation of NSRegualrExpression for GNUStep + + Copyright (C) 2010 Free Software Foundation, Inc. + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + + $Date: 2010-09-18 16:09:58 +0100 (Sat, 18 Sep 2010) $ $Revision: 31371 $ + */ + +#import "common.h" + +#if GS_USE_ICU == 1 +#include "unicode/uregex.h" +#if (U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM >= 4)) + +#define GSREGEXTYPE URegularExpression +#import "GSICUString.h" +#import "Foundation/NSRegularExpression.h" +#import "Foundation/NSTextCheckingResult.h" +#import "Foundation/NSArray.h" +#import "Foundation/NSCoder.h" + + +/** + * To be helpful, Apple decided to define a set of flags that mean exactly the + * same thing as the URegexpFlags enum in libicu, but have different values. + * This was completely stupid, but we probably have to live with it. We could + * in theory use the libicu values directly (that would be sensible), but that + * would break any code that didn't correctly use the symbolic constants. + */ +uint32_t +NSRegularExpressionOptionsToURegexpFlags(NSRegularExpressionOptions opts) +{ + uint32_t flags = 0; + + if (opts & NSRegularExpressionCaseInsensitive) + { + flags |= UREGEX_CASE_INSENSITIVE; + } + if (opts & NSRegularExpressionAllowCommentsAndWhitespace) + { + flags |= UREGEX_COMMENTS; + } + if (opts & NSRegularExpressionIgnoreMetacharacters) + { + flags |= UREGEX_LITERAL; + } + if (opts & NSRegularExpressionDotMatchesLineSeparators) + { + flags |= UREGEX_DOTALL; + } + if (opts & NSRegularExpressionAnchorsMatchLines) + { + flags |= UREGEX_MULTILINE; + } + if (opts & NSRegularExpressionUseUnixLineSeparators) + { + flags |= UREGEX_UNIX_LINES; + } + if (opts & NSRegularExpressionUseUnicodeWordBoundaries) + { + flags |= UREGEX_UWORD; + } + return flags; +} + +@implementation NSRegularExpression + ++ (NSRegularExpression*) regularExpressionWithPattern: (NSString*)aPattern + options: (NSRegularExpressionOptions)opts + error: (NSError**)e +{ + return [[[self alloc] initWithPattern: aPattern + options: opts + error: e] autorelease]; +} + +- (id) initWithPattern: (NSString*)aPattern + options: (NSRegularExpressionOptions)opts + error: (NSError**)e +{ + uint32_t flags = NSRegularExpressionOptionsToURegexpFlags(opts); + UText p = UTEXT_INITIALIZER; + UParseError pe = {0}; + UErrorCode s = 0; + + UTextInitWithNSString(&p, aPattern); + regex = uregex_openUText(&p, flags, &pe, &s); + utext_close(&p); + if (U_FAILURE(s)) + { + // FIXME: Do something sensible with the error parameter. + [self release]; + return nil; + } + options = opts; + return self; +} + +- (NSString*) pattern +{ + UErrorCode s = 0; + UText *t = uregex_patternUText(regex, &s); + GSUTextString *str = NULL; + + if (U_FAILURE(s)) + { + return nil; + } + str = [GSUTextString new]; + utext_clone(&str->txt, t, FALSE, TRUE, &s); + utext_close(t); + return [str autorelease]; +} + +static UBool +callback(const void *context, int32_t steps) +{ + BOOL stop = NO; + GSRegexBlock block = (GSRegexBlock)context; + + if (NULL == context) + { + return FALSE; + } + CALL_BLOCK(block, nil, NSMatchingProgress, &stop); + return stop; +} + +/** + * Sets up a libicu regex object for use. Note: the documentation states that + * NSRegularExpression must be thread safe. To accomplish this, we store a + * prototype URegularExpression in the object, and then clone it in each + * method. This is required because URegularExpression, unlike + * NSRegularExpression, is stateful, and sharing this state between threads + * would break concurrent calls. + */ +static URegularExpression * +setupRegex(URegularExpression *regex, + NSString *string, + UText *txt, + NSMatchingOptions options, + NSRange range, + GSRegexBlock block) +{ + UErrorCode s = 0; + URegularExpression *r = uregex_clone(regex, &s); + + if (options & NSMatchingReportProgress) + { + uregex_setMatchCallback(r, callback, block, &s); + } + UTextInitWithNSString(txt, string); + uregex_setUText(r, txt, &s); + uregex_setRegion(r, range.location, range.location+range.length, &s); + if (options & NSMatchingWithoutAnchoringBounds) + { + uregex_useAnchoringBounds(r, FALSE, &s); + } + if (options & NSMatchingWithTransparentBounds) + { + uregex_useTransparentBounds(r, TRUE, &s); + } + if (U_FAILURE(s)) + { + uregex_close(r); + return NULL; + } + return r; +} + +static uint32_t +prepareResult(NSRegularExpression *regex, + URegularExpression *r, + NSRangePointer ranges, + NSUInteger groups, + UErrorCode *s) +{ + uint32_t flags = 0; + NSUInteger i = 0; + + for (i = 0; i < groups; i++) + { + NSUInteger start = uregex_start(r, i, s); + NSUInteger end = uregex_end(r, i, s); + + ranges[i] = NSMakeRange(start, end-start); + } + if (uregex_hitEnd(r, s)) + { + flags |= NSMatchingHitEnd; + } + if (uregex_requireEnd(r, s)) + { + flags |= NSMatchingRequiredEnd; + } + if (0 != *s) + { + flags |= NSMatchingInternalError; + } + return flags; +} + +- (void) enumerateMatchesInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range + usingBlock: (GSRegexBlock)block +{ + UErrorCode s = 0; + UText txt = UTEXT_INITIALIZER; + BOOL stop = NO; + URegularExpression *r = setupRegex(regex, string, &txt, opts, range, block); + NSUInteger groups = [self numberOfCaptureGroups] + 1; + NSRange ranges[groups]; + + // Should this throw some kind of exception? + if (NULL == r) + { + return; + } + if (opts & NSMatchingAnchored) + { + if (uregex_lookingAt(r, -1, &s) && (0 == s)) + { + // FIXME: Factor all of this out into prepareResult() + uint32_t flags; + NSTextCheckingResult *result; + + flags = prepareResult(self, r, ranges, groups, &s); + result = [NSTextCheckingResult + regularExpressionCheckingResultWithRanges: ranges + count: groups + regularExpression: self]; + CALL_BLOCK(block, result, flags, &stop); + } + } + else + { + while (!stop && uregex_findNext(r, &s) && (0 == s)) + { + uint32_t flags; + NSTextCheckingResult *result; + + flags = prepareResult(self, r, ranges, groups, &s); + result = [NSTextCheckingResult + regularExpressionCheckingResultWithRanges: ranges + count: groups + regularExpression: self]; + CALL_BLOCK(block, result, flags, &stop); + } + } + if (opts & NSMatchingCompleted) + { + CALL_BLOCK(block, nil, NSMatchingCompleted, &stop); + } + utext_close(&txt); + uregex_close(r); +} + +/* The remaining methods are all meant to be wrappers around the primitive + * method that takes a block argument. Unfortunately, this is not really + * possible when compiling with a compiler that doesn't support blocks. + */ +#if __has_feature(blocks) +- (NSUInteger) numberOfMatchesInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range + +{ + __block NSUInteger count = 0; + + opts &= ~NSMatchingReportProgress; + opts &= ~NSMatchingReportCompletion; + + GSRegexBlock block = + ^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) + { + count++; + }; + [self enumerateMatchesInString: string + options: opts + range: range + usingBlock: block]; + return count; +} + +- (NSTextCheckingResult*) firstMatchInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range +{ + __block NSTextCheckingResult *r = nil; + + opts &= ~NSMatchingReportProgress; + opts &= ~NSMatchingReportCompletion; + + GSRegexBlock block = + ^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) + { + r = result; + *stop = YES; + }; + [self enumerateMatchesInString: string + options: opts + range: range + usingBlock: block]; + return r; +} + +- (NSArray*) matchesInString: (NSString*)string + options:(NSMatchingOptions)opts + range:(NSRange)range +{ + NSMutableArray *array = [NSMutableArray array]; + + opts &= ~NSMatchingReportProgress; + opts &= ~NSMatchingReportCompletion; + + GSRegexBlock block = + ^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) + { + [array addObject: result]; + }; + [self enumerateMatchesInString: string + options: opts + range: range + usingBlock: block]; + return array; +} + +- (NSRange) rangeOfFirstMatchInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range +{ + __block NSRange r; + + opts &= ~NSMatchingReportProgress; + opts &= ~NSMatchingReportCompletion; + + GSRegexBlock block = + ^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) + { + r = [result range]; + *stop = YES; + }; + [self enumerateMatchesInString: string + options: opts + range: range + usingBlock: block]; + return r; +} + +#else +# warning Your compiler does not support blocks. NSRegularExpression will deviate from the documented behaviour when subclassing and any code that subclasses NSRegularExpression may break in unexpected ways. It is strongly recommended that you use a compiler with blocks support. +# ifdef __clang__ +# warning Your compiler would support blocks if you added -fblocks to your OBJCFLAGS +# endif +#define FAKE_BLOCK_HACK(failRet, code) \ + UErrorCode s = 0;\ + UText txt = UTEXT_INITIALIZER;\ + BOOL stop = NO;\ + URegularExpression *r = setupRegex(regex, string, &txt, opts, range, 0);\ + if (NULL == r) { return failRet; }\ + if (opts & NSMatchingAnchored)\ + {\ + if (uregex_lookingAt(r, -1, &s) && (0==s))\ + {\ + code\ + }\ + }\ + else\ + {\ + while (!stop && uregex_findNext(r, &s) && (s == 0))\ + {\ + code\ + }\ + }\ + utext_close(&txt);\ + uregex_close(r); + +- (NSUInteger) numberOfMatchesInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range + +{ + NSUInteger count = 0; + + FAKE_BLOCK_HACK(count, + { + count++; + }); + return count; +} + +- (NSTextCheckingResult*) firstMatchInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range +{ + NSTextCheckingResult *result = nil; + NSUInteger groups = [self numberOfCaptureGroups] + 1; + NSRange ranges[groups]; + + FAKE_BLOCK_HACK(result, + { + prepareResult(self, r, ranges, groups, &s); + result = [NSTextCheckingResult + regularExpressionCheckingResultWithRanges: ranges + count: groups + regularExpression: self]; + stop = YES; + }); + return result; +} + +- (NSArray*) matchesInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range +{ + NSMutableArray *array = [NSMutableArray array]; + NSUInteger groups = [self numberOfCaptureGroups] + 1; + NSRange ranges[groups]; + + FAKE_BLOCK_HACK(array, + { + NSTextCheckingResult *result = NULL; + + prepareResult(self, r, ranges, groups, &s); + result = [NSTextCheckingResult + regularExpressionCheckingResultWithRanges: ranges + count: groups + regularExpression: self]; + [array addObject: result]; + }); + return array; +} + +- (NSRange) rangeOfFirstMatchInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range +{ + NSRange result = {0,0}; + + FAKE_BLOCK_HACK(result, + { + prepareResult(self, r, &result, 1, &s); + stop = YES; + }); + return result; +} + +#endif + +- (NSUInteger) replaceMatchesInString: (NSMutableString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range + withTemplate: (NSString*)template +{ + // FIXME: We're computing a value that is most likely ignored in an + // expensive way. + NSInteger results = [self numberOfMatchesInString: string + options: opts + range: range]; + UErrorCode s = 0; + UText txt = UTEXT_INITIALIZER; + UText replacement = UTEXT_INITIALIZER; + GSUTextString *ret = [GSUTextString new]; + URegularExpression *r = setupRegex(regex, string, &txt, opts, range, 0); + UText *output = NULL; + + UTextInitWithNSString(&replacement, template); + + output = uregex_replaceAllUText(r, &replacement, NULL, &s); + utext_clone(&ret->txt, output, TRUE, TRUE, &s); + [string setString: ret]; + [ret release]; + uregex_close(r); + + utext_close(&txt); + utext_close(output); + utext_close(&replacement); + return results; +} + +- (NSString*) stringByReplacingMatchesInString: (NSString*)string + options: (NSMatchingOptions)opts + range: (NSRange)range + withTemplate: (NSString*)template +{ + UErrorCode s = 0; + UText txt = UTEXT_INITIALIZER; + UText replacement = UTEXT_INITIALIZER; + UText *output = NULL; + GSUTextString *ret = [GSUTextString new]; + URegularExpression *r = setupRegex(regex, string, &txt, opts, range, 0); + + UTextInitWithNSString(&replacement, template); + + output = uregex_replaceAllUText(r, &replacement, NULL, &s); + utext_clone(&ret->txt, output, TRUE, TRUE, &s); + uregex_close(r); + + utext_close(&txt); + utext_close(output); + utext_close(&replacement); + return ret; +} + +- (NSString*) replacementStringForResult: (NSTextCheckingResult*)result + inString: (NSString*)string + offset: (NSInteger)offset + template: (NSString*)template +{ + UErrorCode s = 0; + UText txt = UTEXT_INITIALIZER; + UText replacement = UTEXT_INITIALIZER; + UText *output = NULL; + GSUTextString *ret = [GSUTextString new]; + NSRange range = [result range]; + URegularExpression *r = setupRegex(regex, + [string substringWithRange: range], + &txt, + 0, + NSMakeRange(0, range.length), + 0); + + UTextInitWithNSString(&replacement, template); + + output = uregex_replaceFirstUText(r, &replacement, NULL, &s); + utext_clone(&ret->txt, output, TRUE, TRUE, &s); + uregex_close(r); + + utext_close(&txt); + utext_close(output); + utext_close(&replacement); + return ret; +} + +- (NSRegularExpressionOptions) options +{ + return options; +} + +- (NSUInteger) numberOfCaptureGroups +{ + UErrorCode s = 0; + return uregex_groupCount(regex, &s); +} + +- (void) dealloc +{ + uregex_close(regex); + [super dealloc]; +} + +- (void) encodeWithCoder: (NSCoder*)aCoder +{ + if ([aCoder allowsKeyedCoding]) + { + [aCoder encodeInteger: options forKey: @"options"]; + [aCoder encodeObject: [self pattern] forKey: @"pattern"]; + } + else + { + [aCoder encodeValueOfObjCType: @encode(NSRegularExpressionOptions) + at: &options]; + [aCoder encodeObject: [self pattern]]; + } +} + +- (id) initWithCoder: (NSCoder*)aCoder +{ + NSString *pattern; + + if ([aCoder allowsKeyedCoding]) + { + options = [aCoder decodeIntegerForKey: @"options"]; + pattern = [aCoder decodeObjectForKey: @"pattern"]; + } + else + { + [aCoder decodeValueOfObjCType: @encode(NSRegularExpressionOptions) + at: &options]; + pattern = [aCoder decodeObject]; + } + return [self initWithPattern: pattern options: options error: NULL]; +} + +- (id) copyWithZone: (NSZone*)aZone +{ + NSRegularExpressionOptions opts = options; + UErrorCode s = 0; + URegularExpression *r = uregex_clone(regex, &s); + + if (0 != s) + { + return nil; + } + + self = [[self class] allocWithZone: aZone]; + if (nil == self) + { + return nil; + } + options = opts; + regex = r; + return self; +} +@end +#endif //U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM >= 4)) +#endif //HAV_ICU diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 40d23900d..8ececc78e 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -11,7 +11,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -20,7 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -29,26 +29,25 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSRunLoop_IVARS 1 -#define EXPOSE_NSTimer_IVARS 1 -#import "Foundation/NSMapTable.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSTimer.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSStream.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSInvocation.h" -#import "GSRunLoopCtxt.h" -#import "GSRunLoopWatcher.h" -#import "GSStream.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSPort.h" +#include "Foundation/NSTimer.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSStream.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSDebug.h" +#include "GSRunLoopCtxt.h" +#include "GSRunLoopWatcher.h" +#include "GSStream.h" -#import "GSPrivate.h" +#include "GSPrivate.h" #ifdef HAVE_SYS_TYPES_H #include @@ -62,8 +61,8 @@ #ifdef HAVE_UNISTD_H #include #endif -#include #include +#include #include /* for memset() */ @@ -72,7 +71,7 @@ NSString * const NSDefaultRunLoopMode = @"NSDefaultRunLoopMode"; static NSDate *theFuture = nil; @interface NSObject (OptionalPortRunLoop) -- (void) getFds: (NSInteger*)fds count: (NSInteger*)count; +- (void) getFds: (int*)fds count: (int*)count; @end @@ -95,7 +94,7 @@ static NSDate *theFuture = nil; - (id) initWithSelector: (SEL)aSelector target: (id)target argument: (id)argument - order: (NSUInteger)order; + order: (unsigned int)order; @end @implementation GSRunLoopPerformer @@ -115,7 +114,7 @@ static NSDate *theFuture = nil; - (id) initWithSelector: (SEL)aSelector target: (id)aTarget argument: (id)anArgument - order: (NSUInteger)theOrder + order: (unsigned int)theOrder { self = [super init]; if (self) @@ -147,7 +146,7 @@ static NSDate *theFuture = nil; * The GSTimedPerformer class is used to hold information about * messages which are due to be sent to objects at a particular time. */ -@interface GSTimedPerformer: NSObject +@interface GSTimedPerformer: NSObject { @public SEL selector; @@ -168,7 +167,7 @@ static NSDate *theFuture = nil; - (void) dealloc { - [self finalize]; + [self gcFinalize]; TEST_RELEASE(timer); RELEASE(target); RELEASE(argument); @@ -183,7 +182,7 @@ static NSDate *theFuture = nil; removeObjectIdenticalTo: self]; } -- (void) finalize +- (void) gcFinalize { [self invalidate]; } @@ -241,13 +240,22 @@ static NSDate *theFuture = nil; #include "GNUstepBase/GSIArray.h" #endif +typedef struct { + @defs(NSTimer) +} *tvars; + static inline NSDate *timerDate(NSTimer *t) { - return t->_date; + return ((tvars)t)->_date; } static inline BOOL timerInvalidated(NSTimer *t) { - return t->_invalidated; + return ((tvars)t)->_invalidated; +} + +static NSComparisonResult tSort(GSIArrayItem i0, GSIArrayItem i1) +{ + return [timerDate(i0.obj) compare: timerDate(i1.obj)]; } @@ -308,7 +316,7 @@ static inline BOOL timerInvalidated(NSTimer *t) { GSTimedPerformer *p = array[count]; - if (p->target == target && sel_isEqual(p->selector, aSelector) + if (p->target == target && sel_eq(p->selector, aSelector) && (p->argument == arg || [p->argument isEqual: arg])) { [p invalidate]; @@ -356,17 +364,7 @@ static inline BOOL timerInvalidated(NSTimer *t) delay: seconds]; [[loop _timedPerformers] addObject: item]; RELEASE(item); - if ([modes isProxy]) - { - for (i = 0; i < count; i++) - { - marray[i] = [modes objectAtIndex: i]; - } - } - else - { - [modes getObjects: marray]; - } + [modes getObjects: marray]; for (i = 0; i < count; i++) { [loop addTimer: item->timer forMode: marray[i]]; @@ -386,7 +384,6 @@ static inline BOOL timerInvalidated(NSTimer *t) - (GSRunLoopWatcher*) _getWatcher: (void*)data type: (RunLoopEventType)type forMode: (NSString*)mode; -- (id) _init; - (void) _removeWatcher: (void*)data type: (RunLoopEventType)type forMode: (NSString*)mode; @@ -401,7 +398,6 @@ static inline BOOL timerInvalidated(NSTimer *t) { GSRunLoopCtxt *context; GSIArray watchers; - unsigned i; context = NSMapGet(_contextMap, mode); if (context == nil) @@ -412,13 +408,6 @@ static inline BOOL timerInvalidated(NSTimer *t) } watchers = context->watchers; GSIArrayAddItem(watchers, (GSIArrayItem)((id)item)); - i = GSIArrayCount(watchers); - if (i % 1000 == 0 && i > context->maxWatchers) - { - context->maxWatchers = i; - NSLog(@"WARNING ... there are %u watchers scheduled in mode %@ of %@", - i, mode, self); - } } - (void) _checkPerformers: (GSRunLoopCtxt*)context @@ -528,27 +517,6 @@ static inline BOOL timerInvalidated(NSTimer *t) return nil; } -- (id) _init -{ - self = [super init]; - if (self != nil) - { - _contextStack = [NSMutableArray new]; - _contextMap = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks, - NSObjectMapValueCallBacks, 0); - _timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8]; -#ifdef HAVE_POLL_F -#if GS_WITH_GC - _extra = NSAllocateCollectable(sizeof(pollextra), NSScannedOption); -#else - _extra = NSZoneMalloc(NSDefaultMallocZone(), sizeof(pollextra)); - memset(_extra, '\0', sizeof(pollextra)); -#endif -#endif - } - return self; -} - /** * Removes a runloop watcher matching the specified data and type in this * runloop. If the mode is nil, either the currentMode is used (if the @@ -678,9 +646,8 @@ static inline BOOL timerInvalidated(NSTimer *t) * [NSTimer]s, and sending notifications and other messages * asynchronously.

* - *

There is one run loop per thread in an application, which - * may always be obtained through the +currentRunLoop method - * (you cannot use -init or +new), + *

In general, there is one run loop per thread in an application, which + * may always be obtained through the +currentRunLoop method, * however unless you are using the AppKit and the [NSApplication] class, the * run loop will not be started unless you explicitly send it a * -run message.

@@ -705,78 +672,45 @@ static inline BOOL timerInvalidated(NSTimer *t) */ + (NSRunLoop*) currentRunLoop { - GSRunLoopThreadInfo *info = GSRunLoopInfoForThread(nil); - NSRunLoop *current = info->loop; + extern NSRunLoop *GSRunLoopForThread(); - if (current == nil) - { - current = info->loop = [[self alloc] _init]; - /* If this is the main thread, set up a housekeeping timer. - */ - if ([GSCurrentThread() isMainThread] == YES) - { - CREATE_AUTORELEASE_POOL (arp); - GSRunLoopCtxt *context; - NSNotificationCenter *ctr; - NSNotification *not; - NSInvocation *inv; - NSTimer *timer; - SEL sel; - - ctr = [NSNotificationCenter defaultCenter]; - not = [NSNotification notificationWithName: @"GSHousekeeping" - object: nil - userInfo: nil]; - sel = @selector(postNotification:); - inv = [NSInvocation invocationWithMethodSignature: - [ctr methodSignatureForSelector: sel]]; - [inv setTarget: ctr]; - [inv setSelector: sel]; - [inv setArgument: ¬ atIndex: 2]; - [inv retainArguments]; - - context = NSMapGet(current->_contextMap, NSDefaultRunLoopMode); - if (context == nil) - { - context = [GSRunLoopCtxt alloc]; - context = [context initWithMode: NSDefaultRunLoopMode - extra: current->_extra]; - NSMapInsert(current->_contextMap, context->mode, context); - RELEASE(context); - } - if (context->housekeeper != nil) - { - [context->housekeeper invalidate]; - DESTROY(context->housekeeper); - } - timer = [[NSTimer alloc] initWithFireDate: nil - interval: 30.0 - target: inv - selector: NULL - userInfo: nil - repeats: YES]; - context->housekeeper = timer; - RELEASE(arp); - } - } - return current; + return GSRunLoopForThread(nil); } +/* This is the designated initializer. */ - (id) init { - DESTROY(self); - return nil; + self = [super init]; + if (self != nil) + { + _contextStack = [NSMutableArray new]; + _contextMap = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks, + NSObjectMapValueCallBacks, 0); + _timedPerformers = [[NSMutableArray alloc] initWithCapacity: 8]; +#ifdef HAVE_POLL_F + _extra = objc_malloc(sizeof(pollextra)); + memset(_extra, '\0', sizeof(pollextra)); +#endif + } + return self; } - (void) dealloc +{ + [self gcFinalize]; + [super dealloc]; +} + +- (void) gcFinalize { #ifdef HAVE_POLL_F if (_extra != 0) { pollextra *e = (pollextra*)_extra; + if (e->index != 0) - NSZoneFree(NSDefaultMallocZone(), e->index); - NSZoneFree(NSDefaultMallocZone(), e); + objc_free(e->index); + objc_free(e); } #endif RELEASE(_contextStack); @@ -785,7 +719,6 @@ static inline BOOL timerInvalidated(NSTimer *t) NSFreeMapTable(_contextMap); } RELEASE(_timedPerformers); - [super dealloc]; } /** @@ -807,24 +740,6 @@ static inline BOOL timerInvalidated(NSTimer *t) { GSRunLoopCtxt *context; GSIArray timers; - unsigned i; - - if ([timer isKindOfClass: [NSTimer class]] == NO - || [timer isProxy] == YES) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] not a valid timer", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - if ([mode isKindOfClass: [NSString class]] == NO) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@-%@] not a valid mode", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } - - NSDebugMLLog(@"NSRunLoop", @"add timer for %f in %@", - [[timer fireDate] timeIntervalSinceReferenceDate], mode); context = NSMapGet(_contextMap, mode); if (context == nil) @@ -834,104 +749,14 @@ static inline BOOL timerInvalidated(NSTimer *t) RELEASE(context); } timers = context->timers; - i = GSIArrayCount(timers); - while (i-- > 0) - { - if (timer == GSIArrayItemAtIndex(timers, i).obj) - { - return; /* Timer already present */ - } - } - /* - * NB. A previous version of the timer code maintained an ordered - * array on the theory that we could improve performance by only - * checking the first few timers (up to the first one whose fire - * date is in the future) each time -limitDateForMode: is called. - * The problem with this was that it's possible for one timer to - * be added in multiple modes (or to different run loops) and for - * a repeated timer this could mean that the firing of the timer - * in one mode/loop adjusts its date ... without changing the - * ordering of the timers in the other modes/loops which contain - * the timer. When the ordering of timers in an array was broken - * we could get delays in processing timeouts, so we reverted to - * simply having timers in an unordered array and checking them - * all each time -limitDateForMode: is called. - */ - GSIArrayAddItem(timers, (GSIArrayItem)((id)timer)); - i = GSIArrayCount(timers); - if (i % 1000 == 0 && i > context->maxTimers) - { - context->maxTimers = i; - NSLog(@"WARNING ... there are %u timers scheduled in mode %@ of %@", - i, mode, self); - } + GSIArrayInsertSorted(timers, (GSIArrayItem)((id)timer), tSort); } - -/* Ensure that the fire date has been updated either by the timeout handler - * updating it or by incrementing it ourselves.
- * Return YES if it was updated, NO if it was invalidated. - */ -static BOOL -updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) -{ - if (timerInvalidated(t) == YES) - { - return NO; - } - if (timerDate(t) == d) - { - NSTimeInterval ti = [d timeIntervalSinceReferenceDate]; - NSTimeInterval increment = [t timeInterval]; - - if (increment <= 0.0) - { - /* Should never get here ... unless a subclass is returning - * a bad interval ... we return NO so that the timer gets - * removed from the loop. - */ - NSLog(@"WARNING timer %@ had bad interval ... removed", t); - return NO; - } - - ti += increment; // Hopefully a single increment will do. - - if (ti < now) - { - NSTimeInterval add; - - /* Just incrementing the date was insufficieint to bring it to - * the current time, so we must have missed one or more fire - * opportunities, or the fire date has been set on the timer. - * If a fire date long ago has been set and the increment value - * is really small, we might need to increment very many times - * to get the new fire date. To avoid looping for ages, we - * calculate the number of increments needed and do them in one - * go. - */ - add = floor((now - ti) / increment); - ti += (increment * add); - if (ti < now) - { - add++; - ti += increment; - } - } - d = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate: ti]; - [t setFireDate: d]; - RELEASE(d); - } - return YES; -} - /** * Fires timers whose fire date has passed, and checks timers and limit dates * for input sources, determining the earliest time that any future timeout - * becomes due. Returns that date/time.
- * Returns distant future if the loop contains no timers, just input sources - * without timeouts.
- * Returns nil if the loop contains neither timers nor input sources. + * becomes due. Returns that date/time. */ - (NSDate*) limitDateForMode: (NSString*)mode { @@ -950,117 +775,64 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) extern NSTimeInterval GSTimeNow(void); GSIArray timers = context->timers; NSTimeInterval now; - NSDate *earliest; - NSDate *d; NSTimer *t; - NSTimeInterval ti; - NSTimeInterval ei; - unsigned c; - unsigned i; - - ei = 0.0; // Only needed to avoid compiler warning /* * Save current time so we don't keep redoing system call to - * get it and so that we check timer fire dates against a known - * value at the point when the method was called. - * If we refetched the date after firing each timer, the time - * taken in firing the timer could be large enough so we would - * just keep firing the timer repeatedly and never return from - * this method. + * get it. We must refetch the time after every operation + * (such as a timer firing) which might cause a significant + * delay making the saved value outdated. */ now = GSTimeNow(); - /* Fire housekeeping timer as necessary + /* + * Fire housekeeping timer as necessary */ - if ((t = context->housekeeper) != nil) - { - if (timerInvalidated(t)) - { - DESTROY(context->housekeeper); - } - else if ([(d=timerDate(t)) timeIntervalSinceReferenceDate] <= now) - { - [t fire]; - GSPrivateNotifyASAP(_currentMode); - IF_NO_GC([arp emptyPool]); - updateTimer(t, d, now); - } - } - - /* Fire the oldest/first valid timer whose fire date has passed - * and fire it. - * We fire timers in the order in which they were added to the - * run loop rather than in date order. This prevents code - * from blocking other timers by adding timers whose fire date - * is some time in the past... we guarantee fair handling. - */ - c = GSIArrayCount(timers); - for (i = 0; i < c; i++) + while ((t = context->housekeeper) != nil + && ([timerDate(t) timeIntervalSinceReferenceDate] <= now)) { - t = GSIArrayItemAtIndex(timers, i).obj; - if (timerInvalidated(t) == NO) - { - d = timerDate(t); - ti = [d timeIntervalSinceReferenceDate]; - if (ti < now) - { - GSIArrayRemoveItemAtIndexNoRelease(timers, i); - [t fire]; - GSPrivateNotifyASAP(_currentMode); - IF_NO_GC([arp emptyPool]); - if (updateTimer(t, d, now) == YES) - { - /* Updated ... replace in array. - */ - GSIArrayAddItemNoRetain(timers, - (GSIArrayItem)((id)t)); - } - else - { - /* The timer was invalidated, so we can - * release it as we aren't putting it back - * in the array. - */ - RELEASE(t); - } - break; - } - } + [t fire]; + IF_NO_GC([arp emptyPool]); + now = GSTimeNow(); } - /* Now, find the earliest remaining timer date while removing - * any invalidated timers. We iterate from the end of the - * array to minimise the amount of array alteration needed. + /* + * Handle normal timers ... remove invalidated timers and fire any + * whose date has passed. */ - earliest = nil; - i = GSIArrayCount(timers); - while (i-- > 0) + while (GSIArrayCount(timers) != 0) { - t = GSIArrayItemAtIndex(timers, i).obj; - if (timerInvalidated(t) == YES) + NSTimer *min_timer = GSIArrayItemAtIndex(timers, 0).obj; + + if (timerInvalidated(min_timer) == YES) { - GSIArrayRemoveItemAtIndex(timers, i); + GSIArrayRemoveItemAtIndex(timers, 0); + min_timer = nil; + continue; + } + + if ([timerDate(min_timer) timeIntervalSinceReferenceDate] > now) + { + when = [timerDate(min_timer) copy]; + break; + } + + GSIArrayRemoveItemAtIndexNoRelease(timers, 0); + /* Firing will also increment its fireDate, if it is repeating. */ + [min_timer fire]; + now = GSTimeNow(); + if (timerInvalidated(min_timer) == NO) + { + GSIArrayInsertSortedNoRetain(timers, + (GSIArrayItem)((id)min_timer), tSort); } else { - d = timerDate(t); - ti = [d timeIntervalSinceReferenceDate]; - if (earliest == nil || ti < ei) - { - earliest = d; - ei = ti; - } + RELEASE(min_timer); } + GSPrivateNotifyASAP(); /* Post notifications. */ + IF_NO_GC([arp emptyPool]); } - - /* The earliest date of a valid timeout is copied into 'when' - * and used as our limit date. - */ - if (earliest != nil) - { - when = [earliest copy]; - } _currentMode = savedMode; } NS_HANDLER @@ -1072,7 +844,11 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) RELEASE(arp); - if (when == nil) + if (when != nil) + { + AUTORELEASE(when); + } + else { GSIArray watchers = context->watchers; unsigned i = GSIArrayCount(watchers); @@ -1091,15 +867,9 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) when = theFuture; } } -#if !GS_WITH_GC - else - { - AUTORELEASE(when); - } -#endif - NSDebugMLLog(@"NSRunLoop", @"limit date %f in %@", - [when timeIntervalSinceReferenceDate], mode); + NSDebugMLLog(@"NSRunLoop", @"limit date %f", + [when timeIntervalSinceReferenceDate]); } return when; } @@ -1110,14 +880,13 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) * just poll inputs and return, * otherwise block until input is available or until the * earliest limit date has passed (whichever comes first).
- * If the supplied mode is nil, uses NSDefaultRunLoopMode.
- * If there are no input sources or timers in the mode, returns immediately. + * If the supplied mode is nil, uses NSDefaultRunLoopMode. */ - (void) acceptInputForMode: (NSString*)mode beforeDate: (NSDate*)limit_date { GSRunLoopCtxt *context; - NSTimeInterval ti = 0; + NSTimeInterval ti; int timeout_ms; NSString *savedMode = _currentMode; CREATE_AUTORELEASE_POOL(arp); @@ -1134,6 +903,9 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) NS_DURING { + GSIArray watchers; + unsigned i; + /* * If we have a housekeeping timer, and it is earlier than the * limit date we have been given, we use the date of the housekeeper @@ -1146,23 +918,23 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) limit_date = timerDate(context->housekeeper); } - if (context == nil - || (GSIArrayCount(context->watchers) == 0 - && GSIArrayCount(context->timers) == 0)) + if ((context == nil || (watchers = context->watchers) == 0 + || (i = GSIArrayCount(watchers)) == 0)) { - NSDebugMLLog(@"NSRunLoop", @"no inputs or timers in mode %@", mode); - GSPrivateNotifyASAP(_currentMode); - GSPrivateNotifyIdle(_currentMode); - /* Pause until the limit date or until we might have - * a method to perform in this thread. + NSDebugMLLog(@"NSRunLoop", @"no inputs in mode %@", mode); + GSPrivateNotifyASAP(); + GSPrivateNotifyIdle(); + /* + * Pause for as long as possible (up to the limit date) */ - [GSRunLoopCtxt awakenedBefore: nil]; + [NSThread sleepUntilDate: limit_date]; + ti = [limit_date timeIntervalSinceNow]; GSPrivateCheckTasks(); if (context != nil) { [self _checkPerformers: context]; } - GSPrivateNotifyASAP(_currentMode); + GSPrivateNotifyASAP(); _currentMode = savedMode; RELEASE(arp); NS_VOIDRETURN; @@ -1178,33 +950,31 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) else { /* Wait until the LIMIT_DATE. */ + NSDebugMLLog(@"NSRunLoop", @"accept I/P before %f (sec from now %f)", + [limit_date timeIntervalSinceReferenceDate], ti); if (ti >= INT_MAX / 1000) { timeout_ms = INT_MAX; // Far future. } else { - timeout_ms = (ti * 1000.0); + timeout_ms = ti * 1000; } } - NSDebugMLLog(@"NSRunLoop", - @"accept I/P before %d millisec from now in %@", - timeout_ms, mode); - if ([_contextStack indexOfObjectIdenticalTo: context] == NSNotFound) { [_contextStack addObject: context]; } if ([context pollUntil: timeout_ms within: _contextStack] == NO) { - GSPrivateNotifyIdle(_currentMode); + GSPrivateNotifyIdle(); } [self _checkPerformers: context]; - GSPrivateNotifyASAP(_currentMode); + GSPrivateNotifyASAP(); _currentMode = savedMode; - - /* Once a poll has been completed on a context, we can remove that + /* + * Once a poll has been completed on a context, we can remove that * context from the stack even if it actually polling at an outer * level of re-entrancy ... since the poll we have just done will * have handled any events that the outer levels would have wanted @@ -1212,7 +982,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) */ [context endPoll]; [_contextStack removeObjectIdenticalTo: context]; - NSDebugMLLog(@"NSRunLoop", @"accept I/P completed in %@", mode); } NS_HANDLER { @@ -1226,16 +995,13 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) } /** - * Calls -limitDateForMode: to determine if a timeout occurs before the - * specified date, then calls -acceptInputForMode:beforeDate: to run the - * loop once.
+ * Calls -acceptInputForMode:beforeDate: to run the loop once.
* The specified date may be nil ... in which case the loop runs * until the limit date of the first input or timeout.
- * If the specified date is in the past, this runs the loop once only, - * to handle any events already available.
- * If there are no input sources or timers in mode, this method - * returns NO without running the loop (irrespective of the supplied - * date argument), otherwise returns YES. + * If the specified date is in the past, runs the loop once only, to + * handle any events already available.
+ * If there are no input sources in mode, returns NO without running the loop, + * otherwise returns YES. */ - (BOOL) runMode: (NSString*)mode beforeDate: (NSDate*)date { @@ -1248,6 +1014,14 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) d = [self limitDateForMode: mode]; if (d == nil) { + NSDebugMLLog(@"NSRunLoop", @"run mode with nothing to do"); + /* + * Notify if any tasks have completed. + */ + if (GSPrivateCheckTasks() == YES) + { + GSPrivateNotifyASAP(); + } RELEASE(arp); return NO; } @@ -1385,7 +1159,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) GSRunLoopPerformer *p; p = GSIArrayItemAtIndex(performers, count).obj; - if (p->target == target && sel_isEqual(p->selector, aSelector) + if (p->target == target && sel_eq(p->selector, aSelector) && (p->argument == argument || [p->argument isEqual: argument])) { GSIArrayRemoveItemAtIndex(performers, count); @@ -1418,7 +1192,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) - (void) performSelector: (SEL)aSelector target: (id)target argument: (id)argument - order: (NSUInteger)order + order: (unsigned int)order modes: (NSArray*)modes { unsigned count = [modes count]; @@ -1433,19 +1207,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) argument: argument order: order]; - if ([modes isProxy]) - { - unsigned i; - - for (i = 0; i < count; i++) - { - array[i] = [modes objectAtIndex: i]; - } - } - else - { - [modes getObjects: array]; - } + [modes getObjects: array]; while (count-- > 0) { NSString *mode = array[count]; @@ -1480,13 +1242,6 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) { GSIArrayInsertItem(performers, (GSIArrayItem)((id)item), i); } - i = GSIArrayCount(performers); - if (i % 1000 == 0 && i > context->maxPerformers) - { - context->maxPerformers = i; - NSLog(@"WARNING ... there are %u performers scheduled" - @" in mode %@ of %@", i, mode, self); - } } RELEASE(item); } @@ -1504,3 +1259,28 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now) @end +@implementation NSRunLoop (Housekeeper) +- (void) _setHousekeeper: (NSTimer*)timer +{ + GSRunLoopCtxt *context; + + context = NSMapGet(_contextMap, NSDefaultRunLoopMode); + if (context == nil) + { + context = [[GSRunLoopCtxt alloc] initWithMode: NSDefaultRunLoopMode + extra: _extra]; + NSMapInsert(_contextMap, context->mode, context); + RELEASE(context); + } + if (context->housekeeper != timer) + { + [context->housekeeper invalidate]; + DESTROY(context->housekeeper); + } + if (timer != nil) + { + context->housekeeper = RETAIN(timer); + } +} +@end + diff --git a/Source/NSScanner.m b/Source/NSScanner.m index 469509bc5..1cddf1492 100644 --- a/Source/NSScanner.m +++ b/Source/NSScanner.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Objective-C Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,33 +27,30 @@ $Date$ $Revision$ */ -#import "common.h" - -#if defined(HAVE_FLOAT_H) -#include +/* We need to define _GNU_SOURCE on systems (SuSE) to get LONG_LONG_MAX. */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif -#if !defined(LLONG_MAX) -# if defined(__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX-1) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) -# else -# error Neither LLONG_MAX nor __LONG_LONG_MAX__ found -# endif -#endif +#include "config.h" +#include "GNUstepBase/Unicode.h" +#include "Foundation/NSScanner.h" +#include "Foundation/NSException.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSUserDefaults.h" +#include +#include #include #include /* FIXME: May go away once I figure out Unicode */ +#include "GSPrivate.h" -#define EXPOSE_NSScanner_IVARS 1 -#import "GNUstepBase/Unicode.h" -#import "Foundation/NSScanner.h" -#import "Foundation/NSException.h" -#import "Foundation/NSUserDefaults.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" - -#import "GSPrivate.h" +/* BSD and Solaris have this */ +#if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX) +#define LONG_LONG_MAX LLONG_MAX +#define LONG_LONG_MIN LLONG_MIN +#define ULONG_LONG_MAX ULLONG_MAX +#endif @class GSCString; @@ -90,7 +87,9 @@ static inline unichar myGetC(unsigned char c) /* * Hack for direct access to internals of an concrete string object. */ -typedef GSString *ivars; +typedef struct { + @defs(GSString) +} *ivars; #define myLength() (((ivars)_string)->_count) #define myUnicode(I) (((ivars)_string)->_contents.u[I]) #define myChar(I) myGetC((((ivars)_string)->_contents.c[I])) @@ -202,7 +201,7 @@ typedef GSString *ivars; aString = @""; } - c = object_getClass(aString); + c = GSObjCClass(aString); if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES) { _isUnicode = YES; @@ -241,7 +240,7 @@ typedef GSString *ivars; } else { - DESTROY(self); + RELEASE(self); NSLog(@"Scanner initialised with something not a string"); return nil; } @@ -340,7 +339,7 @@ typedef GSString *ivars; if (value) { if (overflow - || (num > (negative ? (NSUInteger)INT_MIN : (NSUInteger)INT_MAX))) + || (num > (negative ? (unsigned int)INT_MIN : (unsigned int)INT_MAX))) *value = negative ? INT_MIN: INT_MAX; else if (negative) *value = -num; @@ -374,8 +373,8 @@ typedef GSString *ivars; * Scan an unsigned int of the given radix into value. * Internal version used by scanRadixUnsignedInt: and scanHexInt: . */ -- (BOOL) scanUnsignedInt_: (unsigned int*)value - radix: (NSUInteger)radix +- (BOOL) scanUnsignedInt_: (unsigned int *)value + radix: (unsigned int)radix gotDigits: (BOOL)gotDigits { unsigned int num = 0; @@ -463,7 +462,7 @@ typedef GSString *ivars; *
* Scans past any excess digits */ -- (BOOL) scanRadixUnsignedInt: (unsigned int*)value +- (BOOL) scanRadixUnsignedInt: (unsigned int *)value { unsigned int radix; BOOL gotDigits = NO; @@ -513,7 +512,7 @@ typedef GSString *ivars; *
* Scans past any excess digits */ -- (BOOL) scanHexInt: (unsigned int*)value +- (BOOL) scanHexInt: (unsigned int *)value { unsigned int saveScanLocation = _scanLocation; @@ -558,16 +557,16 @@ typedef GSString *ivars; *
* Returns YES if anything is scanned, NO otherwise. *
- * On overflow, LLONG_MAX or LLONG_MIN is put into + * On overflow, LONG_LONG_MAX or LONG_LONG_MIN is put into * longLongValue *
* Scans past any excess digits */ - (BOOL) scanLongLong: (long long *)value { -#if defined(LLONG_MAX) +#if defined(LONG_LONG_MAX) unsigned long long num = 0; - const unsigned long long limit = ULLONG_MAX / 10; + const unsigned long long limit = ULONG_LONG_MAX / 10; BOOL negative = NO; BOOL overflow = NO; BOOL got_digits = NO; @@ -622,21 +621,21 @@ typedef GSString *ivars; { if (negative) { - if (overflow || (num > (unsigned long long)LLONG_MIN)) - *value = LLONG_MIN; + if (overflow || (num > (unsigned long long)LONG_LONG_MIN)) + *value = LONG_LONG_MIN; else *value = -num; } else { - if (overflow || (num > (unsigned long long)LLONG_MAX)) - *value = LLONG_MAX; + if (overflow || (num > (unsigned long long)LONG_LONG_MAX)) + *value = LONG_LONG_MAX; else *value = num; } } return YES; -#else /* defined(LLONG_MAX) */ +#else /* defined(LONG_LONG_MAX) */ /* * Provide compile-time warning and run-time exception. */ @@ -644,7 +643,7 @@ typedef GSString *ivars; [NSException raise: NSGenericException format: @"Can't use long long variables."]; return NO; -#endif /* defined(LLONG_MAX) */ +#endif /* defined(LONG_LONG_MAX) */ } /** @@ -935,10 +934,7 @@ typedef GSString *ivars; NSRange range; unsigned int saveScanLocation = _scanLocation; - if (skipToNextField() == NO) - { - return NO; - } + skipToNextField(); range.location = _scanLocation; range.length = [string length]; if (range.location + range.length > myLength()) @@ -992,10 +988,7 @@ typedef GSString *ivars; NSRange found; unsigned int saveScanLocation = _scanLocation; - if (skipToNextField() == NO) - { - return NO; - } + skipToNextField(); range.location = _scanLocation; range.length = myLength() - _scanLocation; found = [_string rangeOfString: string @@ -1027,7 +1020,7 @@ typedef GSString *ivars; * scanning the string. This is the position at which the next scan * operation will begin. */ -- (NSUInteger) scanLocation +- (unsigned) scanLocation { return _scanLocation; } @@ -1038,7 +1031,7 @@ typedef GSString *ivars; * Raises an NSRangeException if index is beyond the end of the * scanned string. */ -- (void) setScanLocation: (NSUInteger)anIndex +- (void) setScanLocation: (unsigned int)anIndex { if (_scanLocation <= myLength()) _scanLocation = anIndex; @@ -1146,7 +1139,7 @@ typedef GSString *ivars; { NSScanner *n = [[self class] allocWithZone: zone]; - [n initWithString: _string]; + n = [n initWithString: _string]; [n setCharactersToBeSkipped: _charactersToBeSkipped]; [n setLocale: _locale]; [n setScanLocation: _scanLocation]; @@ -1154,22 +1147,6 @@ typedef GSString *ivars; return n; } -- (BOOL) scanHexDouble: (double *)result -{ - return NO; // FIXME -} -- (BOOL) scanHexFloat: (float *)result -{ - return NO; // FIXME -} -- (BOOL) scanHexLongLong: (unsigned long long *)result -{ - return NO; // FIXME -} -- (BOOL) scanInteger: (NSInteger *)value -{ - return NO; // FIXME -} @end /* @@ -1226,7 +1203,7 @@ GSScanInt(unichar *buf, unsigned length, int *result) if (result) { if (overflow - || (num > (negative ? (NSUInteger)INT_MIN : (NSUInteger)INT_MAX))) + || (num > (negative ? (unsigned int)INT_MIN : (unsigned int)INT_MAX))) *result = negative ? INT_MIN: INT_MAX; else if (negative) *result = -num; @@ -1237,7 +1214,7 @@ GSScanInt(unichar *buf, unsigned length, int *result) } /** - * Scan in a double value in the standard locale ('.' as decimal poNSInteger).
+ * Scan in a double value in the standard locale ('.' as decimal point).
* Return YES on success, NO on failure.
* The value pointed to by result is unmodified on failure.
* No value is returned in result if it is a null pointer. @@ -1254,7 +1231,7 @@ GSScanDouble(unichar *buf, unsigned length, double *result) unsigned pos = 0; /* Skip whitespace */ - while (pos < length && isspace((NSInteger)buf[pos])) + while (pos < length && isspace((int)buf[pos])) { pos++; } diff --git a/Source/NSSerializer.m b/Source/NSSerializer.m index 4ccd0a5f8..c6412cbfe 100644 --- a/Source/NSSerializer.m +++ b/Source/NSSerializer.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,22 +25,23 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSException.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSProxy.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSValue.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSString.h" +#include "Foundation/NSException.h" +#include "Foundation/NSProxy.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSSet.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSValue.h" -#import "GSPrivate.h" +#include "GSPrivate.h" @class GSDictionary; @class GSMutableDictionary; @@ -53,8 +54,6 @@ /* * Setup for inline operation of string map tables. */ -#define GSI_MAP_KTYPES GSUNION_OBJ -#define GSI_MAP_VTYPES GSUNION_INT #define GSI_MAP_RETAIN_KEY(M, X) #define GSI_MAP_RELEASE_KEY(M, X) #define GSI_MAP_RETAIN_VAL(M, X) @@ -63,11 +62,6 @@ #define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToString: (Y).obj] #define GSI_MAP_NOCLEAN 1 -#if GS_WITH_GC -#define GSI_MAP_NODES(M, X) \ -(GSIMapNode)NSAllocateCollectable(X * sizeof(GSIMapNode_t), 0) -#endif - #include "GNUstepBase/GSIMap.h" /* @@ -119,6 +113,10 @@ static Class MutableDictionaryClass = 0; static Class StringClass = 0; static Class NumberClass = 0; +typedef struct { + @defs(GSString) +} *ivars; + typedef struct { NSMutableData *data; void (*appImp)(NSData*,SEL,const void*,unsigned); @@ -147,7 +145,7 @@ initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u) { Class c; - c = object_getClass(d); + c = GSObjCClass(d); info->data = d; info->appImp = (void (*)(NSData*,SEL,const void*,unsigned))get_imp(c, appSel); info->datImp = (void* (*)(NSMutableData*,SEL))get_imp(c, datSel); @@ -181,7 +179,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) format: @"Class (%@) in property list - expected instance", [object description]]; } - c = object_getClass(object); + c = GSObjCClass(object); if (GSObjCIsKindOf(c, StringClass) /* @@ -281,17 +279,7 @@ serializeToInfo(id object, _NSSerializerInfo* info) id objects[count]; unsigned int i; - if ([object isProxy]) - { - for (i = 0; i < count; i++) - { - objects[i] = [object objectAtIndex: i]; - } - } - else - { - [object getObjects: objects]; - } + [object getObjects: objects]; for (i = 0; i < count; i++) { serializeToInfo(objects[i], info); @@ -497,7 +485,7 @@ initDeserializerInfo(_NSDeserializerInfo* info, NSData *d, unsigned *c, BOOL m) *c += 9; (*info->debImp)(d, debSel, &u, 1, c); NSLog(@"Serialised data version %d not supported ..." - @" try another version of GNUstep", u); + @" try another version of GNUstep"); return NO; } } @@ -556,11 +544,7 @@ deserializeFromInfo(_NSDeserializerInfo* info) char *b; size = (*info->deiImp)(info->data, deiSel, info->cursor); -#if GS_WITH_GC - b = NSAllocateCollectable(size, 0); -#else b = NSZoneMalloc(NSDefaultMallocZone(), size); -#endif (*info->debImp)(info->data, debSel, b, size, info->cursor); s = [[StringClass alloc] initWithBytesNoCopy: b length: size - 1 @@ -591,11 +575,7 @@ deserializeFromInfo(_NSDeserializerInfo* info) unichar *b; size = (*info->deiImp)(info->data, deiSel, info->cursor); -#if GS_WITH_GC - b = NSAllocateCollectable(size*sizeof(unichar), 0); -#else b = NSZoneMalloc(NSDefaultMallocZone(), size*sizeof(unichar)); -#endif (*info->debImp)(info->data, debSel, b, size*sizeof(unichar), info->cursor); s = [[StringClass alloc] initWithBytesNoCopy: b @@ -693,7 +673,7 @@ deserializeFromInfo(_NSDeserializerInfo* info) * rather than simply releasing as the key may * be referred to by a cross-reference later. */ - IF_NO_GC(AUTORELEASE(k);) + AUTORELEASE(k); RELEASE(o); } } diff --git a/Source/NSSet.m b/Source/NSSet.m index 1c05fcad8..e2fc8653e 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,19 +25,19 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSKeyValueCoding.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSException.h" +#include "config.h" +#include "Foundation/NSSet.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSUtilities.h" +#include "Foundation/NSString.h" +#include "Foundation/NSException.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSDebug.h" // For private method _decodeArrayOfObjectsForKey: -#import "Foundation/NSKeyedArchiver.h" -#import "GSPrivate.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "Foundation/NSKeyedArchiver.h" +#include "GNUstepBase/GSCategories.h" +#include "GSPrivate.h" @class GSSet; @interface GSSet : NSObject // Help the compiler @@ -74,9 +74,10 @@ static Class NSMutableSet_concrete_class; { if (self == [NSSet class]) { - NSSet_abstract_class = self; + NSSet_abstract_class = [NSSet class]; + NSMutableSet_abstract_class = [NSMutableSet class]; NSSet_concrete_class = [GSSet class]; - [NSMutableSet class]; + NSMutableSet_concrete_class = [GSMutableSet class]; } } @@ -110,7 +111,7 @@ static Class NSMutableSet_concrete_class; * New set containing (unique elements of) objects. */ + (id) setWithObjects: (id*)objects - count: (NSUInteger)count + count: (unsigned)count { return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] initWithObjects: objects count: count]); @@ -159,7 +160,7 @@ static Class NSMutableSet_concrete_class; /** * Returns the number of objects stored in the set. */ -- (NSUInteger) count +- (unsigned) count { [self subclassResponsibility: _cmd]; return 0; @@ -210,16 +211,16 @@ static Class NSMutableSet_concrete_class; { Class c; - c = object_getClass(self); + c = GSObjCClass(self); if (c == NSSet_abstract_class) { - DESTROY(self); + RELEASE(self); self = [NSSet_concrete_class allocWithZone: NSDefaultMallocZone()]; return [self initWithCoder: aCoder]; } else if (c == NSMutableSet_abstract_class) { - DESTROY(self); + RELEASE(self); self = [NSMutableSet_concrete_class allocWithZone: NSDefaultMallocZone()]; return [self initWithCoder: aCoder]; } @@ -314,7 +315,7 @@ static Class NSMutableSet_concrete_class; * other initialisers work. */ - (id) initWithObjects: (id*)objects - count: (NSUInteger)count + count: (unsigned)count { self = [self init]; return self; @@ -377,19 +378,7 @@ static Class NSMutableSet_concrete_class; { GS_BEGINIDBUF(objs, count); - if ([other isProxy]) - { - unsigned i; - - for (i = 0; i < count; i++) - { - objs[i] = [other objectAtIndex: i]; - } - } - else - { - [other getObjects: objs]; - } + [other getObjects: objs]; self = [self initWithObjects: objs count: count]; GS_ENDIDBUF(); return self; @@ -441,7 +430,7 @@ static Class NSMutableSet_concrete_class; id e = [self objectEnumerator]; unsigned i; unsigned c = [self count]; - NSArray *result = nil; + NSArray *result; GS_BEGINIDBUF(k, c); for (i = 0; i < c; i++) @@ -477,7 +466,7 @@ static Class NSMutableSet_concrete_class; return (([self member: anObject]) ? YES : NO); } -- (NSUInteger) hash +- (unsigned) hash { return [self count]; } @@ -624,288 +613,6 @@ static Class NSMutableSet_concrete_class; return [[self allObjects] descriptionWithLocale: locale]; } -- (id) valueForKeyPath: (NSString*)path -{ - id result = (id) nil; - - if ([path hasPrefix: @"@"]) - { - NSRange r; - - r = [path rangeOfString: @"."]; - if (r.length == 0) - { - if ([path isEqualToString: @"@count"] == YES) - { - result = [NSNumber numberWithUnsignedInt: [self count]]; - } - else - { - result = [self valueForKey: path]; - } - } - else - { - NSString *op = [path substringToIndex: r.location]; - NSString *rem = [path substringFromIndex: NSMaxRange(r)]; - unsigned count = [self count]; - - if ([op isEqualToString: @"@count"] == YES) - { - result = [NSNumber numberWithUnsignedInt: count]; - } - else if ([op isEqualToString: @"@avg"] == YES) - { - double d = 0; - - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - while ((o = [e nextObject]) != nil) - { - d += [[o valueForKeyPath: rem] doubleValue]; - } - d /= count; - } - result = [NSNumber numberWithDouble: d]; - } - else if ([op isEqualToString: @"@max"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - if (result == nil - || [result compare: o] == NSOrderedAscending) - { - result = o; - } - } - } - } - else if ([op isEqualToString: @"@min"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - if (result == nil - || [result compare: o] == NSOrderedDescending) - { - result = o; - } - } - } - } - else if ([op isEqualToString: @"@sum"] == YES) - { - double d = 0; - - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - while ((o = [e nextObject]) != nil) - { - d += [[o valueForKeyPath: rem] doubleValue]; - } - } - result = [NSNumber numberWithDouble: d]; - } - else if ([op isEqualToString: @"@distinctUnionOfArrays"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - result = [NSMutableSet set]; - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - [result addObjectsFromArray: o]; - } - result = [result allObjects]; - } - else - { - result = [NSArray array]; - } - } - else if ([op isEqualToString: @"@distinctUnionOfObjects"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - result = [NSMutableSet set]; - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - [result addObject: o]; - } - result = [result allObjects]; - } - else - { - result = [NSArray array]; - } - } - else if ([op isEqualToString: @"@distinctUnionOfSets"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - result = [NSMutableSet set]; - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - [result addObjectsFromArray: [o allObjects]]; - } - result = [result allObjects]; - } - else - { - result = [NSArray array]; - } - } - else if ([op isEqualToString: @"@unionOfArrays"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - result = [GSMutableArray array]; - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - [result addObjectsFromArray: o]; - } - [result makeImmutableCopyOnFail: NO]; - } - else - { - result = [NSArray array]; - } - } - else if ([op isEqualToString: @"@unionOfObjects"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - result = [GSMutableArray array]; - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - [result addObject: o]; - } - [result makeImmutableCopyOnFail: NO]; - } - else - { - result = [NSArray array]; - } - } - else if ([op isEqualToString: @"@unionOfSets"] == YES) - { - if (count > 0) - { - NSEnumerator *e = [self objectEnumerator]; - id o; - - result = [GSMutableArray array]; - while ((o = [e nextObject]) != nil) - { - o = [o valueForKeyPath: rem]; - [result addObjectsFromArray: [o allObjects]]; - } - [result makeImmutableCopyOnFail: NO]; - } - else - { - result = [NSArray array]; - } - } - else - { - result = [super valueForKeyPath: path]; - } - } - } - else - { - result = [super valueForKeyPath: path]; - } - - return result; -} - -/** Return a set formed by adding anObject to the receiver. - */ -- (NSSet *) setByAddingObject: (id)anObject -{ - NSMutableSet *m; - NSSet *s; - - m = [self mutableCopy]; - [m addObject: anObject]; - s = [m copy]; - [m release]; - return [s autorelease]; -} - -/** Return a set formed by adding the contents of other to the receiver. - */ -- (NSSet *) setByAddingObjectsFromArray: (NSArray *)other -{ - NSMutableSet *m; - NSSet *s; - - m = [self mutableCopy]; - [m addObjectsFromArray: other]; - s = [m copy]; - [m release]; - return [s autorelease]; -} - -/** Return a set formed as a union of the receiver and other. - */ -- (NSSet *) setByAddingObjectsFromSet: (NSSet *)other -{ - NSMutableSet *m; - NSSet *s; - - m = [self mutableCopy]; - [m unionSet: other]; - s = [m copy]; - [m release]; - return [s autorelease]; -} - -- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state - objects: (id*)stackbuf - count: (NSUInteger)len -{ - [self subclassResponsibility: _cmd]; - return 0; -} @end @@ -918,15 +625,13 @@ static Class NSMutableSet_concrete_class; { if (self == [NSMutableSet class]) { - NSMutableSet_abstract_class = self; - NSMutableSet_concrete_class = [GSMutableSet class]; } } /** * New autoreleased instance with given capacity. */ -+ (id) setWithCapacity: (NSUInteger)numItems ++ (id) setWithCapacity: (unsigned)numItems { return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] initWithCapacity: numItems]); @@ -946,7 +651,7 @@ static Class NSMutableSet_concrete_class; - (Class) classForCoder { - return NSMutableSet_abstract_class; + return NSMutableSet_concrete_class; } /** @@ -959,7 +664,7 @@ static Class NSMutableSet_concrete_class; * and needs to be re-implemented in subclasses in order to have all * other initialisers work. */ -- (id) initWithCapacity: (NSUInteger)numItems +- (id) initWithCapacity: (unsigned)numItems { self = [self init]; return self; @@ -983,7 +688,7 @@ static Class NSMutableSet_concrete_class; } - (id) initWithObjects: (id*)objects - count: (NSUInteger)count + count: (unsigned)count { self = [self initWithCapacity: count]; if (self != nil) @@ -1078,7 +783,7 @@ static Class NSMutableSet_concrete_class; } else { - IF_NO_GC([other retain];) // In case it's held by us + RETAIN(other); // In case it's held by us [self removeAllObjects]; [self unionSet: other]; RELEASE(other); diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index b7c5bc888..a4fb885be 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,55 +16,56 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" -#define EXPOSE_NSPort_IVARS 1 -#define EXPOSE_NSSocketPort_IVARS 1 -#import "GNUstepBase/GSLock.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSException.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSByteOrder.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSPortMessage.h" -#import "Foundation/NSPortNameServer.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSConnection.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "GNUstepBase/GSLock.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSException.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSByteOrder.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSHost.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSPortMessage.h" +#include "Foundation/NSPortNameServer.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSHost.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSConnection.h" +#include "Foundation/NSDebug.h" -#import "GSNetwork.h" -#import "GSPortPrivate.h" -#import "GSPrivate.h" +#include "GSPortPrivate.h" +#include "GSPrivate.h" #include +#include #ifdef HAVE_UNISTD_H -#include +#include /* for gethostname() */ #endif -#ifdef __MINGW__ +#ifdef __MINGW32__ #define close closesocket #else #include /* for MAXHOSTNAMELEN */ #include #include #include /* for inet_ntoa() */ -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ #include +#include #include /* for strchr() */ #include /* for strchr() */ #include -#ifdef __MINGW__ +#ifdef __MINGW32__ #include #include #include @@ -101,7 +102,7 @@ #define SOCKET_ERROR -1 #define INVALID_SOCKET -1 -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ /* * Largest chunk of data possible in DO @@ -186,7 +187,7 @@ typedef enum { GS_H_CONNECTED // Currently connected. } GSHandleState; -@interface GSTcpHandle : NSObject +@interface GSTcpHandle : NSObject { SOCKET desc; /* File descriptor for I/O. */ unsigned wItem; /* Index of item being written. */ @@ -202,7 +203,7 @@ typedef enum { unsigned nItems; /* Number of items to be read. */ GSHandleState state; /* State of the handle. */ unsigned int addrNum; /* Address number within host. */ -#ifdef __MINGW__ +#ifdef __MINGW32__ WSAEVENT event; /* Win32 event associated to socket */ WSAEVENT eventTemp; /* Win32 event for asynchronous */ @public @@ -223,7 +224,7 @@ typedef enum { + (GSTcpHandle*) handleWithDescriptor: (SOCKET)d; - (BOOL) connectToPort: (NSSocketPort*)aPort beforeDate: (NSDate*)when; - (int) descriptor; -#if defined(__MINGW__) +#if defined(__MINGW32__) - (int) eventHandle; #endif - (void) invalidate; @@ -252,14 +253,12 @@ decodePort(NSData *data, NSString *defaultAddress) GSPortInfo *pi; NSString *addr; uint16_t pnum; - uint32_t length; NSHost *host; unichar c; pih = (GSPortItemHeader*)[data bytes]; NSCAssert(GSSwapBigI32ToHost(pih->type) == GSP_PORT, NSInternalInconsistencyException); - length = GSSwapBigI32ToHost(pih->length); pi = (GSPortInfo*)&pih[1]; pnum = GSSwapBigI16ToHost(pi->num); if (strncmp(pi->addr, "VER", 3) == 0) @@ -369,13 +368,13 @@ static Class runLoopClass; + (GSTcpHandle*) handleWithDescriptor: (SOCKET)d { GSTcpHandle *handle; -#ifdef __MINGW__ +#ifdef __MINGW32__ unsigned long dummy; #else int e; -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ -#ifdef __MINGW__ +#ifdef __MINGW32__ WSAEVENT ev; int rc; #endif @@ -385,7 +384,7 @@ static Class runLoopClass; NSLog(@"illegal descriptor (%d) for Tcp Handle", d); return nil; } -#ifdef __MINGW__ +#ifdef __MINGW32__ dummy = 1; if (ioctlsocket(d, FIONBIO, &dummy) == SOCKET_ERROR) { @@ -393,7 +392,7 @@ static Class runLoopClass; d, [NSError _last]); return nil; } -#else /* !__MINGW__ */ +#else /* !__MINGW32__ */ if ((e = fcntl(d, F_GETFL, 0)) >= 0) { e |= NBLK_OPT; @@ -416,7 +415,7 @@ static Class runLoopClass; handle->wMsgs = [NSMutableArray new]; handle->myLock = [GSLazyRecursiveLock new]; handle->valid = YES; -#if defined(__MINGW__) +#if defined(__MINGW32__) ev = (WSAEVENT)CreateEvent(NULL,NO,NO,NULL); if (ev == WSA_INVALID_EVENT) { @@ -437,7 +436,7 @@ static Class runLoopClass; { if (self == [GSTcpHandle class]) { -#ifdef __MINGW__ +#ifdef __MINGW32__ WORD wVersionRequested; WSADATA wsaData; @@ -538,7 +537,7 @@ static Class runLoopClass; if (connect(desc, (struct sockaddr*)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR) { -#ifdef __MINGW__ +#ifdef __MINGW32__ if (WSAGetLastError() != WSAEWOULDBLOCK) #else if (errno != EINPROGRESS) @@ -565,7 +564,7 @@ static Class runLoopClass; state = GS_H_TRYCON; l = [NSRunLoop currentRunLoop]; -#if defined(__MINGW__) +#if defined(__MINGW32__) NSAssert(event != WSA_INVALID_EVENT, @"Socket without win32 event!"); [l addEvent: (void*)(uintptr_t)event type: ET_HANDLE @@ -603,7 +602,7 @@ static Class runLoopClass; M_LOCK(myLock); } -#if defined(__MINGW__) +#if defined(__MINGW32__) [l removeEvent: (void*)(uintptr_t)event type: ET_HANDLE forMode: NSConnectionReplyMode @@ -674,7 +673,7 @@ static Class runLoopClass; - (void) dealloc { - [self finalize]; + [self gcFinalize]; DESTROY(defaultAddress); DESTROY(rData); DESTROY(rItems); @@ -694,14 +693,14 @@ static Class runLoopClass; return desc; } -#if defined(__MINGW__) +#if defined(__MINGW32__) - (int) eventHandle { - return (int) (size_t) event; + return (int)event; } #endif -- (void) finalize +- (void) gcFinalize { [self invalidate]; (void)close(desc); @@ -719,7 +718,7 @@ static Class runLoopClass; valid = NO; l = [runLoopClass currentRunLoop]; -#if defined(__MINGW__) +#if defined(__MINGW32__) [l removeEvent: (void*)(uintptr_t)event type: ET_HANDLE forMode: nil @@ -741,7 +740,7 @@ static Class runLoopClass; NSDebugMLLog(@"GSTcpHandle", @"invalidated 0x%x", self); [[self recvPort] removeHandle: self]; [[self sendPort] removeHandle: self]; -#if defined(__MINGW__) +#if defined(__MINGW32__) WSACloseEvent(event); event = WSA_INVALID_EVENT; #endif @@ -808,12 +807,12 @@ static Class runLoopClass; [self invalidate]; return; } -#ifdef __MINGW__ +#ifdef __MINGW32__ else if (WSAGetLastError()!= WSAEINTR && WSAGetLastError()!= WSAEWOULDBLOCK) #else else if (errno != EINTR && errno != EAGAIN) -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ { NSDebugMLLog(@"GSTcpHandle", @"read failed - %@ on 0x%p", [NSError _last], self); @@ -1074,7 +1073,7 @@ static Class runLoopClass; DESTROY(rItems); NSDebugMLLog(@"GSTcpHandle", @"got message %@ on 0x%x", pm, self); - IF_NO_GC(RETAIN(rp);) + RETAIN(rp); M_UNLOCK(myLock); NS_DURING { @@ -1101,7 +1100,7 @@ static Class runLoopClass; if (state == GS_H_TRYCON) /* Connection attempt. */ { int res = 0; - socklen_t len = sizeof(res); + unsigned len = sizeof(res); if (getsockopt(desc, SOL_SOCKET, SO_ERROR, (char*)&res, &len) != 0) { @@ -1162,23 +1161,23 @@ static Class runLoopClass; res = send(desc, b + wLength, l - wLength, 0); if (res < 0) { -#ifdef __MINGW__ +#ifdef __MINGW32__ if (WSAGetLastError()!= WSAEINTR && WSAGetLastError()!= WSAEWOULDBLOCK) #else if (errno != EINTR && errno != EAGAIN) -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ { NSLog(@"write attempt failed - %@", [NSError _last]); [self invalidate]; return; } -#ifdef __MINGW__ +#ifdef __MINGW32__ if (WSAGetLastError()== WSAEWOULDBLOCK) { readyToSend = NO; } -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ } else { @@ -1223,10 +1222,11 @@ static Class runLoopClass; extra: (void*)extra forMode: (NSString*)mode { -#if defined(__MINGW__) +#if defined(__MINGW32__) WSANETWORKEVENTS ocurredEvents; -#else #endif + NSDebugMLLog(@"GSTcpHandle", @"received %s event on 0x%x", + type == ET_RPORT ? "read" : "write", self); /* * If we have been invalidated (desc < 0) then we should ignore this * event and remove ourself from the runloop. @@ -1235,7 +1235,7 @@ static Class runLoopClass; { NSRunLoop *l = [runLoopClass currentRunLoop]; -#if defined(__MINGW__) +#if defined(__MINGW32__) [l removeEvent: data type: ET_HANDLE forMode: mode @@ -1255,7 +1255,7 @@ static Class runLoopClass; M_LOCK(myLock); -#if defined(__MINGW__) +#if defined(__MINGW32__) if (WSAEnumNetworkEvents(desc, event, &ocurredEvents)==SOCKET_ERROR) { NSLog(@"Error getting event type %d", WSAGetLastError()); @@ -1264,7 +1264,7 @@ static Class runLoopClass; if (ocurredEvents.lNetworkEvents & FD_CONNECT) { [self receivedEventWrite]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (desc == INVALID_SOCKET) { M_UNLOCK(myLock); @@ -1275,7 +1275,7 @@ static Class runLoopClass; if (ocurredEvents.lNetworkEvents & FD_READ) { [self receivedEventRead]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (desc == INVALID_SOCKET) { M_UNLOCK(myLock); @@ -1286,7 +1286,7 @@ static Class runLoopClass; if (ocurredEvents.lNetworkEvents & FD_OOB) { [self receivedEventRead]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (desc == INVALID_SOCKET) { M_UNLOCK(myLock); @@ -1298,7 +1298,7 @@ static Class runLoopClass; { readyToSend = YES; [self receivedEventWrite]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (desc == INVALID_SOCKET) { M_UNLOCK(myLock); @@ -1309,7 +1309,7 @@ static Class runLoopClass; if (ocurredEvents.lNetworkEvents & FD_CLOSE) { [self receivedEventRead]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (desc == INVALID_SOCKET) { M_UNLOCK(myLock); @@ -1323,7 +1323,7 @@ static Class runLoopClass; abort(); } #else - if (type != ET_WDESC) + if (type == ET_RPORT) { [self receivedEventRead]; } @@ -1350,9 +1350,9 @@ static Class runLoopClass; l = [runLoopClass currentRunLoop]; - IF_NO_GC(RETAIN(self);) + RETAIN(self); -#if defined(__MINGW__) +#if defined(__MINGW32__) NSAssert(event != WSA_INVALID_EVENT, @"Socket without win32 event!"); [l addEvent: (void*)(uintptr_t)event type: ET_HANDLE @@ -1387,7 +1387,7 @@ static Class runLoopClass; && [when timeIntervalSinceNow] > 0) { M_UNLOCK(myLock); -#if defined(__MINGW__) +#if defined(__MINGW32__) if (readyToSend) { [self receivedEventWrite]; @@ -1402,7 +1402,7 @@ static Class runLoopClass; M_LOCK(myLock); } -#if defined(__MINGW__) +#if defined(__MINGW32__) [l removeEvent: (void*)(uintptr_t)event type: ET_HANDLE forMode: NSConnectionReplyMode @@ -1436,9 +1436,9 @@ static Class runLoopClass; sent = YES; } M_UNLOCK(myLock); + RELEASE(self); NSDebugMLLog(@"GSTcpHandle", @"Message send 0x%x on 0x%x status %d", components, self, sent); - RELEASE(self); return sent; } @@ -1539,7 +1539,7 @@ static Class tcpPortClass; forceAddress: (NSString*)addr listener: (BOOL)shouldListen { - socklen_t slen; + unsigned i; NSSocketPort *port = nil; NSHost *thisHost = [NSHost localHost]; NSMapTable *thePorts; @@ -1583,7 +1583,7 @@ static Class tcpPortClass; port->address = [addr copy]; port->handles = NSCreateMapTable(NSIntMapKeyCallBacks, NSObjectMapValueCallBacks, 0); -#if defined(__MINGW__) +#if defined(__MINGW32__) port->eventListener = WSA_INVALID_EVENT; port->events = NSCreateMapTable(NSIntMapKeyCallBacks, NSIntMapValueCallBacks, 0); @@ -1627,7 +1627,7 @@ static Class tcpPortClass; /* * Need size of buffer for getsockbyname() later. */ - slen = sizeof(sockaddr); + i = sizeof(sockaddr); if (addrOk == NO) { @@ -1664,13 +1664,13 @@ static Class tcpPortClass; (void) close(desc); DESTROY(port); } - else if (listen(desc, 128) == SOCKET_ERROR) + else if (listen(desc, GSBACKLOG) == SOCKET_ERROR) { NSLog(@"unable to listen on port - %@", [NSError _last]); (void) close(desc); DESTROY(port); } - else if (getsockname(desc, (struct sockaddr*)&sockaddr, &slen) + else if (getsockname(desc, (struct sockaddr*)&sockaddr, &i) == SOCKET_ERROR) { NSLog(@"unable to get socket name - %@", [NSError _last]); @@ -1679,7 +1679,7 @@ static Class tcpPortClass; } else { -#if defined(__MINGW__) +#if defined(__MINGW32__) int rc; #endif /* @@ -1689,7 +1689,7 @@ static Class tcpPortClass; */ port->listener = desc; port->portNum = GSSwapBigI16ToHost(sockaddr.sin_port); -#if defined(__MINGW__) +#if defined(__MINGW32__) port->eventListener = (WSAEVENT)CreateEvent(NULL,NO,NO,NULL); if (port->eventListener == WSA_INVALID_EVENT) { @@ -1751,7 +1751,7 @@ static Class tcpPortClass; } else { - IF_NO_GC(RETAIN(port);) + RETAIN(port); NSDebugMLLog(@"NSPort", @"Using pre-existing port: %@", port); } IF_NO_GC(AUTORELEASE(port)); @@ -1775,7 +1775,7 @@ static Class tcpPortClass; handle->recvPort = GS_GC_HIDE(self); } NSMapInsert(handles, (void*)(uintptr_t)[handle descriptor], (void*)handle); -#if defined(__MINGW__) +#if defined(__MINGW32__) NSMapInsert(events, (void*)(uintptr_t)[handle eventHandle], (void*)(uintptr_t)[handle descriptor]); #endif @@ -1794,41 +1794,42 @@ static Class tcpPortClass; - (void) dealloc { - [self finalize]; + [self gcFinalize]; + DESTROY(host); + TEST_RELEASE(address); [super dealloc]; } - (NSString*) description { - NSString *desc; + NSMutableString *desc; - desc = [NSString stringWithFormat: - @"<%s %p on IP %@,%d>", - GSClassNameFromObject(self), self, - ((address == nil) ? (id)@"any" : (id)address), portNum]; + desc = [NSMutableString stringWithFormat: @"NSPort on host with details -\n" + @"%@\n", host]; + if (address == nil) + { + [desc appendFormat: @" IP address - any\n"]; + } + else + { + [desc appendFormat: @" IP address - %@\n", address]; + } + [desc appendFormat: @" TCP port - %d\n", portNum]; return desc; } -- (void) finalize +- (void) gcFinalize { NSDebugMLLog(@"NSPort", @"NSSocketPort 0x%x finalized", self); [self invalidate]; - if (handles != 0) - { - NSFreeMapTable(handles); - handles = 0; - } - DESTROY(host); - TEST_RELEASE(address); - DESTROY(myLock); } /* * This is a callback method used by the NSRunLoop class to determine which * descriptors to watch for the port. */ -#if defined(__MINGW__) -- (void) getFds: (int*)fds count: (int*)count +#if defined(__MINGW32__) +- (void) getFds: (NSInteger*)fds count: (NSInteger*)count { NSMapEnumerator me; void *event; @@ -1865,14 +1866,13 @@ static Class tcpPortClass; if (handle->recvPort == recvSelf && handle->inReplyMode == NO) { fds[(*count)++] = (uintptr_t)event; - NSDebugMLLog(@"NSPort", @"Add event %p", event); } } NSEndMapTableEnumeration(&me); M_UNLOCK(myLock); } #else -- (void) getFds: (int*)fds count: (int*)count +- (void) getFds: (NSInteger*)fds count: (NSInteger*)count { NSMapEnumerator me; void *sock; @@ -1927,9 +1927,9 @@ static Class tcpPortClass; me = NSEnumerateMapTable(handles); while (NSNextMapEnumeratorPair(&me, &dummy, (void**)&handle)) { - if ((NSPort*) [handle recvPort] == recvPort) + if ([handle recvPort] == recvPort) { - IF_NO_GC(RETAIN(handle);) + RETAIN(handle); NSEndMapTableEnumeration(&me); M_UNLOCK(myLock); return AUTORELEASE(handle); @@ -2030,9 +2030,9 @@ static Class tcpPortClass; [d handlePortMessage: m]; } -- (NSUInteger) hash +- (unsigned) hash { - return (NSUInteger)portNum; + return (unsigned)portNum; } - (NSHost*) host @@ -2042,7 +2042,7 @@ static Class tcpPortClass; - (id) init { - DESTROY(self); + RELEASE(self); self = [tcpPortClass new]; return self; } @@ -2051,7 +2051,6 @@ static Class tcpPortClass; { if ([self isValid] == YES) { - IF_NO_GC(RETAIN(self);) M_LOCK(myLock); if ([self isValid] == YES) @@ -2072,7 +2071,7 @@ static Class tcpPortClass; { (void) close(listener); listener = -1; -#if defined(__MINGW__) +#if defined(__MINGW32__) WSACloseEvent(eventListener); eventListener = WSA_INVALID_EVENT; #endif @@ -2088,8 +2087,17 @@ static Class tcpPortClass; [handle invalidate]; } + /* + * We permit mutual recursive invalidation, so the handles map + * may already have been destroyed. + */ + if (handles != 0) + { + NSFreeMapTable(handles); + handles = 0; + } } -#if defined(__MINGW__) +#if defined(__MINGW32__) if (events != 0) { NSFreeMapTable(events); @@ -2100,7 +2108,6 @@ static Class tcpPortClass; [super invalidate]; } M_UNLOCK(myLock); - RELEASE(self); } } @@ -2132,7 +2139,7 @@ static Class tcpPortClass; extra: (void*)extra forMode: (NSString*)mode { -#if defined(__MINGW__) +#if defined(__MINGW32__) WSAEVENT event = (WSAEVENT)extra; SOCKET desc; #else @@ -2140,17 +2147,17 @@ static Class tcpPortClass; #endif GSTcpHandle *handle; - NSDebugMLLog(@"NSPort", @"received %s event %p on 0x%x", - type == ET_RPORT ? "read" : "write", extra, self); + NSDebugMLLog(@"NSPort", @"received %s event on 0x%x", + type == ET_RPORT ? "read" : "write", self); -#if defined(__MINGW__) +#if defined(__MINGW32__) if (event == eventListener) #else if (desc == listener) #endif { struct sockaddr_in sockAddr; - socklen_t size = sizeof(sockAddr); + unsigned size = sizeof(sockAddr); desc = accept(listener, (struct sockaddr*)&sockAddr, &size); if (desc == INVALID_SOCKET) @@ -2163,7 +2170,7 @@ static Class tcpPortClass; setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status, sizeof(status)); -#if defined(__MINGW__) +#if defined(__MINGW32__) // reset associated event with new socket WSAEventSelect(desc, eventListener, 0); #endif @@ -2184,7 +2191,7 @@ static Class tcpPortClass; else { M_LOCK(myLock); -#if defined(__MINGW__) +#if defined(__MINGW32__) desc = (SOCKET)NSMapGet(events, (void*)(uintptr_t)event); #endif handle = (GSTcpHandle*)NSMapGet(handles, (void*)(uintptr_t)desc); @@ -2194,7 +2201,7 @@ static Class tcpPortClass; { const char *t; -#if defined(__MINGW__) +#if defined(__MINGW32__) if (type == ET_HANDLE) t = "winhandle"; #else if (type == ET_RDESC) t = "rdesc"; @@ -2245,7 +2252,6 @@ static Class tcpPortClass; */ - (void) removeHandle: (GSTcpHandle*)handle { - IF_NO_GC(RETAIN(self);) M_LOCK(myLock); if ([handle sendPort] == self) { @@ -2258,7 +2264,7 @@ static Class tcpPortClass; * been retained - we must therefore release this port since the * handle no longer uses it. */ - IF_NO_GC(RELEASE(self);) + AUTORELEASE(self); } handle->sendPort = nil; } @@ -2267,7 +2273,7 @@ static Class tcpPortClass; handle->recvPort = nil; } NSMapRemove(handles, (void*)(uintptr_t)[handle descriptor]); -#if defined(__MINGW__) +#if defined(__MINGW32__) NSMapRemove(events, (void*)(uintptr_t)[handle eventHandle]); #endif if (((int) listener) < 0 && NSCountMapTable(handles) == 0) @@ -2275,7 +2281,6 @@ static Class tcpPortClass; [self invalidate]; } M_UNLOCK(myLock); - RELEASE(self); } /* @@ -2286,16 +2291,16 @@ static Class tcpPortClass; * the start can be written directly without having to copy data to another * buffer etc. */ -- (unsigned int) reservedSpaceLength +- (NSUInteger) reservedSpaceLength { return sizeof(GSPortItemHeader) + sizeof(GSPortMsgHeader); } - (BOOL) sendBeforeDate: (NSDate*)when - msgid: (int)msgId + msgid: (NSInteger)msgId components: (NSMutableArray*)components from: (NSPort*)receivingPort - reserved: (unsigned)length + reserved: (NSUInteger)length { BOOL sent = NO; GSTcpHandle *h; @@ -2377,7 +2382,6 @@ static Class tcpPortClass; * a maximum of NETBLOCK bytes. This is to try to get a single, * efficient write operation if possible. */ - c = [components count]; for (i = 1; i < c; i++) { id o = [components objectAtIndex: i]; diff --git a/Source/NSSocketPortNameServer.m b/Source/NSSocketPortNameServer.m index 768cf738c..e5625e600 100644 --- a/Source/NSSocketPortNameServer.m +++ b/Source/NSSocketPortNameServer.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -24,32 +24,31 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSSocketPortNameServer_IVARS 1 -#import "Foundation/NSData.h" -#import "Foundation/NSByteOrder.h" -#import "Foundation/NSException.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSTask.h" -#import "GNUstepBase/NSTask+GNUstepBase.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSTimer.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSPortNameServer.h" +#include "config.h" +#include "Foundation/NSString.h" +#include "Foundation/NSData.h" +#include "Foundation/NSByteOrder.h" +#include "Foundation/NSException.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSFileHandle.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSPort.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSSet.h" +#include "Foundation/NSHost.h" +#include "Foundation/NSTask.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSTimer.h" +#include "Foundation/NSPathUtilities.h" +#include "Foundation/NSPortNameServer.h" +#include "Foundation/NSDebug.h" -#import "GSPortPrivate.h" +#include "GSPortPrivate.h" -#ifdef __MINGW__ +#ifdef __MINGW32__ #include #include #else @@ -187,7 +186,9 @@ typedef enum { [self close]; if (launchCmd == nil) { - launchCmd = [NSTask launchPathForTool: @"gdomap"]; + launchCmd = RETAIN([[NSSearchPathForDirectoriesInDomains( + GSToolsDirectory, NSSystemDomainMask, YES) objectAtIndex: 0] + stringByAppendingPathComponent: @"gdomap"]); } if (state == GSPC_LOPEN && launchCmd != nil) { @@ -197,10 +198,6 @@ typedef enum { NSLog(@"NSSocketPortNameServer attempting to start gdomap on local host\n" @"This will take a few seconds.\n" @"Trying to launch gdomap from %@ or a machine/operating-system subdirectory.\n" -#if !defined(GDOMAP_PORT_OVERRIDE) -@"On systems other than mswindows, this will only work if the gdomap program\n" -@"was installed setuid to root.\n" -#endif @"It is recommended that you start up gdomap at login time or (better) when\n" @"your computer is started instead.", [launchCmd stringByDeletingLastPathComponent]); @@ -656,7 +653,6 @@ typedef enum { [serverLock lock]; NS_DURING { - GSPortCom *tmp; NSData *dat; [com startListNameServers]; @@ -683,9 +679,7 @@ typedef enum { [NSException raise: NSInternalInconsistencyException format: @"failed to get list of name servers"]; } - tmp = com; - com = nil; - RELEASE(tmp); + RELEASE(com); } NS_HANDLER { @@ -1083,8 +1077,6 @@ typedef enum { NS_DURING { - GSPortCom *tmp; - com = [GSPortCom new]; [com startPortUnregistration: 0 withName: name]; while ([limit timeIntervalSinceNow] > 0 && [com isActive] == YES) @@ -1134,9 +1126,7 @@ typedef enum { } } } - tmp = com; - com = nil; - RELEASE(tmp); + RELEASE(com); } NS_HANDLER { @@ -1198,7 +1188,7 @@ typedef enum { NSMutableSet *known = (NSMutableSet*)NSMapGet(_portMap, port); NSString *name; - IF_NO_GC(RETAIN(known);) + RETAIN(known); while ((name = [known anyObject]) != nil) { if ([self removePortForName: name] == NO) diff --git a/Source/NSSortDescriptor.m b/Source/NSSortDescriptor.m index f272fdab2..ebd0546ac 100644 --- a/Source/NSSortDescriptor.m +++ b/Source/NSSortDescriptor.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,25 +16,22 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include "Foundation/NSSortDescriptor.h" -#define EXPOSE_NSSortDescriptor_IVARS 1 -#import "Foundation/NSSortDescriptor.h" +#include "Foundation/NSBundle.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSException.h" +#include "Foundation/NSKeyValueCoding.h" +#include "Foundation/NSString.h" -#import "Foundation/NSBundle.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSException.h" -#import "Foundation/NSKeyValueCoding.h" - -#import "GNUstepBase/GSObjCRuntime.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GSPrivate.h" +#include "GNUstepBase/GSObjCRuntime.h" +#include "GSPrivate.h" @implementation NSSortDescriptor @@ -82,9 +79,9 @@ [super dealloc]; } -- (NSUInteger) hash +- (unsigned) hash { - const char *sel = sel_getName(_selector); + const char *sel = GSNameFromSelector(_selector); return _ascending + GSPrivateHash(sel, strlen(sel), 16, YES) + [_key hash]; } @@ -137,7 +134,7 @@ { return NO; } - if (!sel_isEqual(((NSSortDescriptor*)other)->_selector, _selector)) + if (!sel_eq(((NSSortDescriptor*)other)->_selector, _selector)) { return NO; } @@ -311,23 +308,11 @@ SortRange(id *objects, NSRange range, id *descriptors, if (count > 1 && numDescriptors > 0) { id descriptors[numDescriptors]; - NSArray *a; GS_BEGINIDBUF(objects, count); + NSArray *a; [self getObjects: objects]; - if ([sortDescriptors isProxy]) - { - unsigned i; - - for (i = 0; i < numDescriptors; i++) - { - descriptors[i] = [sortDescriptors objectAtIndex: i]; - } - } - else - { - [sortDescriptors getObjects: descriptors]; - } + [sortDescriptors getObjects: descriptors]; SortRange(objects, NSMakeRange(0, count), descriptors, numDescriptors); a = [[NSArray alloc] initWithObjects: objects count: count]; [self setArray: a]; @@ -348,19 +333,7 @@ SortRange(id *objects, NSRange range, id *descriptors, { GS_BEGINIDBUF(descriptors, dCount); - if ([sortDescriptors isProxy]) - { - unsigned i; - - for (i = 0; i < dCount; i++) - { - descriptors[i] = [sortDescriptors objectAtIndex: i]; - } - } - else - { - [sortDescriptors getObjects: descriptors]; - } + [sortDescriptors getObjects: descriptors]; SortRange(_contents_array, NSMakeRange(0, _count), descriptors, dCount); GS_ENDIDBUF(); diff --git a/Source/NSSpellServer.m b/Source/NSSpellServer.m index f97ac9705..1ffd258f6 100644 --- a/Source/NSSpellServer.m +++ b/Source/NSSpellServer.m @@ -12,7 +12,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -21,28 +21,24 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" -#define EXPOSE_NSSpellServer_IVARS 1 -#import "Foundation/NSSpellServer.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSConnection.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSException.h" -#import "Foundation/NSSet.h" - -NSString *const NSGrammarRange = @"NSGrammarRange"; -NSString *const NSGrammarUserDescription = @"NSGrammarUserDescription"; -NSString *const NSGrammarCorrections = @"NSGrammarCorrections"; +#include "config.h" +#include "Foundation/NSSpellServer.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSUserDefaults.h" +#include "Foundation/NSPathUtilities.h" +#include "Foundation/NSConnection.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSString.h" +#include "Foundation/NSException.h" +#include "Foundation/NSSet.h" /* User dictionary location */ static NSString *GNU_UserDictionariesDir = @"Dictionaries"; @@ -122,7 +118,7 @@ GSSpellServerName(NSString *vendor, NSString *language) connection = [[NSConnection alloc] init]; if (connection) { - IF_NO_GC(RETAIN(connection);) + RETAIN(connection); [connection setRootObject: self]; result = [connection registerName: serverName]; } @@ -150,7 +146,7 @@ GSSpellServerName(NSString *vendor, NSString *language) - (void) setDelegate: (id)anObject { /* FIXME - we should not retain the delegate ! */ - IF_NO_GC(RETAIN(anObject);) + RETAIN(anObject); ASSIGN(_delegate, anObject); } @@ -301,28 +297,6 @@ GSSpellServerName(NSString *vendor, NSString *language) result = [word isEqualToString: dictWord]; } } - - return result; -} - -// Checking User Dictionaries -/** -Checks to see if the word is in the user's dictionary. The user dictionary -is a set of words learned by the spell service for that particular user -combined with the set of ignored words in the current document. -*/ -- (BOOL) isWordInUserDictionaries: (NSString *)word - caseSensitive: (BOOL)flag -{ - NSSet *userDict = [self _openUserDictionary: _currentLanguage]; - BOOL result = NO; - - if (userDict) - { - result = [self _isWord: word - inDictionary: userDict - caseSensitive: flag]; - } if (result == NO && _ignoredWords) { @@ -346,6 +320,27 @@ combined with the set of ignored words in the current document. } } } + + return result; +} + +// Checking User Dictionaries +/** +Checks to see if the word is in the user's dictionary. The user dictionary +is a set of words learned by the spell service for that particular user. +*/ +- (BOOL) isWordInUserDictionaries: (NSString *)word + caseSensitive: (BOOL)flag +{ + NSSet *userDict = [self _openUserDictionary: _currentLanguage]; + BOOL result = NO; + + if (userDict) + { + result = [self _isWord: word + inDictionary: userDict + caseSensitive: flag]; + } return result; } @@ -424,7 +419,7 @@ combined with the set of ignored words in the current document. - (NSRange) _findMisspelledWordInString: (NSString *)stringToCheck language: (NSString *)language ignoredWords: (NSArray *)ignoredWords - wordCount: (int32_t *)wordCount + wordCount: (int *)wordCount countOnly: (BOOL)countOnly { NSRange r = NSMakeRange(0,0); @@ -473,19 +468,4 @@ combined with the set of ignored words in the current document. return words; } -- (NSArray *) spellServer: (NSSpellServer *)sender - suggestCompletionsForPartialWordRange: (NSRange)range - inString: (NSString *)string - language: (NSString *)language -{ - return nil; // FIXME -} - -- (NSRange) spellServer: (NSSpellServer *)sender - checkGrammarInString: (NSString *)stringToCheck - language: (NSString *)language - details: (NSArray **)details -{ - return NSMakeRange(0, 0); // FIXME -} @end diff --git a/Source/NSString.m b/Source/NSString.m index b15b6470b..6317227cf 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -13,7 +13,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -43,37 +43,41 @@ Limited choice of default encodings. */ -#import "common.h" +/* Needed for visiblity of fwprintf prototype. */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include "config.h" #include #include -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSCalendarDate.h" -#import "Foundation/NSDecimal.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSCharacterSet.h" -#import "Foundation/NSException.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSPortCoder.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSRange.h" -#import "Foundation/NSException.h" -#import "Foundation/NSData.h" -#import "Foundation/NSBundle.h" -#import "Foundation/NSURL.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/FoundationErrors.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSString.h" +#include "Foundation/NSCalendarDate.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSCharacterSet.h" +#include "Foundation/NSException.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSPortCoder.h" +#include "Foundation/NSPathUtilities.h" +#include "Foundation/NSRange.h" +#include "Foundation/NSException.h" +#include "Foundation/NSData.h" +#include "Foundation/NSBundle.h" +#include "Foundation/NSURL.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSUserDefaults.h" +#include "Foundation/NSDebug.h" // For private method _decodePropertyListForKey: -#import "Foundation/NSKeyedArchiver.h" -#import "GNUstepBase/GSMime.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSMutableString+GNUstepBase.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GSPrivate.h" +#include "Foundation/NSKeyedArchiver.h" +#include "GNUstepBase/GSMime.h" +#include "GSPrivate.h" +#include #include #ifdef HAVE_UNISTD_H #include @@ -83,16 +87,9 @@ #include #include -#ifdef HAVE_MALLOC_H -#include -#endif -#ifdef HAVE_ALLOCA_H -#include -#endif +#include "GNUstepBase/Unicode.h" -#import "GNUstepBase/Unicode.h" - -#import "GSPrivate.h" +#include "GSPrivate.h" extern BOOL GSScanDouble(unichar*, unsigned, double*); @@ -103,6 +100,12 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*); @end @class GSMutableArray; @class GSMutableDictionary; +@class NSImmutableString; +@interface NSImmutableString : NSObject // Help the compiler +@end +@class GSImmutableString; +@interface GSImmutableString : NSObject // Help the compiler +@end /* * Cache classes and method implementations for speed. @@ -327,13 +330,8 @@ pathSepString() } /* - * Find the end of 'root' sequence in a string. Characters before this + * Find end of 'root' sequence in a string. Characters before this * point in the string cannot be split into path components/extensions. - * This usage of the term 'root' is slightly different from the usual in - * that it includes the first part of any relative path. The more normal - * usage of 'root' elsewhere is to indicate the first part of an absolute - * path. - * Possible roots are - * * '/' absolute root on unix @@ -341,6 +339,7 @@ pathSepString() * 'C:/' absolute root for a drive on windows * 'C:' if entire path is 'C:' or 'C:relativepath' * '//host/share/' absolute root for a host and share on windows + * '//host/share' if entire path is '//host/share' * '~/' home directory for user * '~' if entire path is '~' * '~username/' home directory for user @@ -429,12 +428,13 @@ static unsigned rootOf(NSString *s, unsigned l) */ if (range.location > pos) { - /* OK ... we have the '//host/share/' - * format, so this is a valid UNC path. - */ root = NSMaxRange(range); } } + else + { + root = l; + } } } } @@ -445,7 +445,7 @@ static unsigned rootOf(NSString *s, unsigned l) } -/* Convert a high-low surrogate pair into Unicode scalar code-poNSInteger*/ +/* Convert a high-low surrogate pair into Unicode scalar code-point */ static inline uint32_t surrogatePairValue(unichar high, unichar low) { @@ -465,6 +465,7 @@ static const unichar byteOrderMarkSwapped = 0xFFFE; #ifdef HAVE_REGISTER_PRINTF_FUNCTION #include #include +#include /* , with libc-5.3.9 thinks this flag PRINTF_ATSIGN_VA_LIST should be 0, but for me, with libc-5.0.9, @@ -480,11 +481,7 @@ static const unichar byteOrderMarkSwapped = 0xFFFE; #if ! PRINTF_ATSIGN_VA_LIST static int -arginfo_func (const struct printf_info *info, size_t n, int *argtypes -#if defined(HAVE_REGISTER_PRINTF_SPECIFIER) -, int *size -#endif -) +arginfo_func (const struct printf_info *info, size_t n, int *argtypes) { *argtypes = PA_POINTER; return 1; @@ -518,8 +515,6 @@ handle_printf_atsign (FILE *stream, string_object = *((id*) ptr); #endif string_object = [string_object description]; - -#if HAVE_WIDE_PRINTF_FUNCTION if (info->wide) { if (sizeof(wchar_t) == 4) @@ -544,7 +539,6 @@ handle_printf_atsign (FILE *stream, } } else -#endif /* HAVE_WIDE_PRINTF_FUNCTION */ { len = fprintf(stream, "%*s", (info->left ? - info->width : info->width), @@ -590,8 +584,9 @@ handle_printf_atsign (FILE *stream, NSNonRetainedObjectMapValueCallBacks, 0); placeholderLock = [NSLock new]; -#if defined(HAVE_REGISTER_PRINTF_SPECIFIER) - if (register_printf_specifier ('@', handle_printf_atsign, +#ifdef HAVE_REGISTER_PRINTF_FUNCTION + if (register_printf_function ('@', + handle_printf_atsign, #if PRINTF_ATSIGN_VA_LIST 0)) #else @@ -599,16 +594,7 @@ handle_printf_atsign (FILE *stream, #endif [NSException raise: NSGenericException format: @"register printf handling of %%@ failed"]; -#elif defined(HAVE_REGISTER_PRINTF_FUNCTION) - if (register_printf_function ('@', handle_printf_atsign, -#if PRINTF_ATSIGN_VA_LIST - 0)) -#else - arginfo_func)) -#endif - [NSException raise: NSGenericException - format: @"register printf handling of %%@ failed"]; -#endif +#endif /* HAVE_REGISTER_PRINTF_FUNCTION */ } } @@ -680,7 +666,7 @@ handle_printf_atsign (FILE *stream, */ + (Class) constantStringClass { - return [@"" class]; + return [NXConstantString class]; } /** @@ -707,7 +693,7 @@ handle_printf_atsign (FILE *stream, * Create a string of unicode characters. */ + (id) stringWithCharacters: (const unichar*)chars - length: (NSUInteger)length + length: (unsigned int)length { NSString *obj; @@ -741,9 +727,6 @@ handle_printf_atsign (FILE *stream, { NSString *obj; - if (NULL == byteString) - [NSException raise: NSInvalidArgumentException - format: @"[NSString+stringWithCString:encoding:]: NULL cString"]; obj = [self allocWithZone: NSDefaultMallocZone()]; obj = [obj initWithCString: byteString encoding: encoding]; return AUTORELEASE(obj); @@ -755,7 +738,7 @@ handle_printf_atsign (FILE *stream, * (Characters will be converted to unicode representation internally.) */ + (id) stringWithCString: (const char*)byteString - length: (NSUInteger)length + length: (unsigned int)length { NSString *obj; @@ -765,16 +748,12 @@ handle_printf_atsign (FILE *stream, } /** - * Create a string based on the given UTF-8 string, null-terminated.
- * Raises NSInvalidArgumentException if given NULL pointer. + * Create a string based on the given UTF-8 string, null-terminated. */ + (id) stringWithUTF8String: (const char *)bytes { NSString *obj; - if (NULL == bytes) - [NSException raise: NSInvalidArgumentException - format: @"[NSString+stringWithUTF8String:]: NULL cString"]; obj = [self allocWithZone: NSDefaultMallocZone()]; obj = [obj initWithUTF8String: bytes]; return AUTORELEASE(obj); @@ -794,36 +773,6 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } -/** - * Load contents of file at path into a new string using the - * -initWithContentsOfFile:usedEncoding:error: method. - */ -+ (id) stringWithContentsOfFile: (NSString *)path - usedEncoding: (NSStringEncoding*)enc - error: (NSError**)error -{ - NSString *obj; - - obj = [self allocWithZone: NSDefaultMallocZone()]; - obj = [obj initWithContentsOfFile: path usedEncoding: enc error: error]; - return AUTORELEASE(obj); -} - -/** - * Load contents of file at path into a new string using the - * -initWithContentsOfFile:encoding:error: method. - */ -+ (id) stringWithContentsOfFile: (NSString*)path - encoding: (NSStringEncoding)enc - error: (NSError**)error -{ - NSString *obj; - - obj = [self allocWithZone: NSDefaultMallocZone()]; - obj = [obj initWithContentsOfFile: path encoding: enc error: error]; - return AUTORELEASE(obj); -} - /** * Load contents of given URL into a new string. Will interpret contents as * containing direct unicode if it begins with the unicode byte order mark, @@ -838,28 +787,6 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } -+ (id) stringWithContentsOfURL: (NSURL*)url - usedEncoding: (NSStringEncoding*)enc - error: (NSError**)error -{ - NSString *obj; - - obj = [self allocWithZone: NSDefaultMallocZone()]; - obj = [obj initWithContentsOfURL: url usedEncoding: enc error: error]; - return AUTORELEASE(obj); -} - -+ (id) stringWithContentsOfURL: (NSURL*)url - encoding: (NSStringEncoding)enc - error: (NSError**)error -{ - NSString *obj; - - obj = [self allocWithZone: NSDefaultMallocZone()]; - obj = [obj initWithContentsOfURL: url encoding: enc error: error]; - return AUTORELEASE(obj); -} - /** * Creates a new string using C printf-style formatting. First argument should * be a constant format string, like '@"float val = %f"', remaining @@ -925,7 +852,7 @@ handle_printf_atsign (FILE *stream, * is released and nil is returned. */ - (id) initWithBytes: (const void*)bytes - length: (NSUInteger)length + length: (unsigned int)length encoding: (NSStringEncoding)encoding { if (length == 0) @@ -937,13 +864,8 @@ handle_printf_atsign (FILE *stream, } else { - void *buf; + void *buf = NSZoneMalloc(GSObjCZone(self), length); -#if GS_WITH_GC - buf = NSAllocateCollectable(length, 0); -#else - buf = NSZoneMalloc([self zone], length); -#endif memcpy(buf, bytes, length); return [self initWithBytesNoCopy: buf length: length @@ -968,7 +890,7 @@ handle_printf_atsign (FILE *stream, * this initialiser in order to have all other functionality.

*/ - (id) initWithBytesNoCopy: (void*)bytes - length: (NSUInteger)length + length: (unsigned int)length encoding: (NSStringEncoding)encoding freeWhenDone: (BOOL)flag { @@ -982,7 +904,7 @@ handle_printf_atsign (FILE *stream, * this instance is deallocated.

*/ - (id) initWithCharactersNoCopy: (unichar*)chars - length: (NSUInteger)length + length: (unsigned int)length freeWhenDone: (BOOL)flag { return [self initWithBytesNoCopy: chars @@ -996,7 +918,7 @@ handle_printf_atsign (FILE *stream, * of null bytes. Copies the string and frees copy when deallocated.

*/ - (id) initWithCharacters: (const unichar*)chars - length: (NSUInteger)length + length: (unsigned int)length { return [self initWithBytes: chars length: length * sizeof(unichar) @@ -1010,7 +932,7 @@ handle_printf_atsign (FILE *stream, * when this instance is deallocated.

*/ - (id) initWithCStringNoCopy: (char*)byteString - length: (NSUInteger)length + length: (unsigned int)length freeWhenDone: (BOOL)flag { return [self initWithBytesNoCopy: byteString @@ -1028,7 +950,7 @@ handle_printf_atsign (FILE *stream, encoding: (NSStringEncoding)encoding { return [self initWithBytes: byteString - length: (byteString ? strlen(byteString) : 0) + length: strlen(byteString) encoding: encoding]; } @@ -1037,7 +959,7 @@ handle_printf_atsign (FILE *stream, * presence of null bytes. Characters converted to unicode based on the * default C encoding. Copies the string.

*/ -- (id) initWithCString: (const char*)byteString length: (NSUInteger)length +- (id) initWithCString: (const char*)byteString length: (unsigned int)length { return [self initWithBytes: byteString length: length @@ -1065,7 +987,7 @@ handle_printf_atsign (FILE *stream, if (length > 0) { - unichar *s = NSZoneMalloc([self zone], sizeof(unichar)*length); + unichar *s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*length); [string getCharacters: s range: ((NSRange){0, length})]; self = [self initWithCharactersNoCopy: s @@ -1134,7 +1056,7 @@ handle_printf_atsign (FILE *stream, arguments: (va_list)argList { unsigned char buf[2048]; - GSStr f; + GSStr_t f; unichar fbuf[1024]; unichar *fmt = fbuf; size_t len; @@ -1148,7 +1070,7 @@ handle_printf_atsign (FILE *stream, len = [format length]; if (len >= 1024) { - fmt = NSZoneMalloc(NSDefaultMallocZone(), (len+1)*sizeof(unichar)); + fmt = objc_malloc((len+1)*sizeof(unichar)); } [format getCharacters: fmt range: ((NSRange){0, len})]; fmt[len] = '\0'; @@ -1157,49 +1079,44 @@ handle_printf_atsign (FILE *stream, * Now set up 'f' as a GSMutableString object whose initial buffer is * allocated on the stack. The GSPrivateFormat function can write into it. */ - f = (GSStr)alloca(class_getInstanceSize(GSMutableStringClass)); - object_setClass(f, GSMutableStringClass); - f->_zone = NSDefaultMallocZone(); - f->_contents.c = buf; - f->_capacity = sizeof(buf); - f->_count = 0; - f->_flags.wide = 0; - f->_flags.owned = 0; - f->_flags.unused = 0; - f->_flags.hash = 0; - GSPrivateFormat(f, fmt, argList, locale); - GSPrivateStrExternalize(f); + f.isa = GSMutableStringClass; + f._zone = NSDefaultMallocZone(); + f._contents.c = buf; + f._capacity = sizeof(buf); + f._count = 0; + f._flags.wide = 0; + f._flags.free = 0; + GSPrivateFormat(&f, fmt, argList, locale); + GSPrivateStrExternalize(&f); if (fmt != fbuf) { - NSZoneFree(NSDefaultMallocZone(), fmt); + objc_free(fmt); } /* - * Don't use noCopy because f->_contents.u may be memory on the stack, - * and even if it wasn't f->_capacity may be greater than f->_count so + * Don't use noCopy because f._contents.u may be memory on the stack, + * and even if it wasn't f._capacity may be greater than f._count so * we could be wasting quite a bit of space. Better to accept a * performance hit due to copying data (and allocating/deallocating * the temporary buffer) for large strings. For most strings, the * on-stack memory will have been used, so we will get better performance. */ -#if HAVE_WIDE_PRINTF_FUNCTION - if (f->_flags.wide == 1) + if (f._flags.wide == 1) { - self = [self initWithCharacters: f->_contents.u length: f->_count]; + self = [self initWithCharacters: f._contents.u length: f._count]; } else -#endif /* HAVE_WIDE_PRINTF_FUNCTION */ { - self = [self initWithCString: (char*)f->_contents.c length: f->_count]; + self = [self initWithCString: (char*)f._contents.c length: f._count]; } /* * If the string had to grow beyond the initial buffer size, we must * release any allocated memory. */ - if (f->_flags.owned == 1) + if (f._flags.free == 1) { - NSZoneFree(f->_zone, f->_contents.c); + NSZoneFree(f._zone, f._contents.c); } return self; } @@ -1248,14 +1165,14 @@ handle_printf_atsign (FILE *stream, d = [[NSDataClass alloc] initWithContentsOfFile: path]; if (d == nil) { - DESTROY(self); + RELEASE(self); return nil; } len = [d length]; if (len == 0) { RELEASE(d); - DESTROY(self); + RELEASE(self); return @""; } data_bytes = [d bytes]; @@ -1285,112 +1202,6 @@ handle_printf_atsign (FILE *stream, return self; } -/** - *

Initialises the receiver with the contents of the file at path. - *

- *

Invokes [NSData-initWithContentsOfFile:] to read the file, then - * examines the data to infer its encoding type, and converts the - * data to a string using -initWithData:encoding: - *

- *

The encoding to use is determined as follows ... if the data begins - * with the 16-bit unicode Byte Order Marker, then it is assumed to be - * unicode data in the appropriate ordering and converted as such.
- * If it begins with a UTF8 representation of the BOM, the UTF8 encoding - * is used.
- * Otherwise, the default C String encoding is used. - *

- *

Releases the receiver and returns nil if the file could not be read - * and converted to a string. - *

- */ -- (id) initWithContentsOfFile: (NSString*)path - usedEncoding: (NSStringEncoding*)enc - error: (NSError**)error -{ - NSData *d; - unsigned int len; - const unsigned char *data_bytes; - - d = [[NSDataClass alloc] initWithContentsOfFile: path]; - if (d == nil) - { - DESTROY(self); - return nil; - } - *enc = _DefaultStringEncoding; - len = [d length]; - if (len == 0) - { - RELEASE(d); - DESTROY(self); - return @""; - } - data_bytes = [d bytes]; - if ((data_bytes != NULL) && (len >= 2)) - { - const unichar *data_ucs2chars = (const unichar *) data_bytes; - if ((data_ucs2chars[0] == byteOrderMark) - || (data_ucs2chars[0] == byteOrderMarkSwapped)) - { - /* somebody set up us the BOM! */ - *enc = NSUnicodeStringEncoding; - } - else if (len >= 3 - && data_bytes[0] == 0xEF - && data_bytes[1] == 0xBB - && data_bytes[2] == 0xBF) - { - *enc = NSUTF8StringEncoding; - } - } - self = [self initWithData: d encoding: *enc]; - RELEASE(d); - if (self == nil) - { - if (error != 0) - { - *error = [NSError errorWithDomain: NSCocoaErrorDomain - code: NSFileReadCorruptFileError - userInfo: nil]; - } - } - return self; -} - -- (id) initWithContentsOfFile: (NSString*)path - encoding: (NSStringEncoding)enc - error: (NSError**)error -{ - NSData *d; - unsigned int len; - - d = [[NSDataClass alloc] initWithContentsOfFile: path]; - if (d == nil) - { - DESTROY(self); - return nil; - } - len = [d length]; - if (len == 0) - { - RELEASE(d); - DESTROY(self); - return @""; - } - self = [self initWithData: d encoding: enc]; - RELEASE(d); - if (self == nil) - { - if (error != 0) - { - *error = [NSError errorWithDomain: NSCocoaErrorDomain - code: NSFileReadCorruptFileError - userInfo: nil]; - } - } - return self; -} - /** *

Initialises the receiver with the contents of the given URL. *

@@ -1419,12 +1230,12 @@ handle_printf_atsign (FILE *stream, if (d == nil) { NSWarnMLog(@"Contents of URL '%@' are not readable", url); - DESTROY(self); + RELEASE(self); return nil; } if (len == 0) { - DESTROY(self); + RELEASE(self); return @""; } data_bytes = [d bytes]; @@ -1452,95 +1263,11 @@ handle_printf_atsign (FILE *stream, return self; } -- (id) initWithContentsOfURL: (NSURL*)url - usedEncoding: (NSStringEncoding*)enc - error: (NSError**)error -{ - NSData *d; - unsigned int len; - const unsigned char *data_bytes; - - d = [NSDataClass dataWithContentsOfURL: url]; - if (d == nil) - { - DESTROY(self); - return nil; - } - *enc = _DefaultStringEncoding; - len = [d length]; - if (len == 0) - { - DESTROY(self); - return @""; - } - data_bytes = [d bytes]; - if ((data_bytes != NULL) && (len >= 2)) - { - const unichar *data_ucs2chars = (const unichar *) data_bytes; - if ((data_ucs2chars[0] == byteOrderMark) - || (data_ucs2chars[0] == byteOrderMarkSwapped)) - { - /* somebody set up us the BOM! */ - *enc = NSUnicodeStringEncoding; - } - else if (len >= 3 - && data_bytes[0] == 0xEF - && data_bytes[1] == 0xBB - && data_bytes[2] == 0xBF) - { - *enc = NSUTF8StringEncoding; - } - } - self = [self initWithData: d encoding: *enc]; - if (self == nil) - { - if (error != 0) - { - *error = [NSError errorWithDomain: NSCocoaErrorDomain - code: NSFileReadCorruptFileError - userInfo: nil]; - } - } - return self; -} - -- (id) initWithContentsOfURL: (NSURL*)url - encoding: (NSStringEncoding)enc - error: (NSError**)error -{ - NSData *d; - unsigned int len; - - d = [NSDataClass dataWithContentsOfURL: url]; - if (d == nil) - { - DESTROY(self); - return nil; - } - len = [d length]; - if (len == 0) - { - DESTROY(self); - return @""; - } - self = [self initWithData: d encoding: enc]; - if (self == nil) - { - if (error != 0) - { - *error = [NSError errorWithDomain: NSCocoaErrorDomain - code: NSFileReadCorruptFileError - userInfo: nil]; - } - } - return self; -} - /** * Returns the number of Unicode characters in this string, including the * individual characters of composed character sequences, */ -- (NSUInteger) length +- (unsigned int) length { [self subclassResponsibility: _cmd]; return 0; @@ -1552,7 +1279,7 @@ handle_printf_atsign (FILE *stream, * Returns unicode character at index. unichar is an unsigned * short. Thus, a 16-bit character is returned. */ -- (unichar) characterAtIndex: (NSUInteger)index +- (unichar) characterAtIndex: (unsigned int)index { [self subclassResponsibility: _cmd]; return (unichar)0; @@ -1581,11 +1308,11 @@ handle_printf_atsign (FILE *stream, { unsigned l = [self length]; unsigned i; - unichar (*caiImp)(NSString*, SEL, NSUInteger); + unichar (*caiImp)(NSString*, SEL, unsigned int); GS_RANGE_CHECK(aRange, l); - caiImp = (unichar (*)(NSString*,SEL,NSUInteger)) + caiImp = (unichar (*)(NSString*,SEL,unsigned)) [self methodForSelector: caiSel]; for (i = 0; i < aRange.length; i++) @@ -1597,7 +1324,7 @@ handle_printf_atsign (FILE *stream, /** * Constructs a new ASCII string which is a representation of the receiver * in which characters are escaped where necessary in order to produce a - * version of the string legal for inclusion within a URL.
+ * legal URL.
* The original string is converted to bytes using the specified encoding * and then those bytes are escaped unless they correspond to 'legal' * ASCII characters. The byte values escaped are any below 32 and any @@ -1622,11 +1349,11 @@ handle_printf_atsign (FILE *stream, { unsigned char *src = (unsigned char*)[data bytes]; unsigned int slen = [data length]; - unsigned char *dst; + NSMutableData *d = [[NSMutableData alloc] initWithLength: slen * 3]; + unsigned char *dst = (unsigned char*)[d mutableBytes]; unsigned int spos = 0; unsigned int dpos = 0; - dst = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), slen * 3); while (spos < slen) { unsigned char c = src[spos++]; @@ -1648,11 +1375,10 @@ handle_printf_atsign (FILE *stream, dst[dpos++] = c; } } - s = [[NSString alloc] initWithBytes: dst - length: dpos - encoding: NSASCIIStringEncoding]; - NSZoneFree(NSDefaultMallocZone(), dst); - IF_NO_GC([s autorelease];) + [d setLength: dpos]; + s = [[NSString alloc] initWithData: d encoding: NSASCIIStringEncoding]; + RELEASE(d); + AUTORELEASE(s); } return s; } @@ -1680,7 +1406,7 @@ handle_printf_atsign (FILE *stream, { unsigned len = [self length]; unsigned otherLength = [aString length]; - NSZone *z = [self zone]; + NSZone *z = GSObjCZone(self); unichar *s = NSZoneMalloc(z, (len+otherLength)*sizeof(unichar)); NSString *tmp; @@ -1693,48 +1419,6 @@ handle_printf_atsign (FILE *stream, // Dividing Strings into Substrings -/** - *

Returns an array of [NSString]s representing substrings of this string - * that are separated by characters in the set (which must not be nil). - * If there are no occurrences of separator, the whole string is - * returned. If string begins or ends with separator, empty strings will - * be returned for those positions.

- */ -- (NSArray *) componentsSeparatedByCharactersInSet: (NSCharacterSet *)separator -{ - NSRange search; - NSRange complete; - NSRange found; - NSMutableArray *array; - - if (separator == nil) - [NSException raise: NSInvalidArgumentException format: @"separator is nil"]; - - array = [NSMutableArray array]; - search = NSMakeRange (0, [self length]); - complete = search; - found = [self rangeOfCharacterFromSet: separator]; - while (found.length != 0) - { - NSRange current; - - current = NSMakeRange (search.location, - found.location - search.location); - [array addObject: [self substringWithRange: current]]; - - search = NSMakeRange (found.location + found.length, - complete.length - found.location - found.length); - found = [self rangeOfCharacterFromSet: separator - options: 0 - range: search]; - } - // Add the last search string range - [array addObject: [self substringWithRange: search]]; - - // FIXME: Need to make mutable array into non-mutable array? - return array; -} - /** *

Returns an array of [NSString]s representing substrings of this string * that are separated by separator (which itself is never returned in the @@ -1774,28 +1458,6 @@ handle_printf_atsign (FILE *stream, return array; } -- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace - withString: (NSString*)by - options: (NSStringCompareOptions)opts - range: (NSRange)searchRange -{ - id copy = [self mutableCopy]; - [copy replaceOccurrencesOfString: replace - withString: by - options: opts - range: searchRange]; - return [copy makeImmutableCopyOnFail: NO]; -} -- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace - withString: (NSString*)by -{ - return [self - stringByReplacingOccurrencesOfString: replace - withString: by - options: 0 - range: NSMakeRange(0, [self length])]; -} - /** * Returns a substring of the receiver from character at the specified * index to the end of the string.
@@ -1805,7 +1467,7 @@ handle_printf_atsign (FILE *stream, * If the supplied index is greater than or equal to the length of the * receiver an exception is raised. */ -- (NSString*) substringFromIndex: (NSUInteger)index +- (NSString*) substringFromIndex: (unsigned int)index { return [self substringWithRange: ((NSRange){index, [self length]-index})]; } @@ -1818,9 +1480,9 @@ handle_printf_atsign (FILE *stream, * If the supplied index is greater than the length of the receiver * an exception is raised. */ -- (NSString*) substringToIndex: (NSUInteger)index +- (NSString*) substringToIndex: (unsigned int)index { - return [self substringWithRange: ((NSRange){0,index})]; + return [self substringWithRange: ((NSRange){0,index})];; } /** @@ -1848,7 +1510,7 @@ handle_printf_atsign (FILE *stream, if (aRange.length == 0) return @""; - buf = NSZoneMalloc([self zone], sizeof(unichar)*aRange.length); + buf = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*aRange.length); [self getCharacters: buf range: aRange]; ret = [[NSStringClass allocWithZone: NSDefaultMallocZone()] initWithCharactersNoCopy: buf length: aRange.length freeWhenDone: YES]; @@ -1882,7 +1544,7 @@ handle_printf_atsign (FILE *stream, * string). */ - (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet - options: (NSUInteger)mask + options: (unsigned int)mask { NSRange all = NSMakeRange(0, [self length]); @@ -1901,7 +1563,7 @@ handle_printf_atsign (FILE *stream, * string). Search only carried out within aRange. */ - (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet - options: (NSUInteger)mask + options: (unsigned int)mask range: (NSRange)aRange { unsigned int i; @@ -1909,7 +1571,7 @@ handle_printf_atsign (FILE *stream, unsigned int stop; int step; NSRange range; - unichar (*cImp)(id, SEL, NSUInteger); + unichar (*cImp)(id, SEL, unsigned int); BOOL (*mImp)(id, SEL, unichar); i = [self length]; @@ -1926,7 +1588,7 @@ handle_printf_atsign (FILE *stream, range.location = NSNotFound; range.length = 0; - cImp = (unichar(*)(id,SEL,NSUInteger)) + cImp = (unichar(*)(id,SEL,unsigned int)) [self methodForSelector: caiSel]; mImp = (BOOL(*)(id,SEL,unichar)) [aSet methodForSelector: cMemberSel]; @@ -1945,11 +1607,6 @@ handle_printf_atsign (FILE *stream, return range; } -- (NSRange) rangeOfComposedCharacterSequencesForRange: (NSRange)range -{ - return NSMakeRange(0, 0); // FIXME -} - /** * Invokes -rangeOfString:options: with no options. */ @@ -1967,7 +1624,7 @@ handle_printf_atsign (FILE *stream, * set to the range of the whole of the receiver. */ - (NSRange) rangeOfString: (NSString*)string - options: (NSUInteger)mask + options: (unsigned int)mask { NSRange all = NSMakeRange(0, [self length]); @@ -2001,24 +1658,15 @@ handle_printf_atsign (FILE *stream, * string. Options should be OR'd together using '|'. */ - (NSRange) rangeOfString: (NSString *)aString - options: (NSUInteger)mask + options: (unsigned int)mask range: (NSRange)aRange { - GS_RANGE_CHECK(aRange, [self length]); if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"range of nil"]; return strRangeNsNs(self, aString, mask, aRange); } -- (NSRange) rangeOfString: (NSString *)aString - options: (NSStringCompareOptions)mask - range: (NSRange)searchRange - locale: (NSLocale *)locale -{ - return NSMakeRange(0, 0); // FIXME -} - -- (NSUInteger) indexOfString: (NSString *)substring +- (unsigned int) indexOfString: (NSString *)substring { NSRange range = {0, [self length]}; @@ -2026,8 +1674,8 @@ handle_printf_atsign (FILE *stream, return range.length ? range.location : NSNotFound; } -- (NSUInteger) indexOfString: (NSString*)substring - fromIndex: (NSUInteger)index +- (unsigned int) indexOfString: (NSString*)substring + fromIndex: (unsigned int)index { NSRange range = {index, [self length] - index}; @@ -2042,18 +1690,18 @@ handle_printf_atsign (FILE *stream, * character sequence anIndex (note indices start from 0), returns the full * range of this sequence. */ -- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (NSUInteger)anIndex +- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (unsigned int)anIndex { unsigned start; unsigned end; unsigned length = [self length]; unichar ch; - unichar (*caiImp)(NSString*, SEL, NSUInteger); + unichar (*caiImp)(NSString*, SEL, unsigned int); NSCharacterSet *nbSet = [NSCharacterSet nonBaseCharacterSet]; if (anIndex >= length) [NSException raise: NSRangeException format:@"Invalid location."]; - caiImp = (unichar (*)(NSString*,SEL,NSUInteger)) + caiImp = (unichar (*)(NSString*,SEL,unsigned)) [self methodForSelector: caiSel]; for (start = anIndex; start > 0; start--) @@ -2093,7 +1741,7 @@ handle_printf_atsign (FILE *stream, * sequences may be used to express the same character.

*/ - (NSComparisonResult) compare: (NSString*)aString - options: (NSUInteger)mask + options: (unsigned int)mask { return [self compare: aString options: mask range: ((NSRange){0, [self length]})]; @@ -2110,10 +1758,9 @@ handle_printf_atsign (FILE *stream, */ // xxx Should implement full POSIX.2 collate - (NSComparisonResult) compare: (NSString*)aString - options: (NSUInteger)mask + options: (unsigned int)mask range: (NSRange)aRange { - GS_RANGE_CHECK(aRange, [self length]); if (aString == nil) [NSException raise: NSInvalidArgumentException format: @"compare with nil"]; return strCompNsNs(self, aString, mask, aRange); @@ -2154,7 +1801,7 @@ handle_printf_atsign (FILE *stream, } if (anObject != nil && GSObjCIsInstance(anObject) == YES) { - Class c = object_getClass(anObject); + Class c = GSObjCClass(anObject); if (c != nil) { @@ -2186,7 +1833,7 @@ handle_printf_atsign (FILE *stream, * for other purposes in a bitfield in the concrete string subclasses, so we * must not use the full unsigned integer. */ -- (NSUInteger) hash +- (unsigned int) hash { unsigned ret = 0; unsigned len = [self length]; @@ -2244,7 +1891,7 @@ handle_printf_atsign (FILE *stream, * the same character. */ - (NSString*) commonPrefixWithString: (NSString*)aString - options: (NSUInteger)mask + options: (unsigned int)mask { if (mask & NSLiteralSearch) { @@ -2287,12 +1934,12 @@ handle_printf_atsign (FILE *stream, } else { - unichar (*scImp)(NSString*, SEL, NSUInteger); - unichar (*ocImp)(NSString*, SEL, NSUInteger); + unichar (*scImp)(NSString*, SEL, unsigned int); + unichar (*ocImp)(NSString*, SEL, unsigned int); void (*sgImp)(NSString*, SEL, unichar*, NSRange) = 0; void (*ogImp)(NSString*, SEL, unichar*, NSRange) = 0; - NSRange (*srImp)(NSString*, SEL, NSUInteger) = 0; - NSRange (*orImp)(NSString*, SEL, NSUInteger) = 0; + NSRange (*srImp)(NSString*, SEL, unsigned int) = 0; + NSRange (*orImp)(NSString*, SEL, unsigned int) = 0; BOOL gotRangeImps = NO; BOOL gotFetchImps = NO; NSRange sRange; @@ -2307,9 +1954,9 @@ handle_printf_atsign (FILE *stream, if (!oLength) return IMMUTABLE(aString); - scImp = (unichar (*)(NSString*,SEL,NSUInteger)) + scImp = (unichar (*)(NSString*,SEL,unsigned)) [self methodForSelector: caiSel]; - ocImp = (unichar (*)(NSString*,SEL,NSUInteger)) + ocImp = (unichar (*)(NSString*,SEL,unsigned)) [aString methodForSelector: caiSel]; while ((sIndex < sLength) && (oIndex < oLength)) @@ -2388,8 +2035,8 @@ handle_printf_atsign (FILE *stream, */ - (NSRange) lineRangeForRange: (NSRange)aRange { - NSUInteger startIndex; - NSUInteger lineEndIndex; + unsigned startIndex; + unsigned lineEndIndex; [self getLineStart: &startIndex end: &lineEndIndex @@ -2420,14 +2067,14 @@ handle_printf_atsign (FILE *stream, * arguments to be null pointers (in which case no value is returned in that * argument). */ -- (void) getLineStart: (NSUInteger*)startIndex - end: (NSUInteger*)lineEndIndex - contentsEnd: (NSUInteger*)contentsEndIndex +- (void) getLineStart: (unsigned int *)startIndex + end: (unsigned int *)lineEndIndex + contentsEnd: (unsigned int *)contentsEndIndex forRange: (NSRange)aRange { unichar thischar; unsigned start, end, len, termlen; - unichar (*caiImp)(NSString*, SEL, NSUInteger); + unichar (*caiImp)(NSString*, SEL, unsigned int); len = [self length]; GS_RANGE_CHECK(aRange, len); @@ -2544,18 +2191,6 @@ handle_printf_atsign (FILE *stream, } } -- (void) getParagraphStart: (NSUInteger *)startPtr - end: (NSUInteger *)parEndPtr - contentsEnd: (NSUInteger *)contentsEndPtr - forRange: (NSRange)range -{ - // FIXME - [self getLineStart: startPtr - end: parEndPtr - contentsEnd: contentsEndPtr - forRange: range]; -} - // Changing Case /** @@ -2578,7 +2213,7 @@ handle_printf_atsign (FILE *stream, if (whitespaceBitmapRep == NULL) setupWhitespace(); - s = NSZoneMalloc([self zone], sizeof(unichar)*len); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len); [self getCharacters: s range: ((NSRange){0, len})]; while (count < len) { @@ -2642,7 +2277,7 @@ handle_printf_atsign (FILE *stream, { return IMMUTABLE(self); } - s = NSZoneMalloc([self zone], sizeof(unichar)*len); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len); [self getCharacters: s range: ((NSRange){0, len})]; for (count = start.location; count < len; count++) { @@ -2679,7 +2314,7 @@ handle_printf_atsign (FILE *stream, { return IMMUTABLE(self); } - s = NSZoneMalloc([self zone], sizeof(unichar)*len); + s = NSZoneMalloc(GSObjCZone(self), sizeof(unichar)*len); [self getCharacters: s range: ((NSRange){0, len})]; for (count = start.location; count < len; count++) { @@ -2742,7 +2377,7 @@ handle_printf_atsign (FILE *stream, } m = [d mutableCopy]; [m appendBytes: "" length: 1]; - IF_NO_GC([m autorelease];) + AUTORELEASE(m); return (const char*)[m bytes]; } @@ -2778,7 +2413,7 @@ handle_printf_atsign (FILE *stream, { [m appendBytes: "" length: 1]; } - IF_NO_GC([m autorelease];) + AUTORELEASE(m); return (const char*)[m bytes]; } @@ -2787,7 +2422,7 @@ handle_printf_atsign (FILE *stream, * specified encoding (without adding a nul character terminator).
* Returns 0 if the conversion is not possible. */ -- (NSUInteger) lengthOfBytesUsingEncoding: (NSStringEncoding)encoding +- (unsigned) lengthOfBytesUsingEncoding: (NSStringEncoding)encoding { NSData *d; @@ -2800,7 +2435,7 @@ handle_printf_atsign (FILE *stream, * specified encoding (without adding a nul character terminator). This may * be larger than the actual number of bytes needed. */ -- (NSUInteger) maximumLengthOfBytesUsingEncoding: (NSStringEncoding)encoding +- (unsigned) maximumLengthOfBytesUsingEncoding: (NSStringEncoding)encoding { if (encoding == NSUnicodeStringEncoding) return [self length] * 2; @@ -2825,7 +2460,7 @@ handle_printf_atsign (FILE *stream, allowLossyConversion: YES]; m = [d mutableCopy]; [m appendBytes: "" length: 1]; - IF_NO_GC([m autorelease];) + AUTORELEASE(m); return (const char*)[m bytes]; } @@ -2843,7 +2478,7 @@ handle_printf_atsign (FILE *stream, allowLossyConversion: NO]; m = [d mutableCopy]; [m appendBytes: "" length: 1]; - IF_NO_GC([m autorelease];) + AUTORELEASE(m); return (const char*)[m bytes]; } @@ -2853,7 +2488,7 @@ handle_printf_atsign (FILE *stream, * information loss, the results are unpredictable. Check * -canBeConvertedToEncoding: first. */ -- (NSUInteger) cStringLength +- (unsigned int) cStringLength { NSData *d; @@ -2878,7 +2513,7 @@ handle_printf_atsign (FILE *stream, * Use -getCString:maxLength:encoding: instead. */ - (void) getCString: (char*)buffer - maxLength: (NSUInteger)maxLength + maxLength: (unsigned int)maxLength { [self getCString: buffer maxLength: maxLength range: ((NSRange){0, [self length]}) @@ -2904,7 +2539,7 @@ handle_printf_atsign (FILE *stream, * twelve if NSUnicodeStringEncoding is requested. */ - (BOOL) getCString: (char*)buffer - maxLength: (NSUInteger)maxLength + maxLength: (unsigned int)maxLength encoding: (NSStringEncoding)encoding { if (encoding == NSUnicodeStringEncoding) @@ -2949,7 +2584,7 @@ handle_printf_atsign (FILE *stream, * Use -getCString:maxLength:encoding: instead. */ - (void) getCString: (char*)buffer - maxLength: (NSUInteger)maxLength + maxLength: (unsigned int)maxLength range: (NSRange)aRange remainingRange: (NSRange*)leftoverRange { @@ -2970,47 +2605,24 @@ handle_printf_atsign (FILE *stream, // Getting Numeric Values -- (BOOL) boolValue -{ - unsigned length = [self length]; - - if (length > 0) - { - unsigned index; - SEL sel = @selector(characterAtIndex:); - unichar (*imp)() = (unichar (*)())[self methodForSelector: sel]; - - for (index = 0; index < length; index++) - { - unichar c = (*imp)(self, sel, index); - - if (c > 'y') - { - break; - } - if (strchr("123456789yYtT", c) != 0) - { - return YES; - } - if (!isspace(c) && c != '0' && c != '-' && c != '+') - { - break; - } - } - } - return NO; -} +// xxx Should we use NSScanner here ? /** - * Returns the string's content as a decimal.
- * Undocumented feature of Aplle Foundation. + * If the string consists of the words 'true' or 'yes' (case insensitive) + * or begins with a non-zero numeric value, return YES, otherwise return + * NO. */ -- (NSDecimal) decimalValue +- (BOOL) boolValue { - NSDecimal result; - - NSDecimalFromString(&result, self, nil); - return result; + if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame) + { + return YES; + } + if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame) + { + return YES; + } + return [self intValue] != 0 ? YES : NO; } /** @@ -3057,16 +2669,6 @@ handle_printf_atsign (FILE *stream, return atoi([self lossyCString]); } -- (NSInteger) integerValue -{ - return atol([self lossyCString]); -} - -- (long long) longLongValue -{ - return atoll([self lossyCString]); -} - // Working With Encodings /** @@ -3191,7 +2793,7 @@ handle_printf_atsign (FILE *stream, */ if (len >= 4096) { - u = NSZoneMalloc(NSDefaultMallocZone(), len * sizeof(unichar)); + u = objc_malloc(len * sizeof(unichar)); } [self getCharacters: u]; if (flag == NO) @@ -3213,7 +2815,7 @@ handle_printf_atsign (FILE *stream, } if (u != buf) { - NSZoneFree(NSDefaultMallocZone(), u); + objc_free(u); } } return d; @@ -3237,10 +2839,10 @@ handle_printf_atsign (FILE *stream, return NSUnicodeStringEncoding; } -- (NSUInteger) completePathIntoString: (NSString**)outputName - caseSensitive: (BOOL)flag - matchesIntoArray: (NSArray**)outputArray - filterTypes: (NSArray*)filterTypes +- (unsigned int) completePathIntoString: (NSString**)outputName + caseSensitive: (BOOL)flag + matchesIntoArray: (NSArray**)outputArray + filterTypes: (NSArray*)filterTypes { NSString *basePath = [self stringByDeletingLastPathComponent]; NSString *lastComp = [self lastPathComponent]; @@ -3310,7 +2912,7 @@ handle_printf_atsign (FILE *stream, static NSFileManager *fm = nil; -#if defined(__MINGW__) +#if defined(__MINGW32__) - (const GSNativeChar*) fileSystemRepresentation { if (fm == nil) @@ -3321,7 +2923,7 @@ static NSFileManager *fm = nil; } - (BOOL) getFileSystemRepresentation: (GSNativeChar*)buffer - maxLength: (NSUInteger)size + maxLength: (unsigned int)size { const unichar *ptr; unsigned i; @@ -3362,7 +2964,7 @@ static NSFileManager *fm = nil; } - (BOOL) getFileSystemRepresentation: (GSNativeChar*)buffer - maxLength: (NSUInteger)size + maxLength: (unsigned int)size { const char* ptr; @@ -3431,18 +3033,6 @@ static NSFileManager *fm = nil; return [self substringWithRange: ((NSRange){i, l-i})]; } -- (NSRange) paragraphRangeForRange: (NSRange)range -{ - NSUInteger startIndex; - NSUInteger endIndex; - - [self getParagraphStart: &startIndex - end: &endIndex - contentsEnd: NULL - forRange: range]; - return NSMakeRange(startIndex, endIndex - startIndex); -} - - (NSString*) pathExtension { NSRange range; @@ -3865,9 +3455,9 @@ static NSFileManager *fm = nil; * as required). The first character from padString to be appended * is specified by padIndex.
*/ -- (NSString*) stringByPaddingToLength: (NSUInteger)newLength +- (NSString*) stringByPaddingToLength: (unsigned int)newLength withString: (NSString*)padString - startingAtIndex: (NSUInteger)padIndex + startingAtIndex: (unsigned int)padIndex { unsigned length = [self length]; unsigned padLength; @@ -4040,23 +3630,19 @@ static NSFileManager *fm = nil; - (NSString*) stringByResolvingSymlinksInPath { -#if defined(__MINGW__) +#if defined(__MINGW32__) return IMMUTABLE(self); #else - #ifndef PATH_MAX - #define PATH_MAX 1024 - /* Don't use realpath unless we know we have the correct path size limit */ - #ifdef HAVE_REALPATH - #undef HAVE_REALPATH + #ifndef MAX_PATH + #define MAX_PATH 1024 #endif - #endif - char newBuf[PATH_MAX]; + char newBuf[MAX_PATH]; #ifdef HAVE_REALPATH if (realpath([self fileSystemRepresentation], newBuf) == 0) return IMMUTABLE(self); #else - char extra[PATH_MAX]; + char extra[MAX_PATH]; char *dest; const char *name = [self fileSystemRepresentation]; const char *start; @@ -4065,7 +3651,7 @@ static NSFileManager *fm = nil; if (name[0] != '/') { - if (!getcwd(newBuf, PATH_MAX)) + if (!getcwd(newBuf, MAX_PATH)) { return IMMUTABLE(self); /* Couldn't get directory. */ } @@ -4123,7 +3709,7 @@ static NSFileManager *fm = nil; { *dest++ = '/'; } - if (&dest[len] >= &newBuf[PATH_MAX]) + if (&dest[len] >= &newBuf[MAX_PATH]) { return IMMUTABLE(self); /* Resolved name too long. */ } @@ -4137,20 +3723,20 @@ static NSFileManager *fm = nil; } if (S_ISLNK(st.st_mode)) { - char buf[PATH_MAX]; + char buf[MAX_PATH]; if (++num_links > MAXSYMLINKS) { return IMMUTABLE(self); /* Too many links. */ } - n = readlink(newBuf, buf, PATH_MAX); + n = readlink(newBuf, buf, MAX_PATH); if (n < 0) { return IMMUTABLE(self); /* Couldn't resolve. */ } buf[n] = '\0'; - if ((n + strlen(end)) >= PATH_MAX) + if ((n + strlen(end)) >= MAX_PATH) { return IMMUTABLE(self); /* Path too long. */ } @@ -4207,14 +3793,14 @@ static NSFileManager *fm = nil; } return [[NSFileManager defaultManager] stringWithFileSystemRepresentation: newBuf length: strlen(newBuf)]; -#endif /* (__MINGW__) */ +#endif /* (__MINGW32__) */ } - (NSString*) stringByStandardizingPath { NSMutableString *s; NSRange r; - unichar (*caiImp)(NSString*, SEL, NSUInteger); + unichar (*caiImp)(NSString*, SEL, unsigned int); unsigned int l = [self length]; unichar c; unsigned root; @@ -4267,20 +3853,14 @@ static NSFileManager *fm = nil; } r.length = l - r.location; } - // Remove trailing ('.') as long as it's preceeded by a path separator. - if (l > root && l > 1 && (*caiImp)(s, caiSel, l-1) == '.' - && pathSepMember((*caiImp)(s, caiSel, l-2)) == YES) - { - l--; - [s deleteCharactersInRange: NSMakeRange(l, 1)]; - } // Condense ('/./') sequences. r = (NSRange){root, l-root}; while ((r = [s rangeOfString: @"." options: 0 range: r]).length == 1) { if (r.location > 0 && pathSepMember((*caiImp)(s, caiSel, r.location-1)) == YES - && pathSepMember((*caiImp)(s, caiSel, r.location+1)) == YES) + && (NSMaxRange(r) == l + || pathSepMember((*caiImp)(s, caiSel, NSMaxRange(r))) == YES)) { r.length++; [s deleteCharactersInRange: r]; @@ -4318,7 +3898,7 @@ static NSFileManager *fm = nil; * For absolute paths, we must resolve symbolic links or (on MINGW) * remove '/../' sequences and their matching parent directories. */ -#if defined(__MINGW__) +#if defined(__MINGW32__) /* Condense `/../' */ r = (NSRange){root, l-root}; while ((r = [s rangeOfString: @".." options: 0 range: r]).length == 2) @@ -4383,7 +3963,7 @@ static NSFileManager *fm = nil; } if (length > 0) { - unichar (*caiImp)(NSString*, SEL, NSUInteger); + unichar (*caiImp)(NSString*, SEL, unsigned int); BOOL (*mImp)(id, SEL, unichar); unichar letter; @@ -4429,7 +4009,7 @@ static NSFileManager *fm = nil; if (len > 0) { unsigned int count = 0; - unichar (*caiImp)(NSString*, SEL, NSUInteger); + unichar (*caiImp)(NSString*, SEL, unsigned int); caiImp = (unichar (*)())[self methodForSelector: caiSel]; while (count < len) @@ -4488,7 +4068,7 @@ static NSFileManager *fm = nil; */ if (c == pathSepChar()) { -#if defined(__MINGW__) +#if defined(__MINGW32__) if (GSPathHandlingUnix() == YES) { return YES; @@ -4648,7 +4228,7 @@ static NSFileManager *fm = nil; * IGNORE the locale.

*/ - (NSComparisonResult) compare: (NSString *)string - options: (NSUInteger)mask + options: (unsigned int)mask range: (NSRange)compareRange locale: (NSDictionary *)dict { @@ -4701,79 +4281,13 @@ static NSFileManager *fm = nil; } /** - * Writes contents out to file at filename, using the default C string encoding - * unless this would result in information loss, otherwise straight unicode. - * The 'atomically' option if set will cause the contents to be - * written to a temp file, which is then closed and renamed to filename. Thus, - * an incomplete file at filename should never result.
- * If there is a problem and error is not NULL, the cause of the problem is - * returned in *error. - */ -- (BOOL) writeToFile: (NSString*)path - atomically: (BOOL)atomically - encoding: (NSStringEncoding)enc - error: (NSError**)error -{ - id d = [self dataUsingEncoding: enc]; - - if (d == nil) - { - if (error != 0) - { - *error = [NSError errorWithDomain: NSCocoaErrorDomain - code: NSFileWriteInapplicableStringEncodingError - userInfo: nil]; - } - return NO; - } - return [d writeToFile: path - options: atomically ? NSAtomicWrite : 0 - error: error]; -} - -/** - * Writes contents out to url, using the default C string encoding - * unless this would result in information loss, otherwise straight unicode. - * See [NSURLHandle-writeData:] on which URL types are supported. - * The 'atomically' option is only heeded if the URL is a - * file:// URL; see -writeToFile:atomically: .
- * If there is a problem and error is not NULL, the cause of the problem is - * returned in *error. - */ -- (BOOL) writeToURL: (NSURL*)url - atomically: (BOOL)atomically - encoding: (NSStringEncoding)enc - error: (NSError**)error -{ - id d = [self dataUsingEncoding: enc]; - - if (d == nil) - { - d = [self dataUsingEncoding: NSUnicodeStringEncoding]; - } - if (d == nil) - { - if (error != 0) - { - *error = [NSError errorWithDomain: NSCocoaErrorDomain - code: NSFileWriteInapplicableStringEncodingError - userInfo: nil]; - } - return NO; - } - return [d writeToURL: url - options: atomically ? NSAtomicWrite : 0 - error: error]; -} - -/** - * Writes contents out to url, using the default C string encoding + * Writes contents out to anURL, using the default C string encoding * unless this would result in information loss, otherwise straight unicode. * See [NSURLHandle-writeData:] on which URL types are supported. * The 'atomically' option is only heeded if the URL is a * file:// URL; see -writeToFile:atomically: . */ -- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)atomically +- (BOOL) writeToURL: (NSURL*)anURL atomically: (BOOL)atomically { id d = [self dataUsingEncoding: _DefaultStringEncoding]; @@ -4781,7 +4295,7 @@ static NSFileManager *fm = nil; { d = [self dataUsingEncoding: NSUnicodeStringEncoding]; } - return [d writeToURL: url atomically: atomically]; + return [d writeToURL: anURL atomically: atomically]; } /* NSCopying Protocol */ @@ -4815,7 +4329,7 @@ static NSFileManager *fm = nil; { unsigned count = [self length]; - [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; + [aCoder encodeValueOfObjCType: @encode(unsigned int) at: &count]; if (count > 0) { NSStringEncoding enc = NSUnicodeStringEncoding; @@ -4837,18 +4351,8 @@ static NSFileManager *fm = nil; { if ([aCoder allowsKeyedCoding]) { - NSString *string = nil; - - if ([aCoder containsValueForKey: @"NS.string"]) - { - string = (NSString*)[(NSKeyedUnarchiver*)aCoder - _decodePropertyListForKey: @"NS.string"]; - } - else if ([aCoder containsValueForKey: @"NS.bytes"]) - { - string = (NSString*)[(NSKeyedUnarchiver*)aCoder - decodeObjectForKey: @"NS.bytes"]; - } + NSString *string = (NSString*)[(NSKeyedUnarchiver*)aCoder + _decodePropertyListForKey: @"NS.string"]; self = [self initWithString: string]; } @@ -4856,7 +4360,7 @@ static NSFileManager *fm = nil; { unsigned count; - [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; + [aCoder decodeValueOfObjCType: @encode(unsigned int) at: &count]; if (count > 0) { @@ -4867,7 +4371,7 @@ static NSFileManager *fm = nil; #if GS_WITH_GC zone = GSAtomicMallocZone(); #else - zone = [self zone]; + zone = GSObjCZone(self); #endif if (enc == NSUnicodeStringEncoding) @@ -4886,11 +4390,7 @@ static NSFileManager *fm = nil; { unsigned char *chars; -#if GS_WITH_GC - chars = NSAllocateCollectable(count+1, 0); -#else chars = NSZoneMalloc(zone, count+1); -#endif [aCoder decodeArrayOfObjCType: @encode(unsigned char) count: count at: chars]; @@ -4902,7 +4402,7 @@ static NSFileManager *fm = nil; } else { - self = [self initWithBytesNoCopy: (char *)"" + self = [self initWithBytesNoCopy: "" length: 0 encoding: NSASCIIStringEncoding freeWhenDone: NO]; @@ -4965,12 +4465,7 @@ static NSFileManager *fm = nil; * in XML format, the standard SGML comment sequences are used. *

*

See the documentation for [NSPropertyListSerialization] for more - * information on what a property list is. - *

- *

If the string cannot be parsed as a normal property list format, - * this method also tries to parse it as 'strings file' format (see the - * -propertyListFromStringsFileFormat method). - *

+ * information on what a property list is.

*/ - (id) propertyList { @@ -4994,22 +4489,8 @@ static NSFileManager *fm = nil; if (result == nil) { - extern id GSPropertyListFromStringsFormat(NSString *string); - - NS_DURING - { - result = GSPropertyListFromStringsFormat(self); - } - NS_HANDLER - { - result = nil; - } - NS_ENDHANDLER - if (result == nil) - { - [NSException raise: NSGenericException - format: @"Parse failed - %@", error]; - } + [NSException raise: NSGenericException + format: @"Parse failed - %@", error]; } return result; } @@ -5073,7 +4554,7 @@ static NSFileManager *fm = nil; /** * Constructs an empty string with initial buffer size of capacity. */ -+ (NSMutableString*) stringWithCapacity: (NSUInteger)capacity ++ (NSMutableString*) stringWithCapacity: (unsigned int)capacity { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithCapacity: capacity]); @@ -5084,7 +4565,7 @@ static NSFileManager *fm = nil; */ // Inefficient implementation. + (id) stringWithCharacters: (const unichar*)characters - length: (NSUInteger)length + length: (unsigned int)length { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithCharacters: characters length: length]); @@ -5118,7 +4599,7 @@ static NSFileManager *fm = nil; * (Characters will be converted to unicode representation internally.) */ + (id) stringWithCString: (const char*)byteString - length: (NSUInteger)length + length: (unsigned int)length { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithCString: byteString length: length]); @@ -5144,14 +4625,14 @@ static NSFileManager *fm = nil; * and needs to be re-implemented in subclasses in order to have all * other initialisers work. */ -- (id) initWithCapacity: (NSUInteger)capacity +- (id) initWithCapacity: (unsigned int)capacity { self = [self init]; return self; } - (id) initWithCharactersNoCopy: (unichar*)chars - length: (NSUInteger)length + length: (unsigned int)length freeWhenDone: (BOOL)flag { if ((self = [self initWithCapacity: length]) != nil && length > 0) @@ -5169,7 +4650,7 @@ static NSFileManager *fm = nil; } - (id) initWithCStringNoCopy: (char*)chars - length: (NSUInteger)length + length: (unsigned int)length freeWhenDone: (BOOL)flag { if ((self = [self initWithCapacity: length]) != nil && length > 0) @@ -5233,7 +4714,7 @@ static NSFileManager *fm = nil; /** * Modifies this instance by inserting aString at loc. */ -- (void) insertString: (NSString*)aString atIndex: (NSUInteger)loc +- (void) insertString: (NSString*)aString atIndex: (unsigned int)loc { NSRange range = {loc, 0}; [self replaceCharactersInRange: range withString: aString]; @@ -5260,45 +4741,35 @@ static NSFileManager *fm = nil; * Raises NSRangeException if part of searchRange is beyond the end * of the receiver. */ -- (NSUInteger) replaceOccurrencesOfString: (NSString*)replace - withString: (NSString*)by - options: (NSUInteger)opts - range: (NSRange)searchRange +- (unsigned int) replaceOccurrencesOfString: (NSString*)replace + withString: (NSString*)by + options: (unsigned int)opts + range: (NSRange)searchRange { NSRange range; unsigned int count = 0; - GSRSFunc func; - if ([replace isKindOfClass: NSStringClass] == NO) + if (replace == nil) { [NSException raise: NSInvalidArgumentException - format: @"%@ bad search string", NSStringFromSelector(_cmd)]; + format: @"%@ nil search string", NSStringFromSelector(_cmd)]; } - if ([by isKindOfClass: NSStringClass] == NO) + if (by == nil) { [NSException raise: NSInvalidArgumentException - format: @"%@ bad replace string", NSStringFromSelector(_cmd)]; + format: @"%@ nil replace string", NSStringFromSelector(_cmd)]; } - if (NSMaxRange(searchRange) > [self length]) - { - [NSException raise: NSInvalidArgumentException - format: @"%@ bad search range", NSStringFromSelector(_cmd)]; - } - func = GSPrivateRangeOfString(self, replace); - range = (*func)(self, replace, opts, searchRange); + range = [self rangeOfString: replace options: opts range: searchRange]; if (range.length > 0) { unsigned byLen = [by length]; - SEL sel; - void (*imp)(id, SEL, NSRange, NSString*); - sel = @selector(replaceCharactersInRange:withString:); - imp = (void(*)(id, SEL, NSRange, NSString*))[self methodForSelector: sel]; do { count++; - (*imp)(self, sel, range, by); + [self replaceCharactersInRange: range + withString: by]; if ((opts & NSBackwardsSearch) == NSBackwardsSearch) { searchRange.length = range.location - searchRange.location; @@ -5312,7 +4783,9 @@ static NSFileManager *fm = nil; searchRange.length = newEnd - searchRange.location; } - range = (*func)(self, replace, opts, searchRange); + range = [self rangeOfString: replace + options: opts + range: searchRange]; } while (range.length > 0); } @@ -5330,3 +4803,31 @@ static NSFileManager *fm = nil; @end + +/** + * GNUstep specific (non-standard) additions to the NSMutableString class. + * The methods in this category are not available in MacOS-X + */ +@implementation NSMutableString (GNUstep) + +/** + * Returns a proxy to the receiver which will allow access to the + * receiver as an NSString, but which will not allow any of the + * extra NSMutableString methods to be used. You can use this method + * to provide other code with read-only access to a mutable string + * you own. + */ +- (NSString*) immutableProxy +{ + if ([self isKindOfClass: GSMutableStringClass]) + { + return AUTORELEASE([[GSImmutableString alloc] initWithString: self]); + } + else + { + return AUTORELEASE([[NSImmutableString alloc] initWithString: self]); + } +} + +@end + diff --git a/Source/NSTask.m b/Source/NSTask.m index 0f86c87fb..5f8cb72fd 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,29 +25,29 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSTask_IVARS 1 -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSBundle.h" -#import "Foundation/NSCharacterSet.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSTask.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSTimer.h" -#import "Foundation/NSLock.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GSPrivate.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSObject.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSBundle.h" +#include "Foundation/NSCharacterSet.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSEnumerator.h" +#include "Foundation/NSString.h" +#include "Foundation/NSException.h" +#include "Foundation/NSFileHandle.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSTask.h" +#include "Foundation/NSTimer.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSDebug.h" +#include "GSPrivate.h" #include #ifdef HAVE_UNISTD_H @@ -84,7 +84,6 @@ #include #endif - /* * If we are on a streams based system, we need to include stropts.h * for definitions needed to set up slave pseudo-terminal stream. @@ -104,7 +103,6 @@ #define NOFILE 256 #endif - @interface NSBundle(Private) + (NSString *) _absolutePathOfExecutable: (NSString *)path; + (NSString*) _gnustep_target_cpu; @@ -120,12 +118,12 @@ static BOOL hadChildSignal = NO; static void handleSignal(int sig) { hadChildSignal = YES; -#ifndef __MINGW__ +#ifndef __MINGW32__ signal(SIGCHLD, handleSignal); #endif } -#ifdef __MINGW__ +#ifdef __MINGW32__ @interface NSConcreteWindowsTask : NSTask { @public @@ -229,6 +227,7 @@ pty_slave(const char* name) @interface NSTask (Private) - (NSString *) _fullLaunchPath; +- (void) _sendNotification; - (void) _collectChild; - (void) _terminatedChild: (int)status; @end @@ -259,34 +258,12 @@ pty_slave(const char* name) if (tasksLock == nil) { tasksLock = [NSRecursiveLock new]; - /* The activeTasks map contains the NSTask objects corresponding - * to running subtasks, and retains them until the subprocess - * actually terminates. - * The previous implementation stored non-retained objects and - * the -finalize method removed them from the table, but this - * caused a thread safety issue even though table access was - * lock protected: - * If thread t1 releases the task at the same time that the subtask - * dies and is 'reaped' by t2, then there is a window such - * that t1 can enter -dealloc while t2 is dealing with - * subprocess termination notification. - * So t1 completes deallocation while t2 performs - * the notification, and then t2 tries to release the object... - * t1: enter dealloc - * t2: lookup task in activeTasks and retain/autorelease it - * t2: create NSNotification (retaining task) - * t2: post notification - * t1: remove task from activeTasks - * t1: release memory occupied by task object. - * t2: complete notification ... attempt to release task object - * but it's already deallocated. - */ activeTasks = NSCreateMapTable(NSIntMapKeyCallBacks, - NSObjectMapValueCallBacks, 0); + NSNonOwnedPointerMapValueCallBacks, 0); } [gnustep_global_lock unlock]; -#ifndef __MINGW__ +#ifndef __MINGW32__ signal(SIGCHLD, handleSignal); #endif } @@ -308,14 +285,16 @@ pty_slave(const char* name) return AUTORELEASE(task); } -- (void) finalize +- (void) gcFinalize { - return; + [tasksLock lock]; + NSMapRemove(activeTasks, (void*)(intptr_t)_taskId); + [tasksLock unlock]; } - (void) dealloc { - [self finalize]; + [self gcFinalize]; RELEASE(_arguments); RELEASE(_environment); RELEASE(_launchPath); @@ -379,7 +358,7 @@ pty_slave(const char* name) return; } -#ifndef __MINGW__ +#ifndef __MINGW32__ #ifdef HAVE_KILLPG killpg(_taskId, SIGINT); #else @@ -447,7 +426,7 @@ pty_slave(const char* name) [NSException raise: NSInvalidArgumentException format: @"NSTask - task has not yet launched"]; } -#ifndef __MINGW__ +#ifndef __MINGW32__ #ifdef HAVE_KILLPG killpg(_taskId, SIGCONT); #else @@ -638,7 +617,7 @@ pty_slave(const char* name) [NSException raise: NSInvalidArgumentException format: @"NSTask - task has not yet launched"]; } -#ifndef __MINGW__ +#ifndef __MINGW32__ #ifdef HAVE_KILLPG killpg(_taskId, SIGSTOP); #else @@ -670,7 +649,7 @@ pty_slave(const char* name) } _hasTerminated = YES; -#ifndef __MINGW__ +#ifndef __MINGW32__ #ifdef HAVE_KILLPG killpg(_taskId, SIGTERM); #else @@ -771,7 +750,7 @@ pty_slave(const char* name) full_path = [arch_path stringByAppendingPathComponent: libs]; lpath = [full_path stringByAppendingPathComponent: prog]; -#ifdef __MINGW__ +#ifdef __MINGW32__ if ([mgr isExecutableFileAtPath: lpath] == NO && [mgr isExecutableFileAtPath: (lpath = [lpath stringByAppendingPathExtension: @"exe"])] == NO) @@ -780,7 +759,7 @@ pty_slave(const char* name) #endif { lpath = [arch_path stringByAppendingPathComponent: prog]; -#ifdef __MINGW__ +#ifdef __MINGW32__ if ([mgr isExecutableFileAtPath: lpath] == NO && [mgr isExecutableFileAtPath: (lpath = [lpath stringByAppendingPathExtension: @"exe"])] == NO) @@ -789,7 +768,7 @@ pty_slave(const char* name) #endif { lpath = [base_path stringByAppendingPathComponent: prog]; -#ifdef __MINGW__ +#ifdef __MINGW32__ if ([mgr isExecutableFileAtPath: lpath] == NO && [mgr isExecutableFileAtPath: (lpath = [lpath stringByAppendingPathExtension: @"exe"])] == NO) @@ -808,7 +787,7 @@ pty_slave(const char* name) } if (lpath != nil) { -#ifdef __MINGW__ +#ifdef __MINGW32__ if ([mgr isExecutableFileAtPath: lpath] == NO && [mgr isExecutableFileAtPath: (lpath = [lpath stringByAppendingPathExtension: @"exe"])] @@ -836,7 +815,7 @@ pty_slave(const char* name) } lpath = [lpath stringByStandardizingPath]; } -#ifdef __MINGW__ +#ifdef __MINGW32__ /** We need this to be native windows format, and some of the standardisation * above may have left unix style separators in the string. */ @@ -900,20 +879,8 @@ pty_slave(const char* name) return val; } -- (void) _collectChild +- (void) _sendNotification { - [self subclassResponsibility: _cmd]; -} - -- (void) _terminatedChild: (int)status -{ - [tasksLock lock]; - IF_NO_GC([[self retain] autorelease];) - NSMapRemove(activeTasks, (void*)(intptr_t)_taskId); - [tasksLock unlock]; - _terminationStatus = status; - _hasCollected = YES; - _hasTerminated = YES; if (_hasNotified == NO) { NSNotification *n; @@ -930,9 +897,28 @@ pty_slave(const char* name) } } +- (void) _collectChild +{ + [self subclassResponsibility: _cmd]; +} + +- (void) _terminatedChild: (int)status +{ + [tasksLock lock]; + NSMapRemove(activeTasks, (void*)(intptr_t)_taskId); + [tasksLock unlock]; + _terminationStatus = status; + _hasCollected = YES; + _hasTerminated = YES; + if (_hasNotified == NO) + { + [self _sendNotification]; + } +} + @end -#ifdef __MINGW__ +#ifdef __MINGW32__ @implementation NSConcreteWindowsTask BOOL @@ -968,9 +954,9 @@ GSPrivateCheckTasks() return found; } -- (void) finalize +- (void) gcFinalize { - [super finalize]; + [super gcFinalize]; if (wThread != NULL) { CloseHandle(wThread); @@ -1005,6 +991,40 @@ GSPrivateCheckTasks() TerminateProcess(procInfo.hProcess, 10); } +/* + * Wait for child process completion. + */ +static DWORD WINAPI _threadFunction(LPVOID t) +{ + DWORD milliseconds = 60000; + int taskId = [(NSTask*)t processIdentifier]; + + for (;;) + { + NSConcreteWindowsTask *task; + + [tasksLock lock]; + task = (NSConcreteWindowsTask*)NSMapGet(activeTasks, (void*)taskId); + [tasksLock unlock]; + if (task == nil) + { + return 0; // Task gone away. + } + switch (WaitForSingleObject(task->procInfo.hProcess, milliseconds)) + { + case WAIT_OBJECT_0: + handleSignal(0); // Signal child process state change. + return 0; + + case WAIT_TIMEOUT: + break; // Timeout ... retry + + default: + return 0; // Error ... stop watching. + } + } +} + static NSString* endSlashesDoubledFromString(NSString *aString) @@ -1057,53 +1077,9 @@ quotedFromString(NSString *aString) return resultString; } - -/* Wait for child process completion. The task object is retained by the - * current thread until it exits, but may be removed from the table of - * active tasks by another thread, so we must check that it's still - * active at intervals. - */ -- (void) _windowsTaskWatcher -{ - void *taskId = (void*)(intptr_t)[self processIdentifier]; - - for (;;) - { - NSConcreteWindowsTask *task; - - /* Check that this task is still active. - */ - [tasksLock lock]; - task = (NSConcreteWindowsTask*)NSMapGet(activeTasks, taskId); - [tasksLock unlock]; - if (task != self) - { - /* Task has been reaped by another thread ... so we can exit. - */ - [NSThread exit]; - } - - /* Wait for up to 1 minute (60,000 milliseconds) to get a notification - * of an event from the subprocess. - */ - if (WaitForSingleObject(procInfo.hProcess, (DWORD)60000) - != WAIT_TIMEOUT) - { - /* The subprocess has terminated or failed in some way ... - * Set flag so child task can be reaped, then exit since this - * thread no longer needs to watch for events. - */ - handleSignal(0); - [NSThread exit]; - } - - /* Timed out ... repeat wait attempt. - */ - } -} - - (void) launch { + DWORD tid; STARTUPINFOW start_info; NSString *lpath; NSString *arg; @@ -1116,10 +1092,6 @@ quotedFromString(NSString *aString) NSDictionary *env; NSMutableArray *toClose; NSFileHandle *hdl; - HANDLE hIn; - HANDLE hOut; - HANDLE hErr; - id last = nil; if (_hasLaunched) { @@ -1191,110 +1163,51 @@ quotedFromString(NSString *aString) start_info.dwFlags |= STARTF_USESTDHANDLES; toClose = [NSMutableArray arrayWithCapacity: 3]; - - if (_standardInput == nil) + hdl = [self standardInput]; + if ([hdl isKindOfClass: [NSPipe class]]) { - start_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); + hdl = [(NSPipe*)hdl fileHandleForReading]; + [toClose addObject: hdl]; } - else + start_info.hStdInput = [hdl nativeHandle]; + + hdl = [self standardOutput]; + if ([hdl isKindOfClass: [NSPipe class]]) { - hdl = [self standardInput]; - if ([hdl isKindOfClass: [NSPipe class]]) + hdl = [(NSPipe*)hdl fileHandleForWriting]; + [toClose addObject: hdl]; + } + start_info.hStdOutput = [hdl nativeHandle]; + + hdl = [self standardError]; + if ([hdl isKindOfClass: [NSPipe class]]) + { + hdl = [(NSPipe*)hdl fileHandleForWriting]; + /* + * If we have the same pipe twice we don't want to close it twice + */ + if ([toClose indexOfObjectIdenticalTo: hdl] == NSNotFound) { - hdl = [(NSPipe*)hdl fileHandleForReading]; [toClose addObject: hdl]; } - start_info.hStdInput = [hdl nativeHandle]; } - hIn = start_info.hStdInput; - - if (_standardOutput == nil) - { - start_info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); - } - else - { - hdl = [self standardOutput]; - if ([hdl isKindOfClass: [NSPipe class]]) - { - hdl = [(NSPipe*)hdl fileHandleForWriting]; - [toClose addObject: hdl]; - } - start_info.hStdOutput = [hdl nativeHandle]; - } - hOut = start_info.hStdOutput; - - if (_standardError == nil) - { - start_info.hStdError = GetStdHandle(STD_ERROR_HANDLE); - } - else - { - hdl = [self standardError]; - if ([hdl isKindOfClass: [NSPipe class]]) - { - hdl = [(NSPipe*)hdl fileHandleForWriting]; - /* - * If we have the same pipe twice we don't want to close it twice - */ - if ([toClose indexOfObjectIdenticalTo: hdl] == NSNotFound) - { - [toClose addObject: hdl]; - } - } - start_info.hStdError = [hdl nativeHandle]; - } - hErr = start_info.hStdError; - - /* Tell the system not to show a window for the subtask. - */ - start_info.wShowWindow = SW_HIDE; - start_info.dwFlags |= STARTF_USESHOWWINDOW; - - /* Make the handles inheritable only temporarily while launching the - * child task. This section must be lock protected so we don't have - * another thread trying to launch at the same time and get handles - * inherited by the wrong threads. - */ - [tasksLock lock]; - SetHandleInformation(hIn, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); - SetHandleInformation(hOut, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); - SetHandleInformation(hErr, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); + start_info.hStdError = [hdl nativeHandle]; result = CreateProcessW(wexecutable, w_args, NULL, /* proc attrs */ NULL, /* thread attrs */ 1, /* inherit handles */ - 0 - |CREATE_NO_WINDOW -/* One would have thought the the CREATE_NO_WINDOW flag should be used, - * but apparently this breaks for old 16bit applications/tools on XP. - * So maybe we want to leave it out? - */ -// |DETACHED_PROCESS -/* We don't set the DETACHED_PROCESS flag as it actually means that the - * child task should get a new Console allocated ... and that means it - * will pop up a console window ... which looks really bad. - */ - |CREATE_UNICODE_ENVIRONMENT, +// CREATE_NO_WINDOW|DETACHED_PROCESS|CREATE_UNICODE_ENVIRONMENT, + CREATE_NO_WINDOW|CREATE_UNICODE_ENVIRONMENT, envp, /* env block */ (const unichar*)[[self currentDirectoryPath] fileSystemRepresentation], &start_info, &procInfo); - if (result == 0) - { - last = [NSError _last]; - } NSZoneFree(NSDefaultMallocZone(), w_args); - SetHandleInformation(hIn, HANDLE_FLAG_INHERIT, 0); - SetHandleInformation(hOut, HANDLE_FLAG_INHERIT, 0); - SetHandleInformation(hErr, HANDLE_FLAG_INHERIT, 0); - [tasksLock unlock]; - if (result == 0) { - NSLog(@"Error launching task: %@ ... %@", lpath, last); + NSLog(@"Error launching task: %@", lpath); return; } @@ -1303,15 +1216,12 @@ quotedFromString(NSString *aString) ASSIGN(_launchPath, lpath); // Actual path used. [tasksLock lock]; - NSMapInsert(activeTasks, (void*)(intptr_t) _taskId, (void*)self); + NSMapInsert(activeTasks, (void*)_taskId, (void*)self); [tasksLock unlock]; - /* * Create thread to watch for termination of process. */ - [NSThread detachNewThreadSelector: @selector(_windowsTaskWatcher) - toTarget: self - withObject: nil]; + wThread = CreateThread(NULL, 0, _threadFunction, (LPVOID)self, 0, &tid); /* * Close the ends of any pipes used by the child. @@ -1361,47 +1271,24 @@ GSPrivateCheckTasks() do { - NSTask *t; - - errno = 0; result = waitpid(-1, &status, WNOHANG); - if (result < 0) + if (result > 0) { -#if defined(WAITDEBUG) + NSTask *t; + [tasksLock lock]; t = (NSTask*)NSMapGet(activeTasks, (void*)(intptr_t)result); - IF_NO_GC([[t retain] autorelease];) - [tasksLock unlock]; - if (t != nil) - { - NSLog(@"waitpid result %d, error %@", - result, [NSError _last]); - } -#endif - } - else if (result > 0) - { - [tasksLock lock]; - t = (NSTask*)NSMapGet(activeTasks, (void*)(intptr_t)result); - IF_NO_GC([[t retain] autorelease];) + AUTORELEASE(RETAIN(t)); [tasksLock unlock]; if (t != nil) { if (WIFEXITED(status)) { -#if defined(WAITDEBUG) - NSLog(@"waitpid %d, exit status = %d", - result, status); -#endif [t _terminatedChild: WEXITSTATUS(status)]; found = YES; } else if (WIFSIGNALED(status)) { -#if defined(WAITDEBUG) - NSLog(@"waitpid %d, termination status = %d", - result, status); -#endif [t _terminatedChild: WTERMSIG(status)]; found = YES; } @@ -1411,12 +1298,6 @@ GSPrivateCheckTasks() result); } } -#if defined(WAITDEBUG) - else - { - NSLog(@"Received signal for unknown child %d", result); - } -#endif } } while (result > 0); @@ -1511,7 +1392,7 @@ GSPrivateCheckTasks() } edesc = [hdl fileDescriptor]; - pid = vfork(); + pid = fork(); if (pid < 0) { [NSException raise: NSInvalidArgumentException @@ -1521,48 +1402,33 @@ GSPrivateCheckTasks() { int i; - /* Make sure the task gets default signal setup. + /* + * Make sure the task gets default signal setup. */ for (i = 0; i < 32; i++) { signal(i, SIG_DFL); } - /* Make sure task is session leader in it's own process group - * and with no controlling terminal. - * This allows us to use killpg() to put the task to sleep etc, - * and have the signal effect forked children of the subtask. + /* + * Make sure task is run in it's own process group. */ -#if defined(HAVE_SETSID) - setsid(); -#else -#if defined(HAVE_SETPGRP) -#if defined(SETPGRP_VOID) +#ifdef HAVE_SETPGRP +#ifdef SETPGRP_VOID setpgrp(); #else setpgrp(getpid(), getpid()); #endif #else -#if defined(HAVE_SETPGID) -#if defined(__MINGW__) +#if defined(__MINGW32__) pid = (int)GetCurrentProcessId(), #else pid = (int)getpid(); #endif +#ifdef HAVE_SETPGID setpgid(pid, pid); -#endif /* HAVE_SETPGID */ -#endif /* HAVE_SETPGRP */ - /* Detach from controlling terminal. - */ -#if defined(TIOCNOTTY) - i = open("/dev/tty", O_RDWR); - if (i >= 0) - { - (void)ioctl(i, TIOCNOTTY, 0); - (void)close(i); - } -#endif /* TIOCNOTTY */ -#endif /* HAVE_SETSID */ +#endif +#endif if (_usePseudoTerminal == YES) { @@ -1574,7 +1440,19 @@ GSPrivateCheckTasks() exit(1); /* Failed to open slave! */ } - /* Set up stdin, stdout and stderr by duplicating descriptors as +#ifdef HAVE_SETSID + i = setsid(); +#endif +#ifdef TIOCNOTTY + i = open("/dev/tty", O_RDWR); + if (i >= 0) + { + (void)ioctl(i, TIOCNOTTY, 0); + (void)close(i); + } +#endif + /* + * Set up stdin, stdout and stderr by duplicating descriptors as * necessary and closing the originals (to ensure we won't have a * pipe left with two write descriptors etc). */ @@ -1593,7 +1471,8 @@ GSPrivateCheckTasks() } else { - /* Set up stdin, stdout and stderr by duplicating descriptors as + /* + * Set up stdin, stdout and stderr by duplicating descriptors as * necessary and closing the originals (to ensure we won't have a * pipe left with two write descriptors etc). */ @@ -1677,7 +1556,52 @@ GSPrivateCheckTasks() - (void) _collectChild { - GSPrivateCheckTasks(); + if (_hasCollected == NO) + { + int result; + + errno = 0; + result = waitpid(_taskId, &_terminationStatus, WNOHANG); + if (result < 0) + { + NSLog(@"waitpid %d, result %d, error %@", + _taskId, result, [NSError _last]); + [self _terminatedChild: -1]; + } + else if (result == _taskId || (result > 0 && errno == 0)) + { + if (WIFEXITED(_terminationStatus)) + { +#ifdef WAITDEBUG + NSLog(@"waitpid %d, termination status = %d", + _taskId, _terminationStatus); +#endif + [self _terminatedChild: WEXITSTATUS(_terminationStatus)]; + } + else if (WIFSIGNALED(_terminationStatus)) + { +#ifdef WAITDEBUG + NSLog(@"waitpid %d, termination status = %d", + _taskId, _terminationStatus); +#endif + [self _terminatedChild: WTERMSIG(_terminationStatus)]; + } +#ifdef WAITDEBUG + else + { + NSLog(@"waitpid %d, event status = %d", + _taskId, _terminationStatus); + } +#endif + } +#ifdef WAITDEBUG + else + { + NSLog(@"waitpid %d, result %d, error %@", + _taskId, result, [NSError _last]); + } +#endif + } } - (BOOL) usePseudoTerminal diff --git a/Source/NSTextCheckingResult.m b/Source/NSTextCheckingResult.m new file mode 100644 index 000000000..7a26c8152 --- /dev/null +++ b/Source/NSTextCheckingResult.m @@ -0,0 +1,79 @@ +#import "Foundation/NSTextCheckingResult.h" +#import "Foundation/NSRegularExpression.h" + +/** + * Private class encapsulating a regular expression match. + */ +@interface GSRegularExpressionCheckingResult : NSTextCheckingResult +{ + // TODO: This could be made more efficient by adding a variant that only + // contained a single range. + @public + /** The number of ranges matched */ + NSUInteger rangeCount; + /** The array of ranges. */ + NSRange *ranges; + /** The regular expression object that generated this match. */ + NSRegularExpression *regularExpression; +} +@end + +@implementation NSTextCheckingResult ++ (NSTextCheckingResult*)regularExpressionCheckingResultWithRanges: (NSRangePointer)ranges + count: (NSUInteger)count + regularExpression: (NSRegularExpression*)regularExpression +{ + GSRegularExpressionCheckingResult *result = [GSRegularExpressionCheckingResult new]; + result->rangeCount = count; + result->ranges = calloc(sizeof(NSRange), count); + memcpy(result->ranges, ranges, (sizeof(NSRange) * count)); + ASSIGN(result->regularExpression, regularExpression); + return [result autorelease]; +} +- (NSDictionary*)addressComponents { return 0; } +- (NSDictionary*)components { return 0; } +- (NSDate*)date { return 0; } +- (NSTimeInterval) duration { return 0; } +- (NSArray*)grammarDetails { return 0; } +- (NSUInteger) numberOfRanges { return 0; } +- (NSOrthography*)orthography { return 0; } +- (NSString*)phoneNumber { return 0; } +- (NSRange) range { return NSMakeRange(0, NSNotFound); } +- (NSRegularExpression*)regularExpression { return 0; } +- (NSString*)replacementString { return 0; } +- (NSTextCheckingType)resultType { return -1; } +- (NSTimeZone*)timeZone { return 0; } +- (NSURL*)URL { return 0; } +@end + + + +@implementation GSRegularExpressionCheckingResult +- (NSUInteger)rangeCount +{ + return rangeCount; +} +- (NSRange)range +{ + return ranges[0]; +} +- (NSRange)rangeAtIndex: (NSUInteger)idx +{ + if (idx >= rangeCount) + { + return NSMakeRange(0, NSNotFound); + } + return ranges[idx]; +} +- (NSTextCheckingType)resultType +{ + return NSTextCheckingTypeRegularExpression; +} +- (void)dealloc +{ + [regularExpression release]; + free(ranges); + [super dealloc]; +} +@end + diff --git a/Source/NSThread.m b/Source/NSThread.m index 32b0ae48f..abe938591 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -13,7 +13,7 @@ This file is part of the GNUstep Objective-C Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -31,69 +31,39 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSThread_IVARS 1 +#include "config.h" +#include "GNUstepBase/preface.h" #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_NANOSLEEP #include #endif -#ifdef HAVE_SYS_TIME_H -#include -#endif -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif -#ifdef HAVE_PTHREAD_H -#include -#endif -#ifdef HAVE_SYS_FILE_H -#include -#endif -#ifdef HAVE_SYS_FCNTL_H -#include +#ifdef NeXT_RUNTIME +#include "thr-mach.h" #endif #include -#ifdef __POSIX_SOURCE -#define NBLK_OPT O_NONBLOCK -#else -#define NBLK_OPT FNDELAY -#endif +#include "Foundation/NSException.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSString.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSNotificationQueue.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSConnection.h" +#include "Foundation/NSInvocation.h" -#import "Foundation/NSException.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSConnection.h" -#import "Foundation/NSInvocation.h" - -#import "GSPrivate.h" -#import "GSRunLoopCtxt.h" - -#if GS_WITH_GC -#include -#endif - -// Some older BSD systems used a non-standard range of thread priorities. -// Use these if they exist, otherwise define standard ones. -#ifndef PTHREAD_MAX_PRIORITY -#define PTHREAD_MAX_PRIORITY 31 -#endif -#ifndef PTHREAD_MIN_PRIORITY -#define PTHREAD_MIN_PRIORITY 0 -#endif - -extern NSTimeInterval GSTimeNow(void); +#include "GSPrivate.h" +#include "GSRunLoopCtxt.h" @interface NSAutoreleasePool (NSThread) + (void) _endThread: (NSThread*)thread; @end +typedef struct { @defs(NSThread) } NSThread_ivars; + static Class threadClass = Nil; static NSNotificationCenter *nc = nil; @@ -109,7 +79,7 @@ static NSNotificationCenter *nc = nil; *

* As instances, each instance retains perform receiver and argument * values as long as they are needed, and handles locking to support - * methods which want to block until an action has been performed. + * mthods which want to block until an action has been performed. *

*

* The initialize method of this class is called before any new threads @@ -121,19 +91,20 @@ static NSNotificationCenter *nc = nil; id receiver; id argument; SEL selector; - NSConditionLock *lock; // Not retained. NSArray *modes; - BOOL invalidated; + NSConditionLock *lock; // Not retained. } ++ (BOOL) isValid; + (GSPerformHolder*) newForReceiver: (id)r argument: (id)a selector: (SEL)s modes: (NSArray*)m lock: (NSConditionLock*)l; ++ (void) receivedEvent: (void*)data + type: (RunLoopEventType)type + extra: (void*)extra + forMode: (NSString*)mode; - (void) fire; -- (void) invalidate; -- (BOOL) isInvalidated; -- (NSArray*) modes; @end /** @@ -143,21 +114,15 @@ static NSNotificationCenter *nc = nil; * to avoid objc messaging and object allocation/deallocation (NSDate) * overheads.
* Used to implement [NSThread+sleepUntilDate:] - * If the date is in the past, this function simply allows other threads - * (if any) to run. */ void GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) { + extern NSTimeInterval GSTimeNow(void); NSTimeInterval delay; // delay is always the number of seconds we still need to wait delay = when - GSTimeNow(); - if (delay <= 0.0) - { - sched_yield(); - return; - } #ifdef HAVE_NANOSLEEP // Avoid any possibility of overflow by sleeping in chunks. @@ -202,7 +167,7 @@ GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) while (delay > 30.0*60.0) { // sleep 30 minutes -#if defined(__MINGW__) +#if defined(__MINGW32__) Sleep (30*60*1000); #else sleep (30*60); @@ -216,32 +181,18 @@ GSSleepUntilIntervalSinceReferenceDate(NSTimeInterval when) */ while (delay > 0) { -#if defined(__MINGW__) -#if defined(HAVE_USLEEP) - /* On windows usleep() seems to perform a busy wait ... so we only - * use it for short delays ... otherwise use the less accurate Sleep() - */ - if (delay > 0.1) - { - Sleep ((NSInteger)(delay*1000)); - } - else - { - usleep ((NSInteger)(delay*1000000)); - } +#ifdef HAVE_USLEEP + usleep ((int)(delay*1000000)); #else - Sleep ((NSInteger)(delay*1000)); -#endif /* HAVE_USLEEP */ +#if defined(__MINGW32__) + Sleep (delay*1000); #else -#if defined(HAVE_USLEEP) - usleep ((NSInteger)(delay*1000000)); -#else - sleep ((NSInteger)delay); -#endif /* HAVE_USLEEP */ -#endif /* __MINGW__ */ + sleep ((int)delay); +#endif +#endif delay = when - GSTimeNow(); } -#endif /* HAVE_NANOSLEEP */ +#endif } static NSArray * @@ -272,7 +223,7 @@ commonModes(void) return modes; } -#if !defined(HAVE_OBJC_THREAD_ADD) && !defined(NeXT_RUNTIME) && !defined(__GNUSTEP_RUNTIME__) +#if !defined(HAVE_OBJC_THREAD_ADD) && !defined(NeXT_RUNTIME) /* We need to access these private vars in the objc runtime - because the objc runtime's API is not enough powerful for the GNUstep extensions we want to add. */ @@ -280,11 +231,6 @@ extern objc_mutex_t __objc_runtime_mutex; extern int __objc_runtime_threads_alive; extern int __objc_is_multi_threaded; -/* WARNING: - * GNUstep appears to have been written on the assumption that these variables - * are used correctly by the GNU runtime. In fact, they are used in only one - * place, and are used incorrectly there. - */ inline static void objc_thread_add (void) { objc_mutex_lock(__objc_runtime_mutex); @@ -292,66 +238,104 @@ inline static void objc_thread_add (void) __objc_runtime_threads_alive++; objc_mutex_unlock(__objc_runtime_mutex); } + +inline static void objc_thread_remove (void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_runtime_threads_alive--; + objc_mutex_unlock(__objc_runtime_mutex); +} #endif /* not HAVE_OBJC_THREAD_ADD */ +@interface NSThread (Private) +- (id) _initWithSelector: (SEL)s toTarget: (id)t withObject: (id)o; +- (void) _sendThreadMethod; +@end + /* * Flag indicating whether the objc runtime ever went multi-threaded. */ static BOOL entered_multi_threaded_state = NO; -static NSThread *defaultThread; -static NSLock *thread_creation_lock; - -static pthread_key_t thread_object_key; - -/** - * Pthread cleanup call. - * - * We should normally not get here ... because threads should exit properly - * and clean up, so that this function doesn't get called. However if a - * thread terminates for some reason without calling the exit method, we - * can at least log it. - * - * We can't do anything more than that since at the point - * when this function is called, the thread specific data is no longer - * available, so the currentThread method will always fail and the - * repercussions of that would well be a crash. - * - * As a special case, we ignore the exit of the default thread ... that one - * will usually terminate without calling the exit method as it ends the - * whole process by returning from the 'main' function. +/* + * Default thread. */ -static void exitedThread(void *thread) -{ - if (thread != defaultThread) - { - fprintf(stderr, "WARNING thread %p terminated without calling +exit!\n", - thread); - } -} +static NSThread *defaultThread = nil; /** - * These functions needed because sending messages to classes is a seriously - * slow process with gcc and the gnu runtime. + *

+ * This function is a GNUstep extension. It pretty much + * duplicates the functionality of [NSThread +currentThread] + * but is more efficient and is used internally throughout + * GNUstep. + *

+ *

+ * Returns the current thread. Could perhaps return nil + * if executing a thread that was started outside the GNUstep + * environment and not registered (this should not happen in a + * well-coded application). + *

*/ inline NSThread* GSCurrentThread(void) { - if (defaultThread == nil) + NSThread *t; + + if (entered_multi_threaded_state == NO) { - [NSThread currentThread]; + /* + * If the NSThread class has been initialized, we will have a default + * thread set up - otherwise we must make sure the class is initialised. + */ + if (defaultThread == nil) + { + t = [NSThread currentThread]; + } + else + { + t = defaultThread; + } } - return (NSThread*)pthread_getspecific(thread_object_key); + else + { + t = (NSThread*)objc_thread_get_data(); + if (t == nil) + { + fprintf(stderr, +"ALERT ... GSCurrentThread() ... objc_thread_get_data() call returned nil!\n" +"Your application MUST call GSRegisterCurrentThread() before attempting to\n" +"use any GNUstep code from a thread other than the main GNUstep thread.\n"); + fflush(stderr); // Needed for windoze + } + } + return t; } +/** + * Fast access function for thread dictionary of current thread.
+ * If there is no dictionary, creates the dictionary. + */ NSMutableDictionary* GSDictionaryForThread(NSThread *t) { - if (nil == t) + if (t == nil) { t = GSCurrentThread(); } - return [t threadDictionary]; + if (t == nil) + { + return nil; + } + else + { + NSMutableDictionary *dict = t->_thread_dictionary; + + if (dict == nil) + { + dict = [t threadDictionary]; + } + return dict; + } } /** @@ -363,6 +347,75 @@ GSCurrentThreadDictionary(void) return GSDictionaryForThread(nil); } +/* + * The special timer which we set up in the run loop of the main thread + * to perform housekeeping duties. NSRunLoop needs to call this private + * function so it knows about the housekeeping timer and won't keep the + * loop running just to do housekeeping. + * + * The NSUserDefaults system registers as an observer of GSHousekeeping + * notifications in order to synchronise the in-memory cache and the + * on-disk database. + */ +static NSTimer *housekeeper = nil; + +/** + * Returns the runloop for the specified thread (or, if t is nil, + * for the current thread).
+ * Creates a new runloop if necessary, + * as long as the thread dictionary exists.
+ * Returns nil on failure. + */ +NSRunLoop* +GSRunLoopForThread(NSThread *t) +{ + static NSString *key = @"NSRunLoopThreadKey"; + NSMutableDictionary *d = GSDictionaryForThread(t); + NSRunLoop *r; + + r = [d objectForKey: key]; + if (r == nil) + { + if (d != nil) + { + r = [NSRunLoop new]; + [d setObject: r forKey: key]; + RELEASE(r); + if (housekeeper == nil && (t == nil || t == defaultThread)) + { + CREATE_AUTORELEASE_POOL (arp); + NSNotificationCenter *ctr; + NSNotification *not; + NSInvocation *inv; + SEL sel; + + ctr = [NSNotificationCenter defaultCenter]; + not = [NSNotification notificationWithName: @"GSHousekeeping" + object: nil + userInfo: nil]; + sel = @selector(postNotification:); + inv = [NSInvocation invocationWithMethodSignature: + [ctr methodSignatureForSelector: sel]]; + [inv setTarget: ctr]; + [inv setSelector: sel]; + [inv setArgument: ¬ atIndex: 2]; + [inv retainArguments]; + + housekeeper = [[NSTimer alloc] initWithFireDate: nil + interval: 30.0 + target: inv + selector: NULL + userInfo: nil + repeats: YES]; + [r _setHousekeeper: housekeeper]; + RELEASE(housekeeper); + RELEASE(arp); + } + } + } + return r; +} + /* * Callback function so send notifications on becoming multi-threaded. */ @@ -387,13 +440,6 @@ gnustep_base_thread_callback(void) * threaded BEFORE sending the notifications. */ entered_multi_threaded_state = YES; -#if GS_WITH_GC && defined(HAVE_GC_ALLOW_REGISTER_THREADS) - /* This function needs to be called before going multi-threaded - * so that the garbage collection library knows to support - * registration of new threads. - */ - GS_allow_register_threads(); -#endif NS_DURING { [GSPerformHolder class]; // Force initialization @@ -404,11 +450,6 @@ gnustep_base_thread_callback(void) * Won't work properly if threads are not all created * by this class, but it's better than nothing. */ - // FIXME: This code is complete nonsense; this can be called from - // any thread (and is when adding new foreign threads), so this - // will often be called from the wrong thread, delivering - // notifications to the wrong thread, and generally doing the - // wrong thing.. if (nc == nil) { nc = RETAIN([NSNotificationCenter defaultCenter]); @@ -431,25 +472,109 @@ gnustep_base_thread_callback(void) } +/** + * This class encapsulates OpenStep threading. See [NSLock] and its + * subclasses for handling synchronisation between threads.
+ * Each process begins with a main thread and additional threads can + * be created using NSThread. The GNUstep implementation of OpenStep + * has been carefully designed so that the internals of the base + * library do not use threading (except for methods which explicitly + * deal with threads of course) so that you can write applications + * without threading. Non-threaded applications are more efficient + * (no locking is required) and are easier to debug during development. + */ @implementation NSThread -static void -setThreadForCurrentThread(NSThread *t) +/** + *

+ * Returns the NSThread object corresponding to the current thread. + *

+ *

+ * NB. In GNUstep the library internals use the GSCurrentThread() + * function as a more efficient mechanism for doing this job - so + * you cannot use a category to override this method and expect + * the library internals to use your implementation. + *

+ */ ++ (NSThread*) currentThread { - pthread_setspecific(thread_object_key, t); - gnustep_base_thread_callback(); + NSThread *t = nil; + + if (entered_multi_threaded_state == NO) + { + /* + * The NSThread class has been initialized - so we will have a default + * thread set up unless the default thread subsequently exited. + */ + t = defaultThread; + } + if (t == nil) + { + t = (NSThread*)objc_thread_get_data(); + if (t == nil) + { + fprintf(stderr, "ALERT ... [NSThread +currentThread] ... the " + "objc_thread_get_data() call returned nil!"); + fflush(stderr); // Needed for windoze + } + } + return t; } -static void -unregisterActiveThread(NSThread *thread) +/** + *

Create a new thread - use this method rather than alloc-init. The new + * thread will begin executing the message given by aSelector, aTarget, and + * anArgument. This should have no return value, and must set up an + * autorelease pool if retain/release memory management is used. It should + * free this pool before it finishes execution.

+ */ ++ (void) detachNewThreadSelector: (SEL)aSelector + toTarget: (id)aTarget + withObject: (id)anArgument { - if (thread->_active == YES) + NSThread *thread; + + /* + * Make sure the notification is posted BEFORE the new thread starts. + */ + gnustep_base_thread_callback(); + + /* + * Create the new thread. + */ + thread = (NSThread*)NSAllocateObject(self, 0, NSDefaultMallocZone()); + thread = [thread _initWithSelector: aSelector + toTarget: aTarget + withObject: anArgument]; + + /* + * Have the runtime detach the thread + */ + if (objc_thread_detach(@selector(_sendThreadMethod), thread, nil) == NULL) + { + [NSException raise: NSInternalInconsistencyException + format: @"Unable to detach thread (unknown error)"]; + } +} + + +/** + * Terminates the current thread.
+ * Normally you don't need to call this method explicitly, + * since exiting the method with which the thread was detached + * causes this method to be called automatically. + */ ++ (void) exit +{ + NSThread *t; + + t = GSCurrentThread(); + if (t->_active == YES) { /* * Set the thread to be inactive to avoid any possibility of recursion. */ - thread->_active = NO; - thread->_finished = YES; + t->_active = NO; /* * Let observers know this thread is exiting. @@ -459,84 +584,20 @@ unregisterActiveThread(NSThread *thread) nc = RETAIN([NSNotificationCenter defaultCenter]); } [nc postNotificationName: NSThreadWillExitNotification - object: thread + object: t userInfo: nil]; - [(GSRunLoopThreadInfo*)thread->_runLoopInfo invalidate]; - [thread release]; - pthread_setspecific(thread_object_key, nil); - } -} + /* + * destroy the thread object. + */ + DESTROY(t); -+ (NSArray*) callStackReturnAddresses -{ - NSMutableArray *stack = GSPrivateStackAddresses(); + objc_thread_set_data (NULL); - return stack; -} - -+ (BOOL) _createThreadForCurrentPthread -{ - NSThread *t = pthread_getspecific(thread_object_key); - - if (t == nil) - { - [thread_creation_lock lock]; - t = pthread_getspecific(thread_object_key); - if (t == nil) - { - t = [self new]; - t->_active = YES; - pthread_setspecific(thread_object_key, t); - [thread_creation_lock unlock]; - return YES; - } - [thread_creation_lock unlock]; - } - return NO; -} - -+ (NSThread*) currentThread -{ - return (NSThread*)pthread_getspecific(thread_object_key); -} - -+ (void) detachNewThreadSelector: (SEL)aSelector - toTarget: (id)aTarget - withObject: (id)anArgument -{ - NSThread *thread; - - /* - * Create the new thread. - */ - thread = [[NSThread alloc] initWithTarget: aTarget - selector: aSelector - object: anArgument]; - - [thread start]; - RELEASE(thread); -} - -+ (void) exit -{ - NSThread *t; - - t = GSCurrentThread(); - if (t->_active == YES) - { - unregisterActiveThread (t); - - if (t == defaultThread || defaultThread == nil) - { - /* For the default thread, we exit the process. - */ - exit(0); - } - else - { - pthread_exit(NULL); - } + /* + * Tell the runtime to exit the thread + */ + objc_thread_exit(); } } @@ -547,77 +608,59 @@ unregisterActiveThread(NSThread *thread) { if (self == [NSThread class]) { - if (pthread_key_create(&thread_object_key, exitedThread)) - { - [NSException raise: NSInternalInconsistencyException - format: @"Unable to create thread key!"]; - } - thread_creation_lock = [NSLock new]; - /* - * Ensure that the default thread exists. - */ - threadClass = self; - - [NSThread _createThreadForCurrentPthread]; - defaultThread = [NSThread currentThread]; - /* * The objc runtime calls this callback AFTER creating a new thread - * which is not correct for us, but does at least mean that we can tell * if we have become multi-threaded due to a call to the runtime directly * rather than via the NSThread class. */ -#if defined(__GNUSTEP_RUNTIME__) || defined(NeXT_RUNTIME) - gnustep_base_thread_callback(); -#else objc_set_thread_callback(gnustep_base_thread_callback); -#endif + + /* + * Ensure that the default thread exists. + */ + defaultThread + = (NSThread*)NSAllocateObject(self, 0, NSDefaultMallocZone()); + defaultThread = [defaultThread _initWithSelector: (SEL)0 + toTarget: nil + withObject: nil]; + defaultThread->_active = YES; + objc_thread_set_data(defaultThread); + threadClass = self; } } -+ (BOOL) isMainThread -{ - return (GSCurrentThread() == defaultThread ? YES : NO); -} - +/** + * Returns a flag to say whether the application is multi-threaded or not.
+ * An application is considered to be multi-threaded if any thread other + * than the main thread has been started, irrespective of whether that + * thread has since terminated.
+ * NB. This method returns YES if called within a handler processing + * NSWillBecomeMultiThreadedNotification + */ + (BOOL) isMultiThreaded { return entered_multi_threaded_state; } -+ (NSThread*) mainThread -{ - return defaultThread; -} - /** * Set the priority of the current thread. This is a value in the * range 0.0 (lowest) to 1.0 (highest) which is mapped to the underlying - * system priorities. + * system priorities. The current gnu objc runtime supports three + * priority levels which you can obtain using values of 0.0, 0.5, and 1.0 */ + (void) setThreadPriority: (double)pri { -#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING - int policy; - struct sched_param param; + int p; - // Clamp pri into the required range. - if (pri > 1) { pri = 1; } - if (pri < 0) { pri = 0; } + if (pri <= 0.3) + p = OBJC_THREAD_LOW_PRIORITY; + else if (pri <= 0.6) + p = OBJC_THREAD_BACKGROUND_PRIORITY; + else + p = OBJC_THREAD_INTERACTIVE_PRIORITY; - // Scale pri based on the range of the host system. - pri *= (PTHREAD_MAX_PRIORITY - PTHREAD_MIN_PRIORITY); - pri += PTHREAD_MIN_PRIORITY; - - pthread_getschedparam(pthread_self(), &policy, ¶m); - param.sched_priority = pri; - pthread_setschedparam(pthread_self(), policy, ¶m); -#endif -} - -+ (void) sleepForTimeInterval: (NSTimeInterval)ti -{ - GSSleepUntilIntervalSinceReferenceDate(GSTimeNow() + ti); + objc_thread_set_priority(p); } /** @@ -634,22 +677,16 @@ unregisterActiveThread(NSThread *thread) */ + (double) threadPriority { - double pri = 0; -#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING - int policy; - struct sched_param param; - - pthread_getschedparam(pthread_self(), &policy, ¶m); - pri = param.sched_priority; - // Scale pri based on the range of the host system. - pri -= PTHREAD_MIN_PRIORITY; - pri /= (PTHREAD_MAX_PRIORITY - PTHREAD_MIN_PRIORITY); - -#else -#warning Your pthread implementation does not support thread priorities -#endif - return pri; + int p = objc_thread_get_priority(); + if (p == OBJC_THREAD_LOW_PRIORITY) + return 0.0; + else if (p == OBJC_THREAD_BACKGROUND_PRIORITY) + return 0.5; + else if (p == OBJC_THREAD_INTERACTIVE_PRIORITY) + return 1.0; + else + return 0.0; // Unknown. } @@ -658,11 +695,6 @@ unregisterActiveThread(NSThread *thread) * Thread instance methods. */ -- (void) cancel -{ - _cancelled = YES; -} - - (void) dealloc { if (_active == YES) @@ -670,17 +702,9 @@ unregisterActiveThread(NSThread *thread) [NSException raise: NSInternalInconsistencyException format: @"Deallocating an active thread without [+exit]!"]; } - if (_runLoopInfo != 0) - { - GSRunLoopThreadInfo *info = (GSRunLoopThreadInfo*)_runLoopInfo; - - _runLoopInfo = 0; - [info release]; - } DESTROY(_thread_dictionary); DESTROY(_target); DESTROY(_arg); - DESTROY(_name); if (_autorelease_vars.pool_cache != 0) { [NSAutoreleasePool _endThread: self]; @@ -705,109 +729,42 @@ unregisterActiveThread(NSThread *thread) } } } - DESTROY(_gcontext); - [super dealloc]; + if (self == defaultThread) + { + defaultThread = nil; + } + NSDeallocateObject(self); + GSNOSUPERDEALLOC; } - (id) init { - init_autorelease_thread_vars(&_autorelease_vars); - return self; + RELEASE(self); + return [NSThread currentThread]; } -- (id) initWithTarget: (id)aTarget - selector: (SEL)aSelector - object: (id)anArgument +- (id) _initWithSelector: (SEL)s toTarget: (id)t withObject: (id)o { /* initialize our ivars. */ - _selector = aSelector; - _target = RETAIN(aTarget); - _arg = RETAIN(anArgument); + _selector = s; + _target = RETAIN(t); + _arg = RETAIN(o); + _thread_dictionary = nil; // Initialize this later only when needed + _exception_handler = NULL; + _active = NO; init_autorelease_thread_vars(&_autorelease_vars); return self; } -- (BOOL) isCancelled +- (void) _sendThreadMethod { - return _cancelled; -} - -- (BOOL) isExecuting -{ - return _active; -} - -- (BOOL) isFinished -{ - return _finished; -} - -- (BOOL) isMainThread -{ - return (self == defaultThread ? YES : NO); -} - -- (void) main -{ - if (_active == NO) - { - [NSException raise: NSInternalInconsistencyException - format: @"[%@-$@] called on inactive thread", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd)]; - } - - [_target performSelector: _selector withObject: _arg]; - -} - -- (NSString*) name -{ - return _name; -} - -- (void) setName: (NSString*)aName -{ - ASSIGN(_name, aName); -} - -- (void) setStackSize: (NSUInteger)stackSize -{ - _stackSize = stackSize; -} - -- (NSUInteger) stackSize -{ - return _stackSize; -} - -/** - * Trampoline function called to launch the thread - */ -static void *nsthreadLauncher(void* thread) -{ - NSThread *t = (NSThread*)thread; - setThreadForCurrentThread(t); -#if GS_WITH_GC && defined(HAVE_GC_REGISTER_MY_THREAD) - { - struct GC_stack_base base; - - if (GC_get_stack_base(&base) == GC_SUCCESS) - { - int result; - - result = GC_register_my_thread(&base); - if (result != GC_SUCCESS && result != GC_DUPLICATE) - { - fprintf(stderr, "Argh ... no thread support in garbage collection library\n"); - } - } - else - { - fprintf(stderr, "Unable to determine stack base to register new thread for garbage collection\n"); - } - } -#endif + /* + * We are running in the new thread - so we store ourself in the thread + * dictionary and release ourself - thus, when the thread exits, we will + * be deallocated cleanly. + */ + objc_thread_set_data(self); + _active = YES; /* * Let observers know a new thread is starting. @@ -817,75 +774,11 @@ static void *nsthreadLauncher(void* thread) nc = RETAIN([NSNotificationCenter defaultCenter]); } [nc postNotificationName: NSThreadDidStartNotification - object: t + object: self userInfo: nil]; - [t main]; - + [_target performSelector: _selector withObject: _arg]; [NSThread exit]; - // Not reached - return NULL; -} - -- (void) start -{ - pthread_attr_t attr; - pthread_t thr; - - if (_active == YES) - { - [NSException raise: NSInternalInconsistencyException - format: @"[%@-$@] called on active thread", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd)]; - } - if (_cancelled == YES) - { - [NSException raise: NSInternalInconsistencyException - format: @"[%@-$@] called on cancelled thread", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd)]; - } - if (_finished == YES) - { - [NSException raise: NSInternalInconsistencyException - format: @"[%@-$@] called on finished thread", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd)]; - } - - /* Make sure the notification is posted BEFORE the new thread starts. - */ - gnustep_base_thread_callback(); - - /* The thread must persist until it finishes executing. - */ - RETAIN(self); - - /* Mark the thread as active whiul it's running. - */ - _active = YES; - - errno = 0; - pthread_attr_init(&attr); - /* Create this thread detached, because we never use the return state from - * threads. - */ - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - /* Set the stack size when the thread is created. Unlike the old setrlimit - * code, this actually works. - */ - if (_stackSize > 0) - { - pthread_attr_setstacksize(&attr, _stackSize); - } - if (pthread_create(&thr, &attr, nsthreadLauncher, self)) - { - DESTROY(self); - [NSException raise: NSInternalInconsistencyException - format: @"Unable to detach thread (last error %@)", - [NSError _last]]; - } } /** @@ -908,199 +801,74 @@ static void *nsthreadLauncher(void* thread) -@implementation GSRunLoopThreadInfo -- (void) addPerformer: (id)performer -{ - [lock lock]; - [performers addObject: performer]; -#if defined(__MINGW__) - if (SetEvent(event) == 0) - { - NSLog(@"Set event failed - %@", [NSError _last]); - } -#else - /* The write could concievably fail if the pipe is full. - * In that case we need to release the lock teporarily to allow the other - * thread to consume data from the pipe. It's possible that the thread - * and its runloop might stop during that ... so we need to check that - * outputFd is still valid. - */ - while (outputFd >= 0 && write(outputFd, "0", 1) != 1) - { - [lock unlock]; - [lock lock]; - } -#endif - [lock unlock]; -} - -- (void) dealloc -{ - [self invalidate]; - DESTROY(lock); - DESTROY(loop); - [super dealloc]; -} - -- (id) init -{ -#ifdef __MINGW__ - if ((event = CreateEvent(NULL, TRUE, FALSE, NULL)) == INVALID_HANDLE_VALUE) - { - DESTROY(self); - [NSException raise: NSInternalInconsistencyException - format: @"Failed to create event to handle perform in thread"]; - } -#else - int fd[2]; - - if (pipe(fd) == 0) - { - int e; - - inputFd = fd[0]; - outputFd = fd[1]; - if ((e = fcntl(inputFd, F_GETFL, 0)) >= 0) - { - e |= NBLK_OPT; - if (fcntl(inputFd, F_SETFL, e) < 0) - { - [NSException raise: NSInternalInconsistencyException - format: @"Failed to set non block flag for perform in thread"]; - } - } - else - { - [NSException raise: NSInternalInconsistencyException - format: @"Failed to get non block flag for perform in thread"]; - } - if ((e = fcntl(outputFd, F_GETFL, 0)) >= 0) - { - e |= NBLK_OPT; - if (fcntl(outputFd, F_SETFL, e) < 0) - { - [NSException raise: NSInternalInconsistencyException - format: @"Failed to set non block flag for perform in thread"]; - } - } - else - { - [NSException raise: NSInternalInconsistencyException - format: @"Failed to get non block flag for perform in thread"]; - } - } - else - { - DESTROY(self); - [NSException raise: NSInternalInconsistencyException - format: @"Failed to create pipe to handle perform in thread"]; - } -#endif - lock = [NSLock new]; - performers = [NSMutableArray new]; - return self; -} - -- (void) invalidate -{ - [lock lock]; - [performers makeObjectsPerformSelector: @selector(invalidate)]; - [performers removeAllObjects]; -#ifdef __MINGW__ - if (event != INVALID_HANDLE_VALUE) - { - CloseHandle(event); - event = INVALID_HANDLE_VALUE; - } -#else - if (inputFd >= 0) - { - close(inputFd); - inputFd = -1; - } - if (outputFd >= 0) - { - close(outputFd); - outputFd = -1; - } -#endif - [lock unlock]; -} - -- (void) fire -{ - NSArray *toDo; - unsigned int i; - unsigned int c; - - [lock lock]; -#if defined(__MINGW__) - if (event != INVALID_HANDLE_VALUE) - { - if (ResetEvent(event) == 0) - { - NSLog(@"Reset event failed - %@", [NSError _last]); - } - } -#else - if (inputFd >= 0) - { - char buf[BUFSIZ]; - - /* We don't care how much we read. If there have been multiple - * performers queued then there will be multiple bytes available, - * but we always handle all available performers, so we can also - * read all available bytes. - * The descriptor is non-blocking ... so it's safe to ask for more - * bytes than are available. - */ - while (read(inputFd, buf, sizeof(buf)) > 0) - ; - } -#endif - - toDo = [NSArray arrayWithArray: performers]; - [performers removeAllObjects]; - [lock unlock]; - - c = [toDo count]; - for (i = 0; i < c; i++) - { - GSPerformHolder *h = [toDo objectAtIndex: i]; - - [loop performSelector: @selector(fire) - target: h - argument: nil - order: 0 - modes: [h modes]]; - } -} -@end - -GSRunLoopThreadInfo * -GSRunLoopInfoForThread(NSThread *aThread) -{ - GSRunLoopThreadInfo *info; - - if (aThread == nil) - { - aThread = GSCurrentThread(); - } - if (aThread->_runLoopInfo == nil) - { - [gnustep_global_lock lock]; - if (aThread->_runLoopInfo == nil) - { - aThread->_runLoopInfo = [GSRunLoopThreadInfo new]; - } - [gnustep_global_lock unlock]; - } - info = aThread->_runLoopInfo; - return info; -} - @implementation GSPerformHolder +static NSLock *subthreadsLock = nil; +#ifdef __MINGW32__ +static HANDLE event; +#else +static int inputFd = -1; +static int outputFd = -1; +#endif +static NSMutableArray *perfArray = nil; +static NSDate *theFuture; + ++ (void) initialize +{ + NSRunLoop *loop = GSRunLoopForThread(defaultThread); + NSArray *m = commonModes(); + unsigned count = [m count]; + unsigned i; + + theFuture = RETAIN([NSDate distantFuture]); + subthreadsLock = [[NSLock alloc] init]; + perfArray = [[NSMutableArray alloc] initWithCapacity: 10]; + +#ifndef __MINGW32__ + { + int fd[2]; + + if (pipe(fd) == 0) + { + inputFd = fd[0]; + outputFd = fd[1]; + } + else + { + [NSException raise: NSInternalInconsistencyException + format: @"Failed to create pipe to handle perform in main thread"]; + } + for (i = 0; i < count; i++) + { + [loop addEvent: (void*)(intptr_t)inputFd + type: ET_RDESC + watcher: (id)self + forMode: [m objectAtIndex: i]]; + } + } +#else + { + if ((event = CreateEvent(NULL, TRUE, FALSE, NULL)) == NULL) + { + [NSException raise: NSInternalInconsistencyException + format: @"Failed to create event to handle perform in main thread"]; + } + for (i = 0; i < count; i++) + { + [loop addEvent: (void*)event + type: ET_HANDLE + watcher: (id)self + forMode: [m objectAtIndex: i]]; + } + } +#endif +} + ++ (BOOL) isValid +{ + return YES; +} + + (GSPerformHolder*) newForReceiver: (id)r argument: (id)a selector: (SEL)s @@ -1116,9 +884,69 @@ GSRunLoopInfoForThread(NSThread *aThread) h->modes = RETAIN(m); h->lock = l; + [subthreadsLock lock]; + + [perfArray addObject: h]; + +#if defined(__MINGW32__) + if (SetEvent(event) == 0) + { + NSLog(@"Set event failed - %@", [NSError _last]); + } +#else + if (write(outputFd, "0", 1) != 1) + { + NSLog(@"Write to pipe failed - %@", [NSError _last]); + } +#endif + + [subthreadsLock unlock]; + return h; } ++ (void) receivedEvent: (void*)data + type: (RunLoopEventType)type + extra: (void*)extra + forMode: (NSString*)mode +{ + NSRunLoop *loop = [NSRunLoop currentRunLoop]; + NSArray *toDo; + unsigned int i; + unsigned int c; + + [subthreadsLock lock]; + +#if defined(__MINGW32__) + if (ResetEvent(event) == 0) + { + NSLog(@"Reset event failed - %@", [NSError _last]); + } +#else + if (read(inputFd, &c, 1) != 1) + { + NSLog(@"Read pipe failed - %@", [NSError _last]); + } +#endif + + toDo = [[NSArray alloc] initWithArray: perfArray]; + [perfArray removeAllObjects]; + [subthreadsLock unlock]; + + c = [toDo count]; + for (i = 0; i < c; i++) + { + GSPerformHolder *h = [toDo objectAtIndex: i]; + + [loop performSelector: @selector(fire) + target: h + argument: nil + order: 0 + modes: h->modes]; + } + RELEASE(toDo); +} + - (void) dealloc { DESTROY(receiver); @@ -1136,19 +964,20 @@ GSRunLoopInfoForThread(NSThread *aThread) - (void) fire { - GSRunLoopThreadInfo *threadInfo; - if (receiver == nil) { return; // Already fired! } - threadInfo = GSRunLoopInfoForThread(GSCurrentThread()); - [threadInfo->loop cancelPerformSelectorsWithTarget: self]; + [GSRunLoopForThread(defaultThread) cancelPerformSelectorsWithTarget: self]; [receiver performSelector: selector withObject: argument]; DESTROY(receiver); DESTROY(argument); DESTROY(modes); - if (lock != nil) + if (lock == nil) + { + RELEASE(self); + } + else { NSConditionLock *l = lock; @@ -1157,75 +986,52 @@ GSRunLoopInfoForThread(NSThread *aThread) [l unlockWithCondition: 1]; } } - -- (void) invalidate -{ - if (invalidated == NO) - { - invalidated = YES; - DESTROY(receiver); - if (lock != nil) - { - NSConditionLock *l = lock; - - [lock lock]; - lock = nil; - [l unlockWithCondition: 1]; - } - } -} - -- (BOOL) isInvalidated -{ - return invalidated; -} - -- (NSArray*) modes -{ - return modes; -} @end -@implementation NSObject (NSThreadPerformAdditions) +/** + * Extra methods to permit messages to be sent to an object such that they + * are executed in the main thread.
+ * The main thread is the thread in which the GNUstep system is started, + * and where the GNUstep gui is used, it is the thread in which gui + * drawing operations must be performed. + */ +@implementation NSObject (NSMainThreadPerformAdditions) +/** + *

This method performs aSelector on the receiver, passing anObject as + * an argument, but does so in the main thread of the program. The receiver + * and anObject are both retained until the method is performed. + *

+ *

The selector is performed when the runloop of the main thread next + * runs in one of the modes specified in anArray.
+ * Where this method has been called more than once before the runloop + * of the main thread runs in the required mode, the order in which the + * operations in the main thread is done is the same as that in which + * they were added using this method. + *

+ *

If there are no modes in anArray, + * the method has no effect and simply returns immediately. + *

+ *

The argument aFlag specifies whether the method should wait until + * the selector has been performed before returning.
+ * NB. This method does not cause the runloop of + * the main thread to be run ... so if the runloop is not executed by some + * code in the main thread, the thread waiting for the perform to complete + * will block forever. + *

+ *

As a special case, if aFlag == YES and the current thread is the main + * thread, the modes array is ignored and the selector is performed immediately. + * This behavior is necessary to avoid the main thread being blocked by + * waiting for a perform which will never happen because the runloop is + * not executing. + *

+ */ - (void) performSelectorOnMainThread: (SEL)aSelector withObject: (id)anObject waitUntilDone: (BOOL)aFlag modes: (NSArray*)anArray { - /* It's possible that this method could be called before the NSThread - * class is initialised, so we check and make sure it's initiailised - * if necessary. - */ - if (defaultThread == nil) - { - [NSThread currentThread]; - } - [self performSelector: aSelector - onThread: defaultThread - withObject: anObject - waitUntilDone: aFlag - modes: anArray]; -} - -- (void) performSelectorOnMainThread: (SEL)aSelector - withObject: (id)anObject - waitUntilDone: (BOOL)aFlag -{ - [self performSelectorOnMainThread: aSelector - withObject: anObject - waitUntilDone: aFlag - modes: commonModes()]; -} - -- (void) performSelector: (SEL)aSelector - onThread: (NSThread*)aThread - withObject: (id)anObject - waitUntilDone: (BOOL)aFlag - modes: (NSArray*)anArray -{ - GSRunLoopThreadInfo *info; - NSThread *t; + NSThread *t; if ([anArray count] == 0) { @@ -1233,42 +1039,26 @@ GSRunLoopInfoForThread(NSThread *aThread) } t = GSCurrentThread(); - if (aThread == nil) + if (t == defaultThread) { - aThread = t; - } - info = GSRunLoopInfoForThread(aThread); - if (t == aThread) - { - /* Perform in current thread. - */ - if (aFlag == YES || info->loop == nil) + if (aFlag == YES) { - /* Wait until done or no run loop. - */ [self performSelector: aSelector withObject: anObject]; } else { - /* Don't wait ... schedule operation in run loop. - */ - [info->loop performSelector: aSelector - target: self - argument: anObject - order: 0 - modes: anArray]; + [GSRunLoopForThread(t) performSelector: aSelector + target: self + argument: anObject + order: 0 + modes: anArray]; } } else { - GSPerformHolder *h; + GSPerformHolder *h; NSConditionLock *l = nil; - if ([t isFinished] == YES) - { - [NSException raise: NSInternalInconsistencyException - format: @"perform on finished thread"]; - } if (aFlag == YES) { l = [[NSConditionLock alloc] init]; @@ -1279,33 +1069,31 @@ GSRunLoopInfoForThread(NSThread *aThread) selector: aSelector modes: anArray lock: l]; - [info addPerformer: h]; - if (l != nil) + + if (aFlag == YES) { [l lockWhenCondition: 1]; + RELEASE(h); [l unlock]; RELEASE(l); - if ([h isInvalidated] == YES) - { - [NSException raise: NSInternalInconsistencyException - format: @"perform on finished thread"]; - RELEASE(h); - } } - RELEASE(h); } } -- (void) performSelector: (SEL)aSelector - onThread: (NSThread*)aThread - withObject: (id)anObject - waitUntilDone: (BOOL)aFlag +/** + * Invokes -performSelectorOnMainThread:withObject:waitUntilDone:modes: + * using the supplied arguments and an array containing common modes.
+ * These modes consist of NSRunLoopMode, NSConnectionreplyMode, and if + * in an application, the NSApplication modes. + */ +- (void) performSelectorOnMainThread: (SEL)aSelector + withObject: (id)anObject + waitUntilDone: (BOOL)aFlag { - [self performSelector: aSelector - onThread: aThread - withObject: anObject - waitUntilDone: aFlag - modes: commonModes()]; + [self performSelectorOnMainThread: aSelector + withObject: anObject + waitUntilDone: aFlag + modes: commonModes()]; } @end @@ -1328,8 +1116,55 @@ GSRunLoopInfoForThread(NSThread *aThread) BOOL GSRegisterCurrentThread (void) { - return [NSThread _createThreadForCurrentPthread]; + NSThread *thread; + + /* + * Do nothing and return NO if the thread is known to us. + */ + if ((NSThread*)objc_thread_get_data() != nil) + { + return NO; + } + + /* + * Make sure the Objective-C runtime knows there is an additional thread. + */ + objc_thread_add (); + + if (threadClass == 0) + { + /* + * If the threadClass has not been set, NSThread has not been + * initialised, and there is no default thread. So we must + * initialise now ... which will make the current thread the default. + */ + NSCAssert(entered_multi_threaded_state == NO, + NSInternalInconsistencyException); + thread = [NSThread currentThread]; + } + else + { + /* + * Create the new thread object. + */ + thread = (NSThread*)NSAllocateObject (threadClass, 0, + NSDefaultMallocZone ()); + thread = [thread _initWithSelector: NULL toTarget: nil withObject: nil]; + objc_thread_set_data (thread); + ((NSThread_ivars *)thread)->_active = YES; + } + + /* + * We post the notification after we register the thread. + * NB. Even if we are the default thread, we do this to register the app + * as being multi-threaded - this is so that, if this thread is unregistered + * later, it does not leave us with a bad default thread. + */ + gnustep_base_thread_callback(); + + return YES; } + /** *

* This function is provided to let threads started by some other @@ -1340,12 +1175,44 @@ GSRegisterCurrentThread (void) * Calling this function causes a * NSThreadWillExitNotification * to be sent out, and destroys the GNUstep NSThread object - * associated with the thread (like [NSThread+exit]) but does - * not exit the underlying thread. + * associated with the thread. *

*/ void GSUnregisterCurrentThread (void) { - unregisterActiveThread(GSCurrentThread()); + NSThread *thread; + + thread = GSCurrentThread(); + + if (((NSThread_ivars *)thread)->_active == YES) + { + /* + * Set the thread to be inactive to avoid any possibility of recursion. + */ + ((NSThread_ivars *)thread)->_active = NO; + + /* + * Let observers know this thread is exiting. + */ + if (nc == nil) + { + nc = RETAIN([NSNotificationCenter defaultCenter]); + } + [nc postNotificationName: NSThreadWillExitNotification + object: thread + userInfo: nil]; + + /* + * destroy the thread object. + */ + DESTROY (thread); + + objc_thread_set_data (NULL); + + /* + * Make sure Objc runtime knows there is a thread less to manage + */ + objc_thread_remove (); + } } diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index 3fdfb613a..dfc1b9700 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -10,16 +10,16 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This library 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 Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -76,33 +76,39 @@ FIXME?: use leap seconds? */ -#import "common.h" -#define EXPOSE_NSTimeZone_IVARS 1 -#import "GNUstepBase/GSLock.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "GNUstepBase/GSLock.h" +#include #include +#include #include #include -#import "Foundation/NSArray.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSBundle.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSPortCoder.h" -#import "Foundation/NSTimeZone.h" -#import "Foundation/NSByteOrder.h" -#import "GNUstepBase/GSConfig.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GSPrivate.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSException.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSObject.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSString.h" +#include "Foundation/NSUserDefaults.h" +#include "Foundation/NSUtilities.h" +#include "Foundation/NSZone.h" +#include "Foundation/NSBundle.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSPortCoder.h" +#include "Foundation/NSTimeZone.h" +#include "Foundation/NSByteOrder.h" +#include "Foundation/NSDebug.h" +#include "GNUstepBase/GSCategories.h" +#include "GNUstepBase/GSConfig.h" +#include "GSPrivate.h" #ifdef HAVE_TZHEAD #include @@ -111,9 +117,6 @@ #include "nstzfile.h" #endif -NSString * const NSSystemTimeZoneDidChangeNotification - = @"NSSystemTimeZoneDidChangeNotification"; - /* Key for local time zone in user defaults. */ #define LOCALDBKEY @"Local Time Zone" @@ -203,7 +206,7 @@ typedef struct { } @end -#if defined(__MINGW__) +#if defined(__MINGW32__) @interface GSWindowsTimeZone : NSTimeZone { @public @@ -247,10 +250,10 @@ decode (const void *ptr) #if defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4 #if NEED_WORD_ALIGNMENT int value; - memcpy(&value, ptr, sizeof(NSInteger)); + memcpy(&value, ptr, sizeof(int)); return value; #else - return *(const NSInteger*) ptr; + return *(const int *) ptr; #endif #else /* defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4 */ const unsigned char *p = ptr; @@ -287,7 +290,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) int offset; // Offset from UTC in seconds. } -- (id) initWithOffset: (NSInteger)anOffset name: (NSString*)aName; +- (id) initWithOffset: (int)anOffset name: (NSString*)aName; @end @interface NSLocalTimeZone : NSTimeZone @@ -303,7 +306,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) - (id) initWithTimeZone: (NSTimeZone*)aZone withAbbrev: (NSString*)anAbbrev - withOffset: (NSInteger)anOffset + withOffset: (int)anOffset withDST: (BOOL)isDST; @end @@ -317,8 +320,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) /* Private methods for obtaining resource file names. */ @interface NSTimeZone (Private) -+ (NSString*) _getTimeZoneFile: (NSString*)name; -+ (void) _notified: (NSNotification*)n; ++ (NSString*) getTimeZoneFile: (NSString*)name; @end @@ -374,7 +376,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) if (zone == nil) { unichar c; - int i; + unsigned i; if ((length == 3 && ([name isEqualToString: @"GMT"] == YES @@ -462,34 +464,26 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) { if (data == nil) { - NSString *fileName; - BOOL isDir; + NSString *fileName; - fileName = [NSTimeZoneClass _getTimeZoneFile: name]; + fileName = [NSTimeZoneClass getTimeZoneFile: name]; if (fileName == nil - || ![[NSFileManager defaultManager] fileExistsAtPath: fileName - isDirectory: &isDir] || YES == isDir) - { - data = nil; - } - else - { - data = [NSData dataWithContentsOfFile: fileName]; - } - if (nil == data) -#if defined(__MINGW__) + || ![[NSFileManager defaultManager] fileExistsAtPath: fileName]) +#if defined(__MINGW32__) { zone = [[GSWindowsTimeZone alloc] initWithName: name data: 0]; - DESTROY(self); + RELEASE(self); return zone; } #else { + NSLog(@"Unknown time zone name `%@'.", name); return nil; } #endif + data = [NSData dataWithContentsOfFile: fileName]; } -#if defined(__MINGW__) +#if defined(__MINGW32__) if (!data) zone = [[GSWindowsTimeZone alloc] initWithName: name data: data]; else @@ -497,7 +491,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) zone = [[GSTimeZone alloc] initWithName: name data: data]; } } - DESTROY(self); + RELEASE(self); return zone; } @@ -570,12 +564,12 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) return self; } -- (NSInteger) secondsFromGMT +- (int) secondsFromGMT { return [[NSTimeZoneClass defaultTimeZone] secondsFromGMT]; } -- (NSInteger) secondsFromGMTForDate: (NSDate*)aDate +- (int) secondsFromGMTForDate: (NSDate*)aDate { return [[NSTimeZoneClass defaultTimeZone] secondsFromGMTForDate: aDate]; } @@ -637,7 +631,7 @@ static NSMapTable *absolutes = 0; [aCoder encodeObject: name]; } -- (id) initWithOffset: (NSInteger)anOffset name: (NSString*)aName +- (id) initWithOffset: (int)anOffset name: (NSString*)aName { GSAbsTimeZone *z; int extra; @@ -665,7 +659,7 @@ static NSMapTable *absolutes = 0; } if (anOffset > 64800) { - DESTROY(self); + RELEASE(self); return nil; } anOffset *= sign; @@ -678,7 +672,7 @@ static NSMapTable *absolutes = 0; if (z != nil) { IF_NO_GC(RETAIN(z)); - DESTROY(self); + RELEASE(self); } else { @@ -732,7 +726,7 @@ static NSMapTable *absolutes = 0; return name; } -- (NSInteger) secondsFromGMTForDate: (NSDate*)aDate +- (int) secondsFromGMTForDate: (NSDate*)aDate { return offset; } @@ -772,7 +766,7 @@ static NSMapTable *absolutes = 0; - (id) initWithTimeZone: (NSTimeZone*)aZone withAbbrev: (NSString*)anAbbrev - withOffset: (NSInteger)anOffset + withOffset: (int)anOffset withDST: (BOOL)isDST { timeZone = RETAIN(aZone); @@ -807,12 +801,12 @@ static NSMapTable *absolutes = 0; return [timeZone timeZoneDetailForDate: date]; } -- (NSInteger) timeZoneSecondsFromGMT +- (int) timeZoneSecondsFromGMT { return offset; } -- (NSInteger) timeZoneSecondsFromGMTForDate: (NSDate*)aDate +- (int) timeZoneSecondsFromGMTForDate: (NSDate*)aDate { return offset; } @@ -874,12 +868,12 @@ static NSMapTable *absolutes = 0; return self; } -- (NSInteger) timeZoneSecondsFromGMT +- (int) timeZoneSecondsFromGMT { return zone->offset; } -- (NSInteger) timeZoneSecondsFromGMTForDate: (NSDate*)aDate +- (int) timeZoneSecondsFromGMTForDate: (NSDate*)aDate { return zone->offset; } @@ -1036,7 +1030,7 @@ static NSMapTable *absolutes = 0; path = _time_zone_path (ABBREV_MAP, nil); if (path != nil) { -#if defined(__MINGW__) +#if defined(__MINGW32__) unichar mode[3]; mode[0] = 'r'; @@ -1293,11 +1287,6 @@ static NSMapTable *absolutes = 0; localTimeZone = [[NSLocalTimeZone alloc] init]; zone_mutex = [GSLazyRecursiveLock new]; - - [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(_notified:) - name: NSUserDefaultsDidChangeNotification - object: nil]; } } @@ -1324,9 +1313,6 @@ static NSMapTable *absolutes = 0; { [zone_mutex unlock]; } - [[NSNotificationCenter defaultCenter] - postNotificationName: NSSystemTimeZoneDidChangeNotification - object: nil]; } /** @@ -1370,7 +1356,6 @@ static NSMapTable *absolutes = 0; if (systemTimeZone == nil) { NSString *localZoneString = nil; - NSString *localZoneSource = nil; /* * setup default value in case something goes wrong. @@ -1380,8 +1365,6 @@ static NSMapTable *absolutes = 0; /* * Try to get timezone from user defaults database */ - localZoneSource = [NSString stringWithFormat: - @"NSUserDefaults: '%@'", LOCALDBKEY]; localZoneString = [[NSUserDefaults standardUserDefaults] stringForKey: LOCALDBKEY]; @@ -1390,7 +1373,6 @@ static NSMapTable *absolutes = 0; */ if (localZoneString == nil) { - localZoneSource = _(@"environment variable: 'GNUSTEP_TZ'"); localZoneString = [[[NSProcessInfo processInfo] environment] objectForKey: @"GNUSTEP_TZ"]; } @@ -1400,8 +1382,6 @@ static NSMapTable *absolutes = 0; if (localZoneString == nil) { NSString *f = _time_zone_path(LOCAL_TIME_FILE, nil); - - localZoneSource = [NSString stringWithFormat: @"file: '%@'", f]; if (f != nil) { localZoneString = [NSString stringWithContentsOfFile: f]; @@ -1413,7 +1393,6 @@ static NSMapTable *absolutes = 0; */ if (localZoneString == nil) { - localZoneSource = _(@"environment variable: 'TZ'"); localZoneString = [[[NSProcessInfo processInfo] environment] objectForKey: @"TZ"]; } @@ -1425,8 +1404,6 @@ static NSMapTable *absolutes = 0; #if defined(HAVE_TZHEAD) && defined(TZDEFAULT) tzdir = RETAIN([NSString stringWithUTF8String: TZDIR]); localZoneString = [NSString stringWithUTF8String: TZDEFAULT]; - localZoneSource = [NSString stringWithFormat: - @"file (TZDEFAULT): '%@'", localZoneString]; localZoneString = [localZoneString stringByResolvingSymlinksInPath]; #else NSFileManager *dflt = [NSFileManager defaultManager]; @@ -1434,8 +1411,6 @@ static NSMapTable *absolutes = 0; if ([dflt fileExistsAtPath: SYSTEM_TIME_FILE]) { localZoneString = SYSTEM_TIME_FILE; - localZoneSource = [NSString stringWithFormat: - @"file (SYSTEM_TIME_FILE): '%@'", localZoneString]; localZoneString = [localZoneString stringByResolvingSymlinksInPath]; /* Guess what tzdir is */ @@ -1446,28 +1421,24 @@ static NSMapTable *absolutes = 0; { tzdir = [tzdir stringByDeletingLastPathComponent]; } - if ([tzdir length] <= 2) + if ([tzdir length] > 2) + { + RETAIN(tzdir); + } + else { localZoneString = tzdir = nil; } -#if !GS_WITH_GC - else - { - [tzdir retain]; - } -#endif } #endif if (localZoneString != nil && [localZoneString hasPrefix: tzdir]) { /* This must be the time zone name */ localZoneString = AUTORELEASE([localZoneString mutableCopy]); - [(NSMutableString*)localZoneString deleteCharactersInRange: - NSMakeRange(0, [tzdir length])]; - while ([localZoneString hasPrefix: @"/"]) + [(NSMutableString *)localZoneString deletePrefix: tzdir]; + if ([localZoneString hasPrefix: @"/"]) { - [(NSMutableString*)localZoneString deleteCharactersInRange: - NSMakeRange(0, 1)]; + [(NSMutableString *)localZoneString deletePrefix: @"/"]; } } else @@ -1481,14 +1452,13 @@ static NSMapTable *absolutes = 0; */ if (localZoneString == nil) { - localZoneSource = @"function: 'tzset()/tzname'"; tzset(); if (tzname[0] != NULL && *tzname[0] != '\0') localZoneString = [NSString stringWithUTF8String: tzname[0]]; } #endif -#if defined(__MINGW__) +#if defined(__MINGW32__) /* * Try to get timezone from windows system call. */ @@ -1496,7 +1466,6 @@ static NSMapTable *absolutes = 0; TIME_ZONE_INFORMATION tz; DWORD DST = GetTimeZoneInformation(&tz); - localZoneSource = @"function: 'GetTimeZoneInformation()'"; if (DST == TIME_ZONE_ID_DAYLIGHT) { localZoneString = [NSString stringWithCharacters: tz.DaylightName @@ -1514,109 +1483,6 @@ static NSMapTable *absolutes = 0; { NSDebugLLog (@"NSTimeZone", @"Using zone %@", localZoneString); zone = [defaultPlaceholderTimeZone initWithName: localZoneString]; - if (zone == nil) - { - NSArray *possibleZoneNames; - - /* - It is not guaranteed on some systems (e.g., Ubuntu) that - SYSTEM_TIME_FILE is a symlink. This file is more probably - a copy of a zoneinfo file. The above time zone detecting - approach can lead to the situation when we can only know - about the time zone abbreviation (localZoneString) and - (for some time zone abbreviations) the corresponding list - of possible time zone names (e.g. SAMT is valid for - Pacific/Samoa, Pacific/Pago_Pago, Pacific/Apia, - Asia/Samarkand, Europe/Samara, US/Samoa). - In such a case the time zone can be selected - from the list by comparing the content of SYSTEM_TIME_FILE - and the content of zoneinfo files corresponding to the items - of that list. - */ - possibleZoneNames = [[self abbreviationMap] - objectForKey: localZoneString]; - if (possibleZoneNames != nil) - { - NSEnumerator *en = [possibleZoneNames objectEnumerator]; - NSString *zoneName; - NSFileManager *dflt = [NSFileManager defaultManager]; - - while ((zoneName = [en nextObject]) != nil) - { - NSString *fileName = [self _getTimeZoneFile: zoneName]; - - if (fileName != nil - && [dflt contentsEqualAtPath: fileName - andPath: SYSTEM_TIME_FILE]) - { - zone = [[self timeZoneWithName: zoneName] retain]; - - if (zone != nil) - { - GSPrintf(stderr, -@"\nIt seems that your operating system does not have a valid timezone name\n" -@"configured and is using an abbreviation instead. By comparing timezone\n" -@"file data it is has been possible to find the actual timezone used, but\n" -@"doing that is a slow process.\n" -@"\nYou can avoid slowness of this time zone detecting approach\n" -@"by setting the environment variable TZ='%@'\n" -@"Or You can override the timezone name by setting the '%@'\n" -@"NSUserDefault via the 'defaults' command line utility, a Preferences\n" -@"application, or some other utility.\n" -@"eg \"defaults write NSGlobalDomain '%@' '%@'\"\n\n", -zoneName, LOCALDBKEY, LOCALDBKEY, zoneName); - break; - } - } - } - } - } - if (zone == nil) - { - if (zone == nil) - { - GSPrintf(stderr, -@"\nUnable to create time zone for name: '%@'\n" -@"(source '%@').\n", localZoneString, localZoneSource); - } - if ([localZoneSource hasPrefix: @"file"] - || [localZoneSource hasPrefix: @"function"]) - { - GSPrintf(stderr, -@"\nIt seems that your operating system does not have a valid timezone name\n" -@"configured (it could be that some other software has set a, possibly\n" -@"ambiguous, timezone abbreviation rather than a name) ... please correct\n" -@"that or override by setting a timezone name (such as 'Europe/London'\n" -@"or 'America/Chicago').\n"); - } - GSPrintf(stderr, -@"\nYou can override the timezone name by setting the '%@'\n" -@"NSUserDefault via the 'defaults' command line utility, a Preferences\n" -@"application, or some other utility.\n" -@"eg \"defaults write NSGlobalDomain '%@' 'Africa/Nairobi'\"\n" -@"See '%@'\n" -@"for the standard timezones such as 'GB-Eire' or 'America/Chicago'.\n", -LOCALDBKEY, LOCALDBKEY, _time_zone_path (ZONES_DIR, nil)); - zone = [[self timeZoneWithAbbreviation: localZoneString] retain]; - if (zone != nil) - { - NSInteger s; - char sign = '+'; - - s = [zone secondsFromGMT]; - if (s < 0) - { - sign = '-'; - s = -s; - } - GSPrintf(stderr, -@"\nSucceeded in treating '%@' as a timezone abbreviation,\n" -@"but abbreviations do not uniquely represent timezones, so this may\n" -@"not have found the timezone you were expecting. The timezone found\n" -@"was '%@' (currently UTC%c%02d%02d)\n\n", -localZoneString, [zone name], sign, s/3600, (s/60)%60); - } - } } else { @@ -1683,7 +1549,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); path = _time_zone_path (REGIONS_FILE, nil); if (path != nil) { -#if defined(__MINGW__) +#if defined(__MINGW32__) unichar mode[3]; mode[0] = 'r'; @@ -1713,7 +1579,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); } else { - NSString *zonedir = [NSTimeZone _getTimeZoneFile: @"WET"]; + NSString *zonedir = [NSTimeZone getTimeZoneFile: @"WET"]; if (tzdir != nil) { @@ -1727,11 +1593,12 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); { NSTimeZone *zone = nil; BOOL isDir; + + // FIXME: check file validity. path = [zonedir stringByAppendingPathComponent: name]; if ([mgr fileExistsAtPath: path isDirectory: &isDir] - && isDir == NO - && [[path pathExtension] isEqual: @"tab"] == NO) + && isDir == NO) { zone = [zoneDictionary objectForKey: name]; if (zone == nil) @@ -1739,12 +1606,8 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); NSData *data; data = [NSData dataWithContentsOfFile: path]; - /* We should really make sure this is a real - zone file and not something extra that happens - to be in this directory, but initWithName:data: - will do this anyway and log a message if not. */ zone = [[self alloc] initWithName: name data: data]; - IF_NO_GC([zone autorelease];) + AUTORELEASE(zone); } if (zone != nil) { @@ -1807,7 +1670,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); * Time zones with an offset of more than +/- 18 hours are disallowed, * and nil is returned. */ -+ (NSTimeZone*) timeZoneForSecondsFromGMT: (NSInteger)seconds ++ (NSTimeZone*) timeZoneForSecondsFromGMT: (int)seconds { NSTimeZone *zone; @@ -2023,7 +1886,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); * from Greenwich Mean Time at the current date and time.
* Invokes -secondsFromGMTForDate: */ -- (NSInteger) secondsFromGMT +- (int) secondsFromGMT { return [self secondsFromGMTForDate: [NSDate date]]; } @@ -2034,7 +1897,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); * If the time zone uses daylight savings time, the returned value * will vary at different times of year. */ -- (NSInteger) secondsFromGMTForDate: (NSDate*)aDate +- (int) secondsFromGMTForDate: (NSDate*)aDate { NSTimeZoneDetail *detail; int offset; @@ -2069,32 +1932,6 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); return [self name]; } -- (NSTimeInterval) daylightSavingTimeOffsetForDate: (NSDate *)aDate -{ - return 0.0; // FIXME -} - -- (NSDate *) nextDaylightSavingTimeTransitionAfterDate: (NSDate *)aDate -{ - return nil; // FIXME; -} - -- (NSTimeInterval) daylightSavingTimeOffset -{ - return 0.0; // FIXME -} - -- (NSDate *) nextDaylightSavingTimeTransition -{ - return nil; // FIXME; -} - -- (NSString *)localizedName: (NSTimeZoneNameStyle)style - locale: (NSLocale *)locale -{ - return nil; // FIXME; -} - @end /** @@ -2133,7 +1970,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60); /** * DEPRECATED: Class is no longer used. */ -- (NSInteger) timeZoneSecondsFromGMT +- (int) timeZoneSecondsFromGMT { [self subclassResponsibility: _cmd]; return 0; @@ -2162,11 +1999,10 @@ static NSString *zoneDirs[] = { /** * Returns the path to the named zone info file. */ -+ (NSString*) _getTimeZoneFile: (NSString *)name ++ (NSString*) getTimeZoneFile: (NSString *)name { static BOOL beenHere = NO; NSString *dir = nil; - BOOL isDir; if (beenHere == NO && tzdir == nil) { @@ -2202,8 +2038,7 @@ static NSString *zoneDirs[] = { /* Use the system zone info if possible, otherwise, use our installed info. */ if (tzdir && [[NSFileManager defaultManager] fileExistsAtPath: - [tzdir stringByAppendingPathComponent: name] isDirectory: &isDir] == YES - && isDir == NO) + [tzdir stringByAppendingPathComponent: name]] == YES) { dir = tzdir; } @@ -2214,24 +2049,10 @@ static NSString *zoneDirs[] = { return [dir stringByAppendingPathComponent: name]; } -+ (void) _notified: (NSNotification*)n -{ - NSString *name; - - /* If the name of the system time zone has changed ... - * get a new system time zone. - */ - name = [[NSUserDefaults standardUserDefaults] stringForKey: LOCALDBKEY]; - if ([name length] > 0 && [name isEqual: [[self systemTimeZone] name]] == NO) - { - [self resetSystemTimeZone]; - [self systemTimeZone]; - } -} @end -#if defined(__MINGW__) +#if defined(__MINGW32__) /* Timezone information data as stored in the registry */ typedef struct TZI_format { LONG Bias; @@ -2262,10 +2083,16 @@ lastDayOfGregorianMonth(int month, int year) /* IMPORT from NSCalendar date */ void -GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, - NSInteger*hour, NSInteger*minute, NSInteger*second, NSInteger*mil); +GSBreakTime(NSTimeInterval when, int *year, int *month, int *day, + int *hour, int *minute, int *second, int *mil); + +/* FIXME + * It's not unicode ... which is OK as the timezone registry + * names are ascii ... but we ought to be consistent. + */ + @implementation GSWindowsTimeZone - (NSString*) abbreviationForDate: (NSDate*)aDate @@ -2291,194 +2118,209 @@ GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, - (id) initWithName: (NSString*)name data: (NSData*)data { - HKEY regDirKey; - BOOL isNT = NO, regFound=NO; + HKEY regDirKey; + BOOL isNT = NO; + BOOL regFound = NO; /* Open the key in the local machine hive where * the time zone data is stored. */ - if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", + if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", 0, KEY_READ, ®DirKey)) { - isNT=YES; - regFound=YES; + isNT = YES; + regFound = YES; } else { - if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", - 0, - KEY_READ, - ®DirKey)) - { - regFound=YES; - } + if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", + 0, + KEY_READ, + ®DirKey)) + { + regFound = YES; + } } if (regFound) { /* Iterate over all subKeys in the registry to find the right one. - Unfortunately name is a localized value. The keys in the registry are - unlocalized names. */ - wchar_t achKey[255]; // buffer for subkey name - DWORD cbName; // size of name string - wchar_t achClass[MAX_PATH] = L""; // buffer for class name - DWORD cchClassName = MAX_PATH; // size of class string - DWORD cSubKeys=0; // number of subkeys - DWORD cbMaxSubKey; // longest subkey size - DWORD cchMaxClass; // longest class string - DWORD cValues; // number of values for key - DWORD cchMaxValue; // longest value name - DWORD cbMaxValueData; // longest value data - DWORD cbSecurityDescriptor; // size of security descriptor - FILETIME ftLastWriteTime; // last write time - DWORD i, retCode; + Unfortunately name is a localized value. The keys in the registry are + unlocalized names. */ + CHAR achKey[255]; // buffer for subkey name + DWORD cbName; // size of name string + CHAR achClass[MAX_PATH] = ""; // buffer for class name + DWORD cchClassName = MAX_PATH; // size of class string + DWORD cSubKeys=0; // number of subkeys + DWORD cbMaxSubKey; // longest subkey size + DWORD cchMaxClass; // longest class string + DWORD cValues; // number of values for key + DWORD cchMaxValue; // longest value name + DWORD cbMaxValueData; // longest value data + DWORD cbSecurityDescriptor; // size of security descriptor + FILETIME ftLastWriteTime; // last write time + DWORD i; + DWORD retCode; BOOL tzFound = NO; - - /* Get the class name and the value count. */ - retCode = RegQueryInfoKeyW( - regDirKey, // key handle - achClass, // buffer for class name - &cchClassName, // size of class string - NULL, // reserved - &cSubKeys, // number of subkeys - &cbMaxSubKey, // longest subkey size - &cchMaxClass, // longest class string - &cValues, // number of values for this key - &cchMaxValue, // longest value name - &cbMaxValueData, // longest value data - &cbSecurityDescriptor, // security descriptor - &ftLastWriteTime); // last write time + + /* Get the class name and the value count. */ + retCode = RegQueryInfoKeyA( + regDirKey, // key handle + achClass, // buffer for class name + &cchClassName, // size of class string + NULL, // reserved + &cSubKeys, // number of subkeys + &cbMaxSubKey, // longest subkey size + &cchMaxClass, // longest class string + &cValues, // number of values for this key + &cchMaxValue, // longest value name + &cbMaxValueData, // longest value data + &cbSecurityDescriptor, // security descriptor + &ftLastWriteTime); // last write time if (cSubKeys && (retCode == ERROR_SUCCESS)) - { - unsigned wLen = [name length]; - wchar_t *wName = malloc((wLen+1) * sizeof(wchar_t)); + { + const char *cName = [name cString]; - if (wName) - { - [name getCharacters: wName]; - wName[wLen] = 0; - for (i = 0; i < cSubKeys && !tzFound; i++) - { - cbName = 255; - - retCode = RegEnumKeyExW(regDirKey, i, achKey, &cbName, - NULL, NULL, NULL, &ftLastWriteTime); - if (retCode == ERROR_SUCCESS) - { - wchar_t keyBuffer[16384]; - HKEY regKey; - - if (isNT) - wcscpy(keyBuffer, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\"); - else - wcscpy(keyBuffer, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Time Zones\\"); - - wcscat(keyBuffer, achKey); - if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_LOCAL_MACHINE, - keyBuffer, 0, KEY_READ, ®Key)) - { - wchar_t buf[256]; - wchar_t standardName[256]; - wchar_t daylightName[256]; - DWORD bufsize; - DWORD type; + for (i = 0; i < cSubKeys && !tzFound; i++) + { + cbName = 255; + + retCode = RegEnumKeyExA(regDirKey, + i, + achKey, + &cbName, + NULL, + NULL, + NULL, + &ftLastWriteTime); + if (retCode == ERROR_SUCCESS) + { + char keyBuffer[16384]; + HKEY regKey; + + if (isNT) + { + sprintf(keyBuffer, "SOFTWARE\\Microsoft\\Windows NT" + "\\CurrentVersion\\Time Zones\\%s", achKey); + } + else + { + sprintf(keyBuffer, "SOFTWARE\\Microsoft\\Windows" + "\\CurrentVersion\\Time Zones\\%s", achKey); + } + + if (ERROR_SUCCESS == RegOpenKeyExA(HKEY_LOCAL_MACHINE, + keyBuffer, + 0, + KEY_READ, + ®Key)) + { + char buf[256]; + char standardName[256]; + char daylightName[256]; + DWORD bufsize; + DWORD type; - /* check standardname */ - standardName[0] = L'\0'; - bufsize = sizeof(buf); - if (ERROR_SUCCESS == RegQueryValueExW(regKey, - L"Std", 0, &type, (BYTE *)buf, &bufsize)) - { - wcscpy(standardName, buf); - if (wcscmp(standardName, wName) == 0) - tzFound = YES; - } - - /* check daylightname */ - daylightName[0] = L'\0'; - bufsize = sizeof(buf); - if (ERROR_SUCCESS == RegQueryValueExW(regKey, - L"Dlt", 0, &type, (BYTE *)buf, &bufsize)) - { - wcscpy(daylightName, buf); - if (wcscmp(daylightName, wName) == 0) - tzFound = YES; - } + /* check standardname */ + standardName[0]='\0'; + bufsize=sizeof(buf); + if (ERROR_SUCCESS == RegQueryValueExA(regKey, + "Std", + 0, + &type, + buf, + &bufsize)) + { + strcpy(standardName, buf); + if (strcmp(standardName, cName) == 0) + tzFound = YES; + } - if (tzFound) - { - /* Read in the time zone data */ - bufsize = sizeof(buf); - if (ERROR_SUCCESS == RegQueryValueExW(regKey, - L"TZI", 0, &type, (BYTE *)buf, &bufsize)) - { - TZI *tzi = (void*)buf; - Bias = tzi->Bias; - StandardBias = tzi->StandardBias; - DaylightBias = tzi->DaylightBias; - StandardDate = tzi->StandardDate; - DaylightDate = tzi->DaylightDate; - } - - /* Set the standard name for the time zone. */ - if (wcslen(standardName)) - { - int a, b; + /* check daylightname */ + daylightName[0]='\0'; + bufsize = sizeof(buf); + if (ERROR_SUCCESS == RegQueryValueExA(regKey, + "Dlt", + 0, + &type, + buf, + &bufsize)) + { + strcpy(daylightName, buf); + if (strcmp(daylightName, cName) == 0) + tzFound = YES; + } - ASSIGN(timeZoneName, - [NSString stringWithCharacters: standardName - length: wcslen(standardName)]); + if (tzFound) + { + /* Read in the time zone data */ + bufsize = sizeof(buf); + if (ERROR_SUCCESS == RegQueryValueExA(regKey, + "TZI", + 0, + &type, + buf, + &bufsize)) + { + TZI *tzi = (void*)buf; + Bias = tzi->Bias; + StandardBias = tzi->StandardBias; + DaylightBias = tzi->DaylightBias; + StandardDate = tzi->StandardDate; + DaylightDate = tzi->DaylightDate; + } + + /* Set the standard name for the time zone. */ + if (strlen(standardName)) + { + int a, b; - /* Abbr generated here is IMHO - * a bit suspicous but I kept it */ - for (a = 0, b = 0; standardName[a]; a++) - { - if (iswupper(standardName[a])) - standardName[b++] = standardName[a]; - } - standardName[b] = L'\0'; - ASSIGN(timeZoneNameAbbr, - [NSString stringWithCharacters: standardName - length: wcslen(standardName)]); - } + ASSIGN(timeZoneName, + [NSString stringWithUTF8String: standardName]); - /* Set the daylight savings name - * for the time zone. */ - if (wcslen(daylightName)) - { - int a, b; + /* Abbr generated here is IMHO a + * bit suspicous but I kept it */ + for (a = 0, b = 0; standardName[a]; a++) + { + if (isupper(standardName[a])) + standardName[b++] = standardName[a]; + } + standardName[b] = 0; + ASSIGN(timeZoneNameAbbr, + [NSString stringWithUTF8String: standardName]); + } - ASSIGN(daylightZoneName, - [NSString stringWithCharacters: daylightName - length: wcslen(daylightName)]); + /* Set the daylight savings name for the time zone. */ + if (strlen(daylightName)) + { + int a, b; - /* Abbr generated here is IMHO - * a bit suspicous but I kept it */ - for (a = 0, b = 0; daylightName[a]; a++) - { - if (iswupper(daylightName[a])) - daylightName[b++] = daylightName[a]; - } - daylightName[b] = L'\0'; - ASSIGN(daylightZoneNameAbbr, - [NSString stringWithCharacters: daylightName - length: wcslen(daylightName)]); - } - } - RegCloseKey(regKey); - } - } - } - free(wName); - } - } + ASSIGN(daylightZoneName, + [NSString stringWithUTF8String: daylightName]); + + /* Abbr generated here is IMHO + * a bit suspicous but I kept it */ + for (a = 0, b = 0; daylightName[a]; a++) + { + if (isupper(daylightName[a])) + daylightName[b++] = daylightName[a]; + } + daylightName[b] = 0; + ASSIGN(daylightZoneNameAbbr, + [NSString stringWithUTF8String: daylightName]); + } + } + RegCloseKey(regKey); + } + } + } + } RegCloseKey(regDirKey); } - return self; } @@ -2524,9 +2366,9 @@ GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, { return NO; } - } + } - dow = ((NSInteger)((when / 86400.0) + GREGORIAN_REFERENCE)) % 7; + dow = ((int)((when / 86400.0) + GREGORIAN_REFERENCE)) % 7; if (dow < 0) dow += 7; @@ -2535,13 +2377,13 @@ GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, daylightdate = day - dow + DaylightDate.wDayOfWeek; maxdate = lastDayOfGregorianMonth(DaylightDate.wMonth, year)-7; while (daylightdate > 7) - daylightdate -= 7; + daylightdate-=7; if (daylightdate < 1) daylightdate += 7; - count = DaylightDate.wDay; - while (count > 1 && daylightdate < maxdate) + count=DaylightDate.wDay; + while (count>1 && daylightdate < maxdate) { - daylightdate += 7; + daylightdate+=7; count--; } if (day > daylightdate) @@ -2569,13 +2411,13 @@ GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, daylightdate = day - dow + StandardDate.wDayOfWeek; maxdate = lastDayOfGregorianMonth(StandardDate.wMonth, year)-7; while (daylightdate > 7) - daylightdate -= 7; + daylightdate-=7; if (daylightdate < 1) daylightdate += 7; - count = StandardDate.wDay; - while (count > 1 && daylightdate < maxdate) + count=StandardDate.wDay; + while (count>1 && daylightdate < maxdate) { - daylightdate += 7; + daylightdate+=7; count--; } if (day > daylightdate) @@ -2616,7 +2458,7 @@ GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, } } -- (NSInteger) secondsFromGMTForDate: (NSDate*)aDate +- (int) secondsFromGMTForDate: (NSDate*)aDate { if ([self isDaylightSavingTimeForDate: aDate]) return -Bias*60 - DaylightBias*60; @@ -2666,7 +2508,7 @@ GSBreakTime(NSTimeInterval when, NSInteger*year, NSInteger*month, NSInteger*day, return [self name]; } @end -#endif // __MINGW__ +#endif // __MINGW32__ @implementation GSTimeZone @@ -2946,7 +2788,7 @@ newDetailInZoneForType(GSTimeZone *zone, TypeInfo *type) return timeZoneName; } -- (NSInteger) secondsFromGMTForDate: (NSDate*)aDate +- (int) secondsFromGMTForDate: (NSDate*)aDate { TypeInfo *type = chop([aDate timeIntervalSince1970], self); diff --git a/Source/NSTimer.m b/Source/NSTimer.m index 7db763216..d837815ce 100644 --- a/Source/NSTimer.m +++ b/Source/NSTimer.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,13 +27,12 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSTimer_IVARS 1 -#import "Foundation/NSTimer.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSException.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSInvocation.h" +#include "config.h" +#include "Foundation/NSTimer.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSException.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSInvocation.h" @class NSGDate; @interface NSGDate : NSObject // Help the compiler @@ -41,16 +40,12 @@ static Class NSDate_class; /** - *

An NSTimer provides a way to send a message at some time in + * An NSTimer provides a way to send a message at some time in * the future, possibly repeating every time a fixed interval has passed. To * use a timer, you can either create one that will automatically be added to * the run loop in the current thread (using the -addTimer:forMode: method), * or you can create it without adding it then add it to an [NSRunLoop] * explicitly later. - *

- *

NB. You may not use -init or +new to create a timer, as the timer must - * be properly initialised to send an action after some interval. - *

*/ @implementation NSTimer @@ -62,29 +57,22 @@ static Class NSDate_class; } } -/* For MacOS-X compatibility, this returns nil. - */ -- (id) init -{ - DESTROY(self); - return nil; -} - -/** +/** + * * Initialise the receive, a newly allocated NSTimer object.
+ * The fd argument specifies an initial fire date ... if it is not + * supplied (a nil object) then the ti argument is used to create + * a start date relative to the current time.
* The ti argument specifies the time (in seconds) between the firing. * If it is less than or equal to 0.0 then a small interval is chosen * automatically.
- * The fd argument specifies an initial fire date copied by the timer... - * if it is not supplied (a nil object) then the ti argument is used to - * create a start date relative to the current time.
* The f argument specifies whether the timer will fire repeatedly * or just once.
* If the selector argument is zero, then then object is an invocation * to be used when the timer fires. otherwise, the object is sent the * message specified by the selector and with the timer as an argument.
- * The object and info arguments will be retained until the timer is - * invalidated. + * The fd, object and info arguments will be retained until the timer is + * invalidated.
*/ - (id) initWithFireDate: (NSDate*)fd interval: (NSTimeInterval)ti @@ -93,32 +81,24 @@ static Class NSDate_class; userInfo: (id)info repeats: (BOOL)f { - if (ti <= 0.0) + if (ti <= 0) { ti = 0.0001; } + _interval = ti; if (fd == nil) { _date = [[NSDate_class allocWithZone: NSDefaultMallocZone()] - initWithTimeIntervalSinceNow: ti]; + initWithTimeIntervalSinceNow: _interval]; } else { - _date = [fd copyWithZone: NSDefaultMallocZone()]; + _date = [fd copy]; } _target = RETAIN(object); _selector = selector; _info = RETAIN(info); - if (f == YES) - { - _repeats = YES; - _interval = ti; - } - else - { - _repeats = NO; - _interval = 0.0; - } + _repeats = f; return self; } @@ -224,41 +204,78 @@ static Class NSDate_class; */ - (void) fire { - if (_selector == 0) + id target; + + /* We retain the target so it won't be deallocated while we are using it + * (if this timer gets invalidated while we are firing). + */ + target = [_target retain]; + + /* We check that we have not been invalidated before we fire. + */ + if (NO == _invalidated) { - NS_DURING + if (_selector == 0) { - [(NSInvocation*)_target invoke]; + NS_DURING + { + [(NSInvocation*)target invoke]; + } + NS_HANDLER + { + NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') " + @"raised during posting of timer with target %p " + @"and selector '%@'", + [localException name], [localException reason], target, + NSStringFromSelector([target selector])); + } + NS_ENDHANDLER } - NS_HANDLER + else { - NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') " - @"raised during posting of timer with target %p and selector '%@'", - [localException name], [localException reason], _target, - NSStringFromSelector([_target selector])); + NS_DURING + { + [target performSelector: _selector withObject: self]; + } + NS_HANDLER + { + NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') " + @"raised during posting of timer with target %p and " + @"selector '%@'", + [localException name], [localException reason], target, + NSStringFromSelector(_selector)); + } + NS_ENDHANDLER } - NS_ENDHANDLER - } - else - { - NS_DURING - { - [_target performSelector: _selector withObject: self]; - } - NS_HANDLER - { - NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') " - @"raised during posting of timer with target %p and selector '%@'", - [localException name], [localException reason], _target, - NSStringFromSelector(_selector)); - } - NS_ENDHANDLER } + [target release]; if (_repeats == NO) { [self invalidate]; } + else if (_invalidated == NO) + { + extern NSTimeInterval GSTimeNow(); + NSTimeInterval now = GSTimeNow(); + NSTimeInterval nxt = [_date timeIntervalSinceReferenceDate]; + int inc = -1; + + while (nxt <= now) // xxx remove this + { + inc++; + nxt += _interval; + } +#ifdef LOG_MISSED + if (inc > 0) + { + NSLog(@"Missed %d timeouts at %f second intervals", inc, _interval); + } +#endif + RELEASE(_date); + _date = [[NSDate_class allocWithZone: NSDefaultMallocZone()] + initWithTimeIntervalSinceReferenceDate: nxt]; + } } /** @@ -269,8 +286,6 @@ static Class NSDate_class; */ - (void) invalidate { - /* OPENSTEP allows this method to be called multiple times. */ - _invalidated = YES; if (_target != nil) { DESTROY(_target); @@ -279,6 +294,9 @@ static Class NSDate_class; { DESTROY(_info); } + /* OPENSTEP allows this method to be called multiple times. */ + //NSAssert(_invalidated == NO, NSInternalInconsistencyException); + _invalidated = YES; } /** @@ -317,8 +335,7 @@ static Class NSDate_class; } /** - * Returns the interval between firings, or zero if the timer - * does not repeat. + * Returns the interval between firings. */ - (NSTimeInterval) timeInterval { diff --git a/Source/NSURL.m b/Source/NSURL.m index b7374b121..45a884b14 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -10,7 +10,7 @@ This file is part of the GNUstep Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -19,7 +19,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -36,20 +36,21 @@ function may be incorrect * I've put 2 functions to make tests. You can add your own tests * Some functions are not implemented */ -#import "common.h" -#define EXPOSE_NSURL_IVARS 1 -#import "Foundation/NSArray.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSPortCoder.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSURL.h" -#import "Foundation/NSURLHandle.h" -#import "Foundation/NSValue.h" +#include "config.h" +#include "Foundation/NSObject.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSString.h" +#include "Foundation/NSException.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSURLHandle.h" +#include "Foundation/NSURL.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSZone.h" NSString * const NSURLErrorDomain = @"NSURLErrorDomain"; NSString * const NSErrorFailingURLStringKey = @"NSErrorFailingURLStringKey"; @@ -87,7 +88,7 @@ static NSLock *clientsLock = nil; static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize); static id clientForHandle(void *data, NSURLHandle *hdl); static char *findUp(char *str); -static char *unescape(const char *from, char * to); +static void unescape(const char *from, char * to); /** * Build an absolute URL as a C string @@ -140,11 +141,7 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize) len += strlen(rel->fragment) + 1; // #fragment } -#if GS_WITH_GC - ptr = buf = (char*)NSAllocateCollectable(len, 0); -#else - ptr = buf = (char*)NSZoneMalloc(NSDefaultMallocZone(), len); -#endif + ptr = buf = (char*)NSZoneMalloc(GSAtomicMallocZone(), len); if (rel->scheme != 0) { @@ -402,7 +399,7 @@ static BOOL legal(const char *str, const char *extras) /* * Convert percent escape sequences to individual characters. */ -static char *unescape(const char *from, char * to) +static void unescape(const char *from, char * to) { while (*from != '\0') { @@ -463,7 +460,6 @@ static char *unescape(const char *from, char * to) } } *to = '\0'; - return to; } @@ -529,12 +525,7 @@ static unsigned urlAlign; * Initialise by building a URL string from the supplied parameters * and calling -initWithString:relativeToURL:
* This method adds percent escapes to aPath if it contains characters - * which need escaping.
- * Accepts RFC2732 style IPv6 host addresses either with or without the - * enclosing square brackets (MacOS-X at least up to version 10.5 does - * not handle these correctly, but GNUstep does).
- * Permits the 'aHost' part to contain 'username:password@host:port' or - * 'host:port' in addition to a simple host name or address. + * which need ascaping. */ - (id) initWithScheme: (NSString*)aScheme host: (NSString*)aHost @@ -546,30 +537,6 @@ static unsigned urlAlign; = [aPath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; if ([aHost length] > 0) { - NSRange r = [aHost rangeOfString: @"@"]; - NSString *auth = nil; - - /* Allow for authentication (username:password) before actual host. - */ - if (r.length > 0) - { - auth = [aHost substringToIndex: r.location]; - aHost = [aHost substringFromIndex: NSMaxRange(r)]; - } - - /* Add square brackets around ipv6 address if necessary - */ - if ([[aHost componentsSeparatedByString: @":"] count] > 2 - && [aHost hasPrefix: @"["] == NO) - { - aHost = [NSString stringWithFormat: @"[%@]", aHost]; - } - - if (auth != nil) - { - aHost = [NSString stringWithFormat: @"%@@%@", auth, aHost]; - } - if ([aPath length] > 0) { /* @@ -622,15 +589,10 @@ static unsigned urlAlign; */ - (id) initFileURLWithPath: (NSString*)aPath { - NSFileManager *mgr = [NSFileManager defaultManager]; - BOOL flag = NO; + BOOL flag = NO; - if ([aPath isAbsolutePath] == NO) - { - aPath = [[mgr currentDirectoryPath] - stringByAppendingPathComponent: aPath]; - } - if ([mgr fileExistsAtPath: aPath isDirectory: &flag] == YES) + if ([[NSFileManager defaultManager] fileExistsAtPath: aPath + isDirectory: &flag] == YES) { if ([aPath isAbsolutePath] == NO) { @@ -642,7 +604,7 @@ static unsigned urlAlign; } } self = [self initWithScheme: NSURLFileScheme - host: @"localhost" + host: nil path: aPath]; return self; } @@ -660,32 +622,21 @@ static unsigned urlAlign; /** * Initialised using aUrlString and aBaseUrl. The value of aBaseUrl * may be nil, but aUrlString must be non-nil.
- * Accepts RFC2732 style IPv6 host addresses.
- * Parses a string wihthout a scheme as a simple path.
- * Parses an empty string as an empty path.
* If the string cannot be parsed the method returns nil. */ - (id) initWithString: (NSString*)aUrlString relativeToURL: (NSURL*)aBaseUrl { /* RFC 2396 'reserved' characters ... - * as modified by RFC2732 */ - static const char *reserved = ";/?:@&=+$,[]"; + static const char *reserved = ";/?:@&=+$,"; - if ([aUrlString isKindOfClass: [NSString class]] == NO) + if (aUrlString == nil) { [NSException raise: NSInvalidArgumentException format: @"[%@ %@] nil string parameter", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; } - if (aBaseUrl != nil - && [aBaseUrl isKindOfClass: [NSURL class]] == NO) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@] bad base URL parameter", - NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; - } ASSIGNCOPY(_urlString, aUrlString); ASSIGN(_baseURL, [aBaseUrl absoluteURL]); NS_DURING @@ -702,11 +653,7 @@ static unsigned urlAlign; BOOL canBeGeneric = YES; size += sizeof(parsedURL) + urlAlign + 1; -#if GS_WITH_GC - buf = _data = (parsedURL*)NSAllocateCollectable(size, 0); -#else - buf = _data = (parsedURL*)NSZoneMalloc(NSDefaultMallocZone(), size); -#endif + buf = _data = (parsedURL*)NSZoneMalloc(GSAtomicMallocZone(), size); memset(buf, '\0', size); start = end = ptr = (char*)&buf[1]; [_urlString getCString: start @@ -742,12 +689,8 @@ static unsigned urlAlign; if (base != 0 && base->scheme != 0 && strcmp(base->scheme, buf->scheme) != 0) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"scheme of base and relative parts does not match", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"scheme of base and relative parts does not match"]; } } } @@ -761,22 +704,25 @@ static unsigned urlAlign; /* * Set up scheme specific parsing options. */ - if (buf->scheme != 0) + if (buf->scheme == 0) { - if (strcmp(buf->scheme, "file") == 0) - { - usesFragments = NO; - usesParameters = NO; - usesQueries = NO; - buf->isFile = YES; - } - else if (strcmp(buf->scheme, "mailto") == 0) - { - usesFragments = NO; - usesParameters = NO; - usesQueries = NO; - } - } + DESTROY(self); // Not a valid URL + NS_VALRETURN(nil); + } + + if (strcmp(buf->scheme, "file") == 0) + { + usesFragments = NO; + usesParameters = NO; + usesQueries = NO; + buf->isFile = YES; + } + else if (strcmp(buf->scheme, "mailto") == 0) + { + usesFragments = NO; + usesParameters = NO; + usesQueries = NO; + } if (canBeGeneric == YES) { @@ -815,12 +761,8 @@ static unsigned urlAlign; start = ptr; if (legal(buf->user, ";:&=+$,") == NO) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in user/password part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in user/password part"]; } ptr = strchr(buf->user, ':'); if (ptr != 0) @@ -834,41 +776,7 @@ static unsigned urlAlign; * Parse host:port part */ buf->host = start; - if (*start == '[') - { - ptr = strchr(buf->host, ']'); - if (ptr == 0) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal ipv6 host address", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; - } - else - { - ptr = start + 1; - while (*ptr != ']') - { - if (*ptr != ':' && *ptr != '.' && !isxdigit(*ptr)) - { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal ipv6 host address", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; - } - ptr++; - } - } - ptr = strchr(ptr, ':'); - } - else - { - ptr = strchr(buf->host, ':'); - } + ptr = strchr(buf->host, ':'); if (ptr != 0) { const char *str; @@ -916,12 +824,8 @@ static unsigned urlAlign; } else { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal port part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal port part"]; } } else if (isdigit(*str)) @@ -930,27 +834,16 @@ static unsigned urlAlign; } else { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in port part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in port part"]; } } } start = end; - /* Check for a legal host, unless it's an ipv6 address - * (which would have been checked earlier). - */ - if (*buf->host != '[' && legal(buf->host, "-") == NO) + if (legal(buf->host, "-") == NO) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in host part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in host part"]; } /* @@ -992,12 +885,8 @@ static unsigned urlAlign; buf->fragment = base->fragment; if (legal(buf->fragment, reserved) == NO) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in fragment part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in fragment part"]; } } } @@ -1021,12 +910,8 @@ static unsigned urlAlign; buf->query = base->query; if (legal(buf->query, reserved) == NO) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in query part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in query part"]; } } } @@ -1050,12 +935,8 @@ static unsigned urlAlign; buf->parameters = base->parameters; if (legal(buf->parameters, reserved) == NO) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in parameters part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in parameters part"]; } } } @@ -1064,7 +945,7 @@ static unsigned urlAlign; { buf->user = 0; buf->password = 0; - buf->host = (char*) "localhost"; + buf->host = "localhost"; buf->port = 0; buf->isGeneric = YES; } @@ -1082,23 +963,15 @@ static unsigned urlAlign; * Store the path. */ buf->path = start; - if (0 == base && '\0' == *buf->path && NO == buf->pathIsAbsolute) - { - buf->hasNoPath = YES; - } if (legal(buf->path, reserved) == NO) { - [NSException raise: NSInvalidArgumentException - format: @"[%@ %@](%@, %@) " - @"illegal character in path part", - NSStringFromClass([self class]), - NSStringFromSelector(_cmd), - aUrlString, aBaseUrl]; + [NSException raise: NSGenericException format: + @"illegal character in path part"]; } } NS_HANDLER { - NSDebugLog(@"%@", localException); + NSLog(@"%@", localException); DESTROY(self); } NS_ENDHANDLER @@ -1115,7 +988,7 @@ static unsigned urlAlign; if (_data != 0) { DESTROY(myData->absolute); - NSZoneFree([self zone], _data); + NSZoneFree(GSObjCZone(self), _data); _data = 0; } DESTROY(_urlString); @@ -1149,19 +1022,11 @@ static unsigned urlAlign; - (void) encodeWithCoder: (NSCoder*)aCoder { - if ([aCoder allowsKeyedCoding]) - { - [aCoder encodeObject: _baseURL forKey: @"NS.base"]; - [aCoder encodeObject: _urlString forKey: @"NS.relative"]; - } - else - { - [aCoder encodeObject: _urlString]; - [aCoder encodeObject: _baseURL]; - } + [aCoder encodeObject: _urlString]; + [aCoder encodeObject: _baseURL]; } -- (NSUInteger) hash +- (unsigned int) hash { return [[self absoluteString] hash]; } @@ -1171,21 +1036,11 @@ static unsigned urlAlign; NSURL *base; NSString *rel; - if ([aCoder allowsKeyedCoding]) - { - base = [aCoder decodeObjectForKey: @"NS.base"]; - rel = [aCoder decodeObjectForKey: @"NS.relative"]; - } - else - { - rel = [aCoder decodeObject]; - base = [aCoder decodeObject]; - } - if (nil == rel) - { - rel = @""; - } + [aCoder decodeValueOfObjCType: @encode(id) at: &rel]; + [aCoder decodeValueOfObjCType: @encode(id) at: &base]; self = [self initWithString: rel relativeToURL: base]; + RELEASE(rel); + RELEASE(base); return self; } @@ -1260,126 +1115,11 @@ static unsigned urlAlign; return fragment; } -- (char*) _path: (char*)buf -{ - char *ptr = buf; - char *tmp = buf; - - if (myData->pathIsAbsolute == YES) - { - if (myData->hasNoPath == NO) - { - *tmp++ = '/'; - } - if (myData->path != 0) - { - strcpy(tmp, myData->path); - } - } - else if (_baseURL == nil) - { - if (myData->path != 0) - { - strcpy(tmp, myData->path); - } - } - else if (*myData->path == 0) - { - if (baseData->hasNoPath == NO) - { - *tmp++ = '/'; - } - if (baseData->path != 0) - { - strcpy(tmp, baseData->path); - } - } - else - { - char *start = baseData->path; - char *end = (start == 0) ? 0 : strrchr(start, '/'); - - if (end != 0) - { - *tmp++ = '/'; - strncpy(tmp, start, end - start); - tmp += end - start; - } - *tmp++ = '/'; - if (myData->path != 0) - { - strcpy(tmp, myData->path); - } - } - - unescape(buf, buf); - -#if defined(__MINGW__) - /* On windows a file URL path may be of the form C:\xxx (ie we should - * not insert the leading slash). - * Also the vertical bar symbol may have been used instead of the - * colon, so we need to convert that. - */ - if (myData->isFile == YES) - { - if (ptr[1] && isalpha(ptr[1])) - { - if (ptr[2] == ':' || ptr[2] == '|') - { - if (ptr[3] == '\0' || ptr[3] == '/' || ptr[3] == '\\') - { - ptr[2] = ':'; - ptr++; - } - } - } - } -#endif - return ptr; -} - -- (NSString*) fullPath -{ - NSString *path = nil; - unsigned int len = 3; - - if (_baseURL != nil) - { - if (baseData->path && *baseData->path) - { - len += strlen(baseData->path); - } - else if (baseData->hasNoPath == NO) - { - len++; - } - } - if (myData->path && *myData->path) - { - len += strlen(myData->path); - } - else if (myData->hasNoPath == NO) - { - len++; - } - if (len > 3) - { - char buf[len]; - char *ptr; - - ptr = [self _path: buf]; - path = [NSString stringWithUTF8String: ptr]; - } - return path; -} - /** * Returns the host portion of the receiver or nil if there is no * host supplied in the URL.
* Percent escape sequences in the user string are translated and the string * treated as UTF8.
- * Returns IPv6 addresses without the enclosing square brackets - * required (by RFC2732) in URL strings. */ - (NSString*) host { @@ -1389,19 +1129,7 @@ static unsigned urlAlign; { char buf[strlen(myData->host)+1]; - if (*myData->host == '[') - { - char *end = unescape(myData->host + 1, buf); - - if (end[-1] == ']') - { - end[-1] = '\0'; - } - } - else - { - unescape(myData->host, buf); - } + unescape(myData->host, buf); host = [NSString stringWithUTF8String: buf]; } return host; @@ -1534,44 +1262,54 @@ static unsigned urlAlign; - (NSString*) path { NSString *path = nil; - unsigned int len = 3; - if (_baseURL != nil) - { - if (baseData->path && *baseData->path) - { - len += strlen(baseData->path); - } - else if (baseData->hasNoPath == NO) - { - len++; - } - } - if (myData->path && *myData->path) - { - len += strlen(myData->path); - } - else if (myData->hasNoPath == NO) - { - len++; - } - if (len > 3) + /* + * If this scheme is from a URL without generic format, there is no path. + */ + if (myData->isGeneric == YES) { + unsigned int len = (_baseURL ? strlen(baseData->path) : 0) + + strlen(myData->path) + 3; char buf[len]; - char *ptr; - char *tmp; + char *tmp = buf; - ptr = [self _path: buf]; - - /* Remove any trailing '/' from the path for MacOS-X compatibility. - */ - tmp = ptr + strlen(ptr) - 1; - if (tmp > ptr && *tmp == '/') + if (myData->pathIsAbsolute == YES) { - *tmp = '\0'; + if (myData->hasNoPath == NO) + { + *tmp++ = '/'; + } + strcpy(tmp, myData->path); + } + else if (_baseURL == nil) + { + strcpy(tmp, myData->path); + } + else if (*myData->path == 0) + { + if (baseData->hasNoPath == NO) + { + *tmp++ = '/'; + } + strcpy(tmp, baseData->path); + } + else + { + char *start = baseData->path; + char *end = strrchr(start, '/'); + + if (end != 0) + { + *tmp++ = '/'; + strncpy(tmp, start, end - start); + tmp += end - start; + } + *tmp++ = '/'; + strcpy(tmp, myData->path); } - path = [NSString stringWithUTF8String: ptr]; + unescape(buf, buf); + path = [NSString stringWithUTF8String: buf]; } return path; } @@ -1650,15 +1388,6 @@ static unsigned urlAlign; return _urlString; } -/* Encode bycopy unless explicitly requested otherwise. - */ -- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder -{ - if ([aCoder isByref] == NO) - return self; - return [super replacementObjectForPortCoder: aCoder]; -} - /** * Loads the resource data for the represented URL and returns the result. * The shouldUseCache flag determines whether data previously retrieved by @@ -1795,7 +1524,7 @@ static unsigned urlAlign; if (c != 0) { handle = [[c alloc] initWithURL: self cached: shouldUseCache]; - IF_NO_GC([handle autorelease];) + AUTORELEASE(handle); } } return handle; @@ -1878,7 +1607,7 @@ static unsigned urlAlign; { id c = clientForHandle(_clients, sender); - IF_NO_GC([self retain];) + RETAIN(self); [sender removeClient: self]; if (c != nil) { diff --git a/Source/NSURLAuthenticationChallenge.m b/Source/NSURLAuthenticationChallenge.m index b14419dd8..b7ae4e432 100644 --- a/Source/NSURLAuthenticationChallenge.m +++ b/Source/NSURLAuthenticationChallenge.m @@ -1,13 +1,13 @@ /* Implementation for NSURLAuthenticationChallenge for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,17 +16,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSURLAuthenticationChallenge_IVARS 1 -#import "GSURLPrivate.h" -#import "Foundation/NSError.h" +#include "GSURLPrivate.h" +#include "Foundation/NSError.h" // Internal data storage @@ -94,7 +91,7 @@ typedef struct { - (id) initWithProtectionSpace: (NSURLProtectionSpace *)space proposedCredential: (NSURLCredential *)credential - previousFailureCount: (NSInteger)previousFailureCount + previousFailureCount: (int)previousFailureCount failureResponse: (NSURLResponse *)response error: (NSError *)error sender: (id)sender @@ -111,7 +108,7 @@ typedef struct { return self; } -- (NSInteger) previousFailureCount +- (int) previousFailureCount { return this->previousFailureCount; } diff --git a/Source/NSURLCache.m b/Source/NSURLCache.m index 06ebb4423..5c3ed24d9 100644 --- a/Source/NSURLCache.m +++ b/Source/NSURLCache.m @@ -1,13 +1,13 @@ /* Implementation for NSURLCache for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,17 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSURLCache_IVARS 1 -#import "GSURLPrivate.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "GSURLPrivate.h" // FIXME ... locking and disk storage needed typedef struct { @@ -38,8 +34,11 @@ typedef struct { NSMutableDictionary *memory; } Internal; -#define this ((Internal*)(self->_NSURLCacheInternal)) -#define inst ((Internal*)(o->_NSURLCacheInternal)) +typedef struct { + @defs(NSURLCache) +} priv; +#define this ((Internal*)(((priv*)self)->_NSURLCacheInternal)) +#define inst ((Internal*)(((priv*)o)->_NSURLCacheInternal)) static NSURLCache *shared = nil; @@ -102,23 +101,23 @@ static NSURLCache *shared = nil; return [this->memory objectForKey: request]; } -- (NSUInteger) currentDiskUsage +- (unsigned) currentDiskUsage { return this->diskUsage; } -- (NSUInteger) currentMemoryUsage +- (unsigned) currentMemoryUsage { return this->memoryUsage; } -- (NSUInteger) diskCapacity +- (unsigned) diskCapacity { return this->diskCapacity; } -- (id) initWithMemoryCapacity: (NSUInteger)memoryCapacity - diskCapacity: (NSUInteger)diskCapacity +- (id) initWithMemoryCapacity: (unsigned)memoryCapacity + diskCapacity: (unsigned)diskCapacity diskPath: (NSString *)path { if ((self = [super init]) != nil) @@ -133,7 +132,7 @@ static NSURLCache *shared = nil; return self; } -- (NSUInteger) memoryCapacity +- (unsigned) memoryCapacity { return this->memoryCapacity; } @@ -158,15 +157,13 @@ static NSURLCache *shared = nil; } } -- (void) setDiskCapacity: (NSUInteger)diskCapacity +- (void) setDiskCapacity: (unsigned)diskCapacity { - [self notImplemented: _cmd]; // FIXME } -- (void) setMemoryCapacity: (NSUInteger)memoryCapacity +- (void) setMemoryCapacity: (unsigned)memoryCapacity { - [self notImplemented: _cmd]; // FIXME } diff --git a/Source/NSURLConnection.m b/Source/NSURLConnection.m index 4d15477f8..fb4f6aac9 100644 --- a/Source/NSURLConnection.m +++ b/Source/NSURLConnection.m @@ -1,13 +1,13 @@ /* Implementation for NSURLConnection for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,167 +16,29 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include "GSURLPrivate.h" -#define EXPOSE_NSURLConnection_IVARS 1 -#import "Foundation/NSRunLoop.h" -#import "GSURLPrivate.h" - -@interface _NSURLConnectionDataCollector : NSObject -{ - NSURLConnection *_connection; // Not retained - NSMutableData *_data; - NSError **_error; - NSURLResponse **_response; - BOOL _done; -} - -- (id) initWithResponsePointer: (NSURLResponse **)response - andErrorPointer: (NSError **)error; -- (NSData*) _data; -- (BOOL) _done; -- (void) _setConnection: (NSURLConnection *)c; - -@end - -@implementation _NSURLConnectionDataCollector - -- (id) initWithResponsePointer: (NSURLResponse **)response - andErrorPointer: (NSError **)error -{ - if ((self = [super init]) != nil) - { - _response = response; - _error = error; - } - return self; -} - -- (void) dealloc -{ - RELEASE(_data); - [super dealloc]; -} - -- (BOOL) _done -{ - return _done; -} - -- (NSData*) _data -{ - return _data; -} - -- (void) _setConnection: (NSURLConnection*)c -{ - _connection = c; -} - -// notification handler - -- (void) URLProtocol: (NSURLProtocol*)proto -cachedResponseIsValid: (NSCachedURLResponse*)resp -{ - return; -} - -- (void) URLProtocol: (NSURLProtocol*)proto -didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge -{ - return; -} - -- (void) URLProtocol: (NSURLProtocol*)proto -didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge -{ - return; -} - -- (void) URLProtocol: (NSURLProtocol*)proto -wasRedirectedToRequest: (NSURLRequest*)request -redirectResponse: (NSURLResponse*)redirectResponse -{ - return; -} - -- (void) URLProtocol: (NSURLProtocol*)proto - didFailWithError: (NSError*)error -{ - *_error = error; - _done = YES; -} - -- (void) connection: (NSURLConnection *)connection - didFailWithError: (NSError *)error -{ - *_error = error; - _done = YES; -} - -- (void) URLProtocol: (NSURLProtocol*)proto - didReceiveResponse: (NSURLResponse*)response - cacheStoragePolicy: (NSURLCacheStoragePolicy)policy -{ - *_response = response; -} - -- (void) URLProtocolDidFinishLoading: (NSURLProtocol*)proto -{ - _done = YES; -} - -- (void) connectionDidFinishLoading: (NSURLConnection *)connection -{ - _done = YES; -} - - -- (void) URLProtocol: (NSURLProtocol*)proto - didLoadData: (NSData*)data -{ - if (_data == nil) - { - _data = [data mutableCopy]; - } - else - { - [_data appendData: data]; - } -} - -- (void) connection: (NSURLConnection *)connection - didReceiveData: (NSData *)data -{ - if (_data == nil) - { - _data = [data mutableCopy]; - } - else - { - [_data appendData: data]; - } -} - -@end - - -typedef struct +@interface GSURLConnection : NSObject { +@public + NSURLConnection *_parent; // Not retained NSURLRequest *_request; NSURLProtocol *_protocol; - id _delegate; // Not retained - BOOL _debug; -} Internal; + id _delegate; +} +@end -#define this ((Internal*)(self->_NSURLConnectionInternal)) -#define inst ((Internal*)(o->_NSURLConnectionInternal)) +typedef struct { + @defs(NSURLConnection) +} priv; +#define this ((GSURLConnection*)(((priv*)self)->_NSURLConnectionInternal)) +#define inst ((GSURLConnection*)(((priv*)o)->_NSURLConnectionInternal)) @implementation NSURLConnection @@ -186,20 +48,17 @@ typedef struct if (o != nil) { -#if GS_WITH_GC o->_NSURLConnectionInternal - = NSAllocateCollectable(sizeof(Internal), NSScannedOption); -#else - o->_NSURLConnectionInternal = NSZoneCalloc([self zone], - 1, sizeof(Internal)); -#endif + = NSAllocateObject([GSURLConnection class], 0, z); + inst->_parent = o; } return o; } + (BOOL) canHandleRequest: (NSURLRequest *)request { - return ([NSURLProtocol _classToHandleRequest: request] != nil); + // FIXME + return NO; } + (NSURLConnection *) connectionWithRequest: (NSURLRequest *)request @@ -211,44 +70,25 @@ typedef struct return AUTORELEASE(o); } +- (void) dealloc +{ + RELEASE(this); + [super dealloc]; +} + - (void) cancel { [this->_protocol stopLoading]; DESTROY(this->_protocol); } -- (void) dealloc -{ - if (this != 0) - { - [self cancel]; - RELEASE(this->_request); - NSZoneFree([self zone], this); - _NSURLConnectionInternal = 0; - } - [super dealloc]; -} - -- (void) finalize -{ - if (this != 0) - { - [self cancel]; - } -} - - (id) initWithRequest: (NSURLRequest *)request delegate: (id)delegate { if ((self = [super init]) != nil) { this->_request = [request copy]; - this->_delegate = delegate; - this->_protocol = [[NSURLProtocol alloc] - initWithRequest: this->_request - cachedResponse: nil - client: (id)self]; - [this->_protocol startLoading]; - this->_debug = GSDebugSet(@"NSURLConnection"); + this->_delegate = [delegate retain]; + // FIXME ... start connection } return self; } @@ -262,18 +102,15 @@ typedef struct - (void) connection: (NSURLConnection *)connection didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { - return; } - (void) connection: (NSURLConnection *)connection didFailWithError: (NSError *)error { - return; } - (void) connectionDidFinishLoading: (NSURLConnection *)connection { - return; } - (void) connection: (NSURLConnection *)connection @@ -286,13 +123,11 @@ typedef struct - (void) connection: (NSURLConnection *)connection didReceiveData: (NSData *)data { - return; } - (void) connection: (NSURLConnection *)connection didReceiveResponse: (NSURLResponse *)response { - return; } - (NSCachedURLResponse *) connection: (NSURLConnection *)connection @@ -322,34 +157,27 @@ typedef struct if ([self canHandleRequest: request] == YES) { - _NSURLConnectionDataCollector *collector; - NSURLConnection *conn; - NSRunLoop *loop; + NSURLConnection *conn = [self alloc]; - collector = [_NSURLConnectionDataCollector alloc]; - collector = [collector initWithResponsePointer: response - andErrorPointer: error]; - conn = [self alloc]; - conn = [conn initWithRequest: request delegate: AUTORELEASE(collector)]; - [collector _setConnection: conn]; - loop = [NSRunLoop currentRunLoop]; - while ([collector _done] == NO) - { - NSDate *limit; - - limit = [[NSDate alloc] initWithTimeIntervalSinceNow: 1.0]; - [loop runMode: NSDefaultRunLoopMode beforeDate: limit]; - RELEASE(limit); - } - data = RETAIN([collector _data]); + conn = [conn initWithRequest: request delegate: nil]; + // FIXME ... handle load and get results; + [conn release]; } - return AUTORELEASE(data); + return data; } @end -@implementation NSURLConnection (URLProtocolClient) +@implementation GSURLConnection + +- (void) dealloc +{ + RELEASE(_protocol); + RELEASE(_request); + RELEASE(_delegate); + [super dealloc]; +} - (void) URLProtocol: (NSURLProtocol *)protocol cachedResponseIsValid: (NSCachedURLResponse *)cachedResponse @@ -360,31 +188,31 @@ typedef struct - (void) URLProtocol: (NSURLProtocol *)protocol didFailWithError: (NSError *)error { - [this->_delegate connection: self didFailWithError: error]; + [_delegate connection: _parent didFailWithError: error]; } - (void) URLProtocol: (NSURLProtocol *)protocol didLoadData: (NSData *)data { - [this->_delegate connection: self didReceiveData: data]; + [_delegate connection: _parent didReceiveData: data]; } - (void) URLProtocol: (NSURLProtocol *)protocol didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { - [this->_delegate connection: self - didReceiveAuthenticationChallenge: challenge]; + [_delegate connection: _parent didReceiveAuthenticationChallenge: challenge]; } - (void) URLProtocol: (NSURLProtocol *)protocol didReceiveResponse: (NSURLResponse *)response cacheStoragePolicy: (NSURLCacheStoragePolicy)policy { - [this->_delegate connection: self didReceiveResponse: response]; + [_delegate connection: _parent didReceiveResponse: response]; if (policy == NSURLCacheStorageAllowed || policy == NSURLCacheStorageAllowedInMemoryOnly) { - // FIXME ... cache response here? + + // FIXME ... cache response here } } @@ -392,57 +220,33 @@ typedef struct wasRedirectedToRequest: (NSURLRequest *)request redirectResponse: (NSURLResponse *)redirectResponse { - if (this->_debug) + request = [_delegate connection: _parent + willSendRequest: request + redirectResponse: redirectResponse]; + // If we have been cancelled, our protocol will be nil + if (_protocol != nil) { - NSLog(@"%@ tell delegate %@ about redirect to %@ as a result of %@", - self, this->_delegate, request, redirectResponse); - } - request = [this->_delegate connection: self - willSendRequest: request - redirectResponse: redirectResponse]; - if (this->_protocol == nil) - { - if (this->_debug) - { - NSLog(@"%@ delegate cancelled request", self); + if (request == nil) + { + [_delegate connectionDidFinishLoading: _parent]; } - /* Our protocol is nil, so we have been cancelled by the delegate. - */ - return; - } - if (request != nil) - { - if (this->_debug) - { - NSLog(@"%@ delegate allowed redirect to %@", self, request); + else + { + DESTROY(_protocol); + // FIXME start new request loading } - /* Follow the redirect ... stop the old load and start a new one. - */ - [this->_protocol stopLoading]; - DESTROY(this->_protocol); - ASSIGNCOPY(this->_request, request); - this->_protocol = [[NSURLProtocol alloc] - initWithRequest: this->_request - cachedResponse: nil - client: (id)self]; - [this->_protocol startLoading]; - } - else if (this->_debug) - { - NSLog(@"%@ delegate cancelled redirect", self); } } - (void) URLProtocolDidFinishLoading: (NSURLProtocol *)protocol { - [this->_delegate connectionDidFinishLoading: self]; + [_delegate connectionDidFinishLoading: _parent]; } - (void) URLProtocol: (NSURLProtocol *)protocol didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { - [this->_delegate connection: self - didCancelAuthenticationChallenge: challenge]; + [_delegate connection: _parent didCancelAuthenticationChallenge: challenge]; } @end diff --git a/Source/NSURLCredential.m b/Source/NSURLCredential.m index 0dad0acec..7e216a1fb 100644 --- a/Source/NSURLCredential.m +++ b/Source/NSURLCredential.m @@ -1,13 +1,13 @@ /* Implementation for NSURLCredential for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,16 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSURLCredential_IVARS 1 -#import "GSURLPrivate.h" +#include "GSURLPrivate.h" // Internal data storage typedef struct { @@ -94,7 +91,7 @@ typedef struct { return this->hasPassword; } -- (NSUInteger) hash +- (unsigned) hash { return [this->user hash]; } @@ -105,7 +102,7 @@ typedef struct { { if (user == nil) { - DESTROY(self); + RELEASE(self); return nil; } if ((self = [super init]) != nil) diff --git a/Source/NSURLCredentialStorage.m b/Source/NSURLCredentialStorage.m index 21e507b2e..8bd630e83 100644 --- a/Source/NSURLCredentialStorage.m +++ b/Source/NSURLCredentialStorage.m @@ -1,13 +1,13 @@ /* Implementation for NSURLCredentialStorage for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,16 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSURLCredentialStorage_IVARS 1 -#import "GSURLPrivate.h" +#include "GSURLPrivate.h" NSString *const NSURLCredentialStorageChangedNotification = @"NSURLCredentialStorageChangedNotification"; @@ -110,7 +107,7 @@ static NSURLCredentialStorage *storage = nil; // Should never be called. - (id) init { - DESTROY(self); + RELEASE(self); return nil; } diff --git a/Source/NSURLDownload.m b/Source/NSURLDownload.m index 3494daf02..16e8e8e30 100644 --- a/Source/NSURLDownload.m +++ b/Source/NSURLDownload.m @@ -1,13 +1,13 @@ /* Implementation for NSURLDownload for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,16 +16,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" -#define EXPOSE_NSURLDownload_IVARS 1 -#import "GSURLPrivate.h" +#include "GSURLPrivate.h" @interface GSURLDownload : NSObject { @@ -41,8 +39,11 @@ } @end -#define this ((GSURLDownload*)(self->_NSURLDownloadInternal)) -#define inst ((GSURLDownload*)(o->_NSURLDownloadInternal)) +typedef struct { + @defs(NSURLDownload) +} priv; +#define this ((GSURLDownload*)(((priv*)self)->_NSURLDownloadInternal)) +#define inst ((GSURLDownload*)(((priv*)o)->_NSURLDownloadInternal)) @implementation NSURLDownload @@ -131,53 +132,44 @@ - (void) downloadDidBegin: (NSURLDownload *)download { - return; } - (void) downloadDidFinish: (NSURLDownload *)download { - return; } - (void) download: (NSURLDownload *)download decideDestinationWithSuggestedFilename: (NSString *)filename { - return; } - (void) download: (NSURLDownload *)download didCancelAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { - return; } - (void) download: (NSURLDownload *)download didCreateDestination: (NSString *)path { - return; } - (void) download: (NSURLDownload *)download didFailWithError: (NSError *)error { - return; } - (void) download: (NSURLDownload *)download didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { - return; } - (void) download: (NSURLDownload *)download - didReceiveDataOfLength: (NSUInteger)length + didReceiveDataOfLength: (unsigned)length { - return; } - (void) download: (NSURLDownload *)download didReceiveResponse: (NSURLResponse *)response { - return; } - (BOOL) download: (NSURLDownload *)download @@ -190,7 +182,6 @@ willResumeWithResponse: (NSURLResponse *)response fromByte: (long long)startingByte { - return; } - (NSURLRequest *) download: (NSURLDownload *)download @@ -218,7 +209,7 @@ - (void) URLProtocol: (NSURLProtocol *)protocol cachedResponseIsValid: (NSCachedURLResponse *)cachedResponse { - return; + } - (void) URLProtocol: (NSURLProtocol *)protocol @@ -230,7 +221,6 @@ - (void) URLProtocol: (NSURLProtocol *)protocol didLoadData: (NSData *)data { - return; } - (void) URLProtocol: (NSURLProtocol *)protocol diff --git a/Source/NSURLHandle.m b/Source/NSURLHandle.m index 0741fb733..46e4f01ea 100644 --- a/Source/NSURLHandle.m +++ b/Source/NSURLHandle.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,15 +27,12 @@ $Date$ $Revision$ */ -#import "common.h" +#include "GSURLPrivate.h" -#define EXPOSE_NSURLHandle_IVARS 1 -#import "GSURLPrivate.h" - -#import "Foundation/NSURLHandle.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSFileManager.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "Foundation/NSEnumerator.h" +#include "Foundation/NSURLHandle.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSFileManager.h" @class GSFTPURLHandle; @@ -256,10 +253,10 @@ static Class NSURLHandleClass = 0; { id o = client; - IF_NO_GC([o retain];) + RETAIN(o); [_clients removeObjectIdenticalTo: o]; [_clients addObject: o]; - IF_NO_GC([o release];) + RELEASE(o); } /** @@ -316,12 +313,12 @@ static Class NSURLHandleClass = 0; */ - (void) cancelLoadInBackground { - IF_NO_GC([self retain];) + RETAIN(self); [_clients makeObjectsPerformSelector: @selector(URLHandleResourceDidCancelLoading:) withObject: self]; [self endLoadInBackground]; - IF_NO_GC(RELEASE(self);) + RELEASE(self); } - (void) dealloc @@ -484,7 +481,7 @@ static Class NSURLHandleClass = 0; NSDate *limit; limit = [[NSDate alloc] initWithTimeIntervalSinceNow: 1.0]; - [loop runMode: NSDefaultRunLoopMode beforeDate: limit]; + [loop runUntilDate: limit]; RELEASE(limit); } return _data; @@ -635,7 +632,7 @@ static NSLock *fileLock = nil; NS_DURING { obj = [fileCache objectForKey: path]; - IF_NO_GC([[obj retain] autorelease];) + AUTORELEASE(RETAIN(obj)); } NS_HANDLER { @@ -710,7 +707,7 @@ static NSLock *fileLock = nil; if ([url isFileURL] == NO) { NSLog(@"Attempt to init GSFileURLHandle with bad URL"); - DESTROY(self); + RELEASE(self); return nil; } path = [url path]; @@ -727,7 +724,7 @@ static NSLock *fileLock = nil; if (obj != nil) { DESTROY(self); - IF_NO_GC([obj retain];) + RETAIN(obj); } } NS_HANDLER diff --git a/Source/NSURLProtectionSpace.m b/Source/NSURLProtectionSpace.m index afac9cd6e..f1d258b75 100644 --- a/Source/NSURLProtectionSpace.m +++ b/Source/NSURLProtectionSpace.m @@ -1,13 +1,13 @@ /* Implementation for NSURLProtectionSpace for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,17 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSURLProtectionSpace_IVARS 1 -#import "GSURLPrivate.h" -#import "GNUstepBase/NSURL+GNUstepBase.h" +#include "GSURLPrivate.h" NSString * const NSURLProtectionSpaceFTPProxy = @"ftp"; NSString * const NSURLProtectionSpaceHTTPProxy = @"http"; @@ -52,8 +48,11 @@ typedef struct { BOOL isProxy; } Internal; -#define this ((Internal*)(self->_NSURLProtectionSpaceInternal)) -#define inst ((Internal*)(o->_NSURLProtectionSpaceInternal)) +typedef struct { + @defs(NSURLProtectionSpace) +} priv; +#define this ((Internal*)(((priv*)self)->_NSURLProtectionSpaceInternal)) +#define inst ((Internal*)(((priv*)o)->_NSURLProtectionSpaceInternal)) @implementation NSURLProtectionSpace @@ -109,7 +108,7 @@ typedef struct { [super dealloc]; } -- (NSUInteger) hash +- (unsigned) hash { return [[self host] hash] + [self port] + [[self realm] hash] + [[self protocol] hash] @@ -122,7 +121,7 @@ typedef struct { } - (id) initWithHost: (NSString *)host - port: (NSInteger)port + port: (int)port protocol: (NSString *)protocol realm: (NSString *)realm authenticationMethod: (NSString *)authenticationMethod @@ -159,7 +158,7 @@ authenticationMethod: (NSString *)authenticationMethod } - (id) initWithProxyHost: (NSString *)host - port: (NSInteger)port + port: (int)port type: (NSString *)type realm: (NSString *)realm authenticationMethod: (NSString *)authenticationMethod @@ -251,7 +250,7 @@ authenticationMethod: (NSString *)authenticationMethod return this->isProxy; } -- (NSInteger) port +- (int) port { return this->port; } diff --git a/Source/NSURLProtocol.m b/Source/NSURLProtocol.m index 7a0e301b3..d7b2e0346 100644 --- a/Source/NSURLProtocol.m +++ b/Source/NSURLProtocol.m @@ -1,14 +1,13 @@ /* Implementation for NSURLProtocol for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 - Parts (FTP and About in particular) based on later code by Nikolaus Schaller This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,250 +16,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSURLProtocol_IVARS 1 -#import "Foundation/NSError.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSValue.h" - -#import "GSPrivate.h" -#import "GSURLPrivate.h" -#import "GNUstepBase/GSMime.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSURL+GNUstepBase.h" - -/* Define to 1 for experimental (net yet working) compression support - */ -#ifdef USE_ZLIB -# undef USE_ZLIB -#endif -#define USE_ZLIB 0 - -#if USE_ZLIB -#if defined(HAVE_ZLIB_H) -#include - -static void* -zalloc(void *opaque, unsigned nitems, unsigned size) -{ - return objc_calloc(nitems, size); -} -static void -zfree(void *opaque, void *mem) -{ - objc_free(mem); -} -#else -# undef USE_ZLIB -# define USE_ZLIB 0 -#endif -#endif - -@interface GSSocketStreamPair : NSObject -{ - NSInputStream *ip; - NSOutputStream *op; - NSHost *host; - uint16_t port; - NSDate *expires; - BOOL ssl; -} -+ (void) purge: (NSNotification*)n; -- (void) cache: (NSDate*)when; -- (NSDate*) expires; -- (id) initWithHost: (NSHost*)h port: (uint16_t)p forSSL: (BOOL)s; -- (NSInputStream*) inputStream; -- (NSOutputStream*) outputStream; -@end - -@implementation GSSocketStreamPair - -static NSMutableArray *pairCache = nil; -static NSLock *pairLock = nil; - -+ (void) initialize -{ - if (pairCache == nil) - { - /* No use trying to use a dictionary ... NSHost objects all hash - * to the same value. - */ - pairCache = [NSMutableArray new]; - pairLock = [NSLock new]; - /* Purge expired pairs at intervals. - */ - [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(purge:) - name: @"GSHousekeeping" object: nil]; - } -} - -+ (void) purge: (NSNotification*)n -{ - NSDate *now = [NSDate date]; - unsigned count; - - [pairLock lock]; - count = [pairCache count]; - while (count-- > 0) - { - GSSocketStreamPair *p = [pairCache objectAtIndex: count]; - - if ([[p expires] timeIntervalSinceDate: now] <= 0.0) - { - [pairCache removeObjectAtIndex: count]; - } - } - [pairLock unlock]; -} - -- (void) cache: (NSDate*)when -{ - ASSIGN(expires, when); - [pairLock lock]; - [pairCache addObject: self]; - [pairLock unlock]; -} - -- (void) dealloc -{ - [ip setDelegate: nil]; - [op setDelegate: nil]; - [ip removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [op removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [ip close]; - [op close]; - DESTROY(ip); - DESTROY(op); - DESTROY(host); - DESTROY(expires); - [super dealloc]; -} - -- (NSDate*) expires -{ - return expires; -} - -- (id) init -{ - DESTROY(self); - return nil; -} - -- (id) initWithHost: (NSHost*)h port: (uint16_t)p forSSL: (BOOL)s; -{ - unsigned count; - NSDate *now; - - now = [NSDate date]; - [pairLock lock]; - count = [pairCache count]; - while (count-- > 0) - { - GSSocketStreamPair *pair = [pairCache objectAtIndex: count]; - - if ([pair->expires timeIntervalSinceDate: now] <= 0.0) - { - [pairCache removeObjectAtIndex: count]; - } - else if (pair->port == p && pair->ssl == s && [pair->host isEqual: h]) - { - /* Found a match ... remove from cache and return as self. - */ - DESTROY(self); - self = [pair retain]; - [pairCache removeObjectAtIndex: count]; - [pairLock unlock]; - return self; - } - } - [pairLock unlock]; - - if ((self = [super init]) != nil) - { - [NSStream getStreamsToHost: host - port: port - inputStream: &ip - outputStream: &op]; - if (ip == nil || op == nil) - { - DESTROY(self); - return nil; - } - ssl = s; - port = p; - host = [h retain]; - [ip retain]; - [op retain]; - if (ssl == YES) - { - [ip setProperty: NSStreamSocketSecurityLevelNegotiatedSSL - forKey: NSStreamSocketSecurityLevelKey]; - [op setProperty: NSStreamSocketSecurityLevelNegotiatedSSL - forKey: NSStreamSocketSecurityLevelKey]; - } - } - return self; -} - -- (NSInputStream*) inputStream -{ - return ip; -} - -- (NSOutputStream*) outputStream -{ - return op; -} - -@end - -@interface _NSAboutURLProtocol : NSURLProtocol -@end - -@interface _NSFTPURLProtocol : NSURLProtocol -@end - -@interface _NSFileURLProtocol : NSURLProtocol -@end - -@interface _NSHTTPURLProtocol : NSURLProtocol - -{ - GSMimeParser *_parser; // Parser handling incoming data - unsigned _parseOffset; // Bytes of body loaded in parser. - float _version; // The HTTP version in use. - int _statusCode; // The HTTP status code returned. - NSInputStream *_body; // for sending the body - unsigned _writeOffset; // Request data to write - NSData *_writeData; // Request bytes written so far - BOOL _complete; - BOOL _debug; - BOOL _isLoading; - BOOL _shouldClose; - NSURLAuthenticationChallenge *_challenge; - NSURLCredential *_credential; - NSHTTPURLResponse *_response; -} -- (void) setDebug: (BOOL)flag; -@end - -@interface _NSHTTPSURLProtocol : _NSHTTPURLProtocol -@end - +#include "GSURLPrivate.h" // Internal data storage @@ -268,42 +30,28 @@ typedef struct { NSInputStream *input; NSOutputStream *output; NSCachedURLResponse *cachedResponse; - id client; // Not retained + id client; NSURLRequest *request; -#if USE_ZLIB - z_stream z; // context for decompress - BOOL compressing; // are we compressing? - BOOL decompressing; // are we decompressing? - NSData *compressed; // only partially decompressed -#endif } Internal; -#define this ((Internal*)(self->_NSURLProtocolInternal)) -#define inst ((Internal*)(o->_NSURLProtocolInternal)) +typedef struct { + @defs(NSURLProtocol) +} priv; +#define this ((Internal*)(((priv*)self)->_NSURLProtocolInternal)) +#define inst ((Internal*)(((priv*)o)->_NSURLProtocolInternal)) static NSMutableArray *registered = nil; static NSLock *regLock = nil; -static Class abstractClass = nil; -static NSURLProtocol *placeholder = nil; @implementation NSURLProtocol + (id) allocWithZone: (NSZone*)z { - NSURLProtocol *o; + NSURLProtocol *o = [super allocWithZone: z]; - if ((self == abstractClass) && (z == 0 || z == NSDefaultMallocZone())) + if (o != nil) { - /* Return a default placeholder instance to avoid the overhead of - * creating and destroying instances of the abstract class. - */ - o = placeholder; - } - else - { - /* Create and return an instance of the concrete subclass. - */ - o = (NSURLProtocol*)NSAllocateObject(self, 0, z); + o->_NSURLProtocolInternal = NSZoneCalloc(z, 1, sizeof(Internal)); } return o; } @@ -312,24 +60,11 @@ static NSURLProtocol *placeholder = nil; { if (registered == nil) { - abstractClass = [NSURLProtocol class]; - placeholder = (NSURLProtocol*)NSAllocateObject(abstractClass, 0, - NSDefaultMallocZone()); registered = [NSMutableArray new]; regLock = [NSLock new]; - [self registerClass: [_NSHTTPURLProtocol class]]; - [self registerClass: [_NSHTTPSURLProtocol class]]; - [self registerClass: [_NSFTPURLProtocol class]]; - [self registerClass: [_NSFileURLProtocol class]]; - [self registerClass: [_NSAboutURLProtocol class]]; } } -+ (id) propertyForKey: (NSString *)key inRequest: (NSURLRequest *)request -{ - return [request _propertyForKey: key]; -} - + (BOOL) registerClass: (Class)protocolClass { if ([protocolClass isSubclassOfClass: [NSURLProtocol class]] == YES) @@ -342,28 +77,11 @@ static NSURLProtocol *placeholder = nil; return NO; } -+(Class) _classToHandleRequest:(NSURLRequest *)request ++ (id) propertyForKey: (NSString *)key inRequest: (NSURLRequest *)request { - Class protoClass = nil; - int count; - [regLock lock]; - - count = [registered count]; - while (count-- > 0) - { - Class proto = [registered objectAtIndex: count]; - - if ([proto canInitWithRequest: request] == YES) - { - protoClass = proto; - break; - } - } - [regLock unlock]; - return protoClass; + return [request _propertyForKey: key]; } - + (void) setProperty: (id)value forKey: (NSString *)key inRequest: (NSMutableURLRequest *)request @@ -390,96 +108,27 @@ static NSURLProtocol *placeholder = nil; - (void) dealloc { - if (self == placeholder) - { - [self retain]; - return; - } if (this != 0) { - [self stopLoading]; - if (this->input != nil) - { - [this->input setDelegate: nil]; - [this->output setDelegate: nil]; - [this->input removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->input close]; - [this->output close]; - DESTROY(this->input); - DESTROY(this->output); - } - DESTROY(this->cachedResponse); - DESTROY(this->request); -#if USE_ZLIB - if (this->compressing == YES) - { - deflateEnd(&this->z); - } - else if (this->decompressing == YES) - { - inflateEnd(&this->z); - } - DESTROY(this->compressed); -#endif + RELEASE(this->input); + RELEASE(this->output); + RELEASE(this->cachedResponse); + RELEASE(this->client); + RELEASE(this->request); NSZoneFree([self zone], this); - _NSURLProtocolInternal = 0; } [super dealloc]; } -- (NSString*) description -{ - return [NSString stringWithFormat:@"%@ %@", - [super description], this ? (id)this->request : nil]; -} - -- (id) init -{ - if ((self = [super init]) != nil) - { - if (isa != abstractClass) - { - _NSURLProtocolInternal = NSZoneCalloc([self zone], - 1, sizeof(Internal)); - } - } - return self; -} - - (id) initWithRequest: (NSURLRequest *)request cachedResponse: (NSCachedURLResponse *)cachedResponse client: (id )client { - if (isa == abstractClass) - { - unsigned count; - - DESTROY(self); - [regLock lock]; - count = [registered count]; - while (count-- > 0) - { - Class proto = [registered objectAtIndex: count]; - - if ([proto canInitWithRequest: request] == YES) - { - self = [proto alloc]; - break; - } - } - [regLock unlock]; - return [self initWithRequest: request - cachedResponse: cachedResponse - client: client]; - } - if ((self = [self init]) != nil) + if ((self = [super init]) != nil) { this->request = [request copy]; this->cachedResponse = RETAIN(cachedResponse); - this->client = client; // Not retained + this->client = RETAIN(client); } return self; } @@ -508,8 +157,6 @@ static NSURLProtocol *placeholder = nil; + (BOOL) requestIsCacheEquivalent: (NSURLRequest *)a toRequest: (NSURLRequest *)b { - a = [self canonicalRequestForRequest: a]; - b = [self canonicalRequestForRequest: b]; return [a isEqual: b]; } @@ -525,1200 +172,3 @@ static NSURLProtocol *placeholder = nil; @end - - - - - -@implementation _NSHTTPURLProtocol - -+ (BOOL) canInitWithRequest: (NSURLRequest*)request -{ - return [[[request URL] scheme] isEqualToString: @"http"]; -} - -+ (NSURLRequest*) canonicalRequestForRequest: (NSURLRequest*)request -{ - return request; -} - -- (void) cancelAuthenticationChallenge: (NSURLAuthenticationChallenge*)c -{ - if (c == _challenge) - { - DESTROY(_challenge); // We should cancel the download - } -} - -- (void) continueWithoutCredentialForAuthenticationChallenge: - (NSURLAuthenticationChallenge*)c -{ - if (c == _challenge) - { - DESTROY(_credential); // We download the challenge page - } -} - -- (void) dealloc -{ - [_parser release]; // received headers - [_body release]; // for sending the body - [_response release]; - [_credential release]; - [_credential release]; - [super dealloc]; -} - -- (void) setDebug: (BOOL)flag -{ - _debug = flag; -} - -- (void) startLoading -{ - static NSDictionary *methods = nil; - - if (methods == nil) - { - methods = [[NSDictionary alloc] initWithObjectsAndKeys: - self, @"HEAD", - self, @"GET", - self, @"POST", - self, @"PUT", - self, @"DELETE", - self, @"TRACE", - self, @"OPTIONS", - self, @"CONNECT", - nil]; - } - if ([methods objectForKey: [this->request HTTPMethod]] == nil) - { - NSLog(@"Invalid HTTP Method: %@", this->request); - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: - [NSError errorWithDomain: @"Invalid HTTP Method" - code: 0 - userInfo: nil]]; - return; - } - if (_isLoading == YES) - { - NSLog(@"startLoading when load in progress"); - return; - } - - _statusCode = 0; /* No status returned yet. */ - _isLoading = YES; - _complete = NO; - _debug = GSDebugSet(@"NSHTTPURLProtocol"); - - /* Perform a redirect if the path is empty. - * As per MacOs-X documentation. - */ - if ([[[this->request URL] fullPath] length] == 0) - { - NSString *s = [[this->request URL] absoluteString]; - NSURL *url; - - if ([s rangeOfString: @"?"].length > 0) - { - s = [s stringByReplacingString: @"?" withString: @"/?"]; - } - else if ([s rangeOfString: @"#"].length > 0) - { - s = [s stringByReplacingString: @"#" withString: @"/#"]; - } - else - { - s = [s stringByAppendingString: @"/"]; - } - url = [NSURL URLWithString: s]; - if (url == nil) - { - NSError *e; - - e = [NSError errorWithDomain: @"Invalid redirect request" - code: 0 - userInfo: nil]; - [self stopLoading]; - [this->client URLProtocol: self - didFailWithError: e]; - } - else - { - NSMutableURLRequest *request; - - request = [this->request mutableCopy]; - [request setURL: url]; - [this->client URLProtocol: self - wasRedirectedToRequest: request - redirectResponse: nil]; - } - if (_isLoading == NO) - { - return; - } - } - - if (0 && this->cachedResponse) - { - } - else - { - NSURL *url = [this->request URL]; - NSHost *host = [NSHost hostWithName: [url host]]; - int port = [[url port] intValue]; - - _parseOffset = 0; - DESTROY(_parser); - - if (host == nil) - { - host = [NSHost hostWithAddress: [url host]]; // try dotted notation - } - if (host == nil) - { - host = [NSHost hostWithAddress: @"127.0.0.1"]; // final default - } - if (port == 0) - { - // default if not specified - port = [[url scheme] isEqualToString: @"https"] ? 443 : 80; - } - - [NSStream getStreamsToHost: host - port: port - inputStream: &this->input - outputStream: &this->output]; - if (!this->input || !this->output) - { - if (_debug == YES) - { - NSLog(@"%@ did not create streams for %@:%@", - self, host, [url port]); - } - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: - [NSError errorWithDomain: @"can't connect" code: 0 userInfo: - [NSDictionary dictionaryWithObjectsAndKeys: - url, @"NSErrorFailingURLKey", - host, @"NSErrorFailingURLStringKey", - @"can't find host", @"NSLocalizedDescription", - nil]]]; - return; - } -#if !GS_WITH_GC - [this->input retain]; - [this->output retain]; -#endif - if ([[url scheme] isEqualToString: @"https"] == YES) - { - [this->input setProperty: NSStreamSocketSecurityLevelNegotiatedSSL - forKey: NSStreamSocketSecurityLevelKey]; - [this->output setProperty: NSStreamSocketSecurityLevelNegotiatedSSL - forKey: NSStreamSocketSecurityLevelKey]; - } - [this->input setDelegate: self]; - [this->output setDelegate: self]; - [this->input scheduleInRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output scheduleInRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->input open]; - [this->output open]; - } -} - -- (void) stopLoading -{ - if (_debug == YES) - { - NSLog(@"%@ stopLoading", self); - } - _isLoading = NO; - DESTROY(_writeData); - if (this->input != nil) - { - [this->input setDelegate: nil]; - [this->output setDelegate: nil]; - [this->input removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->input close]; - [this->output close]; - DESTROY(this->input); - DESTROY(this->output); - } -} - -- (void) _didLoad: (NSData*)d -{ - [this->client URLProtocol: self didLoadData: d]; -} - -- (void) _got: (NSStream*)stream -{ - unsigned char buffer[BUFSIZ*64]; - int readCount; - NSError *e; - NSData *d; - BOOL wasInHeaders = NO; - - readCount = [(NSInputStream *)stream read: buffer - maxLength: sizeof(buffer)]; - if (readCount < 0) - { - if ([stream streamStatus] == NSStreamStatusError) - { - e = [stream streamError]; - if (_debug) - { - NSLog(@"%@ receive error %@", self, e); - } - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: e]; - } - return; - } - if (_debug) - { - NSLog(@"%@ read %d bytes: '%*.*s'", - self, readCount, readCount, readCount, buffer); - } - - if (_parser == nil) - { - _parser = [GSMimeParser new]; - [_parser setIsHttp]; - } - wasInHeaders = [_parser isInHeaders]; - d = [NSData dataWithBytes: buffer length: readCount]; - if ([_parser parse: d] == NO && (_complete = [_parser isComplete]) == NO) - { - if (_debug == YES) - { - NSLog(@"%@ HTTP parse failure - %@", self, _parser); - } - e = [NSError errorWithDomain: @"parse error" - code: 0 - userInfo: nil]; - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: e]; - return; - } - else - { - BOOL isInHeaders = [_parser isInHeaders]; - GSMimeDocument *document = [_parser mimeDocument]; - unsigned bodyLength; - - if (wasInHeaders == YES && isInHeaders == NO) - { - GSMimeHeader *info; - NSString *enc; - int len = -1; - NSString *s; - - info = [document headerNamed: @"http"]; - - _version = [[info value] floatValue]; - if (_version < 1.1) - { - _shouldClose = YES; - } - else if ((s = [[document headerNamed: @"connection"] value]) != nil - && [s caseInsensitiveCompare: @"close"] == NSOrderedSame) - { - _shouldClose = YES; - } - else - { - _shouldClose = NO; // Keep connection alive. - } - - s = [info objectForKey: NSHTTPPropertyStatusCodeKey]; - _statusCode = [s intValue]; - - s = [[document headerNamed: @"content-length"] value]; - if ([s length] > 0) - { - len = [s intValue]; - } - - s = [info objectForKey: NSHTTPPropertyStatusReasonKey]; - enc = [[document headerNamed: @"content-transfer-encoding"] value]; - if (enc == nil) - { - enc = [[document headerNamed: @"transfer-encoding"] value]; - } - - _response = [[NSHTTPURLResponse alloc] - initWithURL: [this->request URL] - MIMEType: nil - expectedContentLength: len - textEncodingName: nil]; - [_response _setStatusCode: _statusCode text: s]; - [document deleteHeaderNamed: @"http"]; - [_response _setHeaders: [document allHeaders]]; - - if (_statusCode == 204 || _statusCode == 304) - { - _complete = YES; // No body expected. - } - else if ([enc isEqualToString: @"chunked"] == YES) - { - _complete = NO; // Read chunked body data - } - if (_complete == NO && [d length] == 0) - { - _complete = YES; // Had EOF ... terminate - } - - if (_statusCode == 401) - { - /* This is an authentication challenge, so we keep reading - * until the challenge is complete, then try to deal with it. - */ - } - else if ((s = [[document headerNamed: @"location"] value]) != nil) - { - NSURL *url; - - url = [NSURL URLWithString: s]; - if (url == nil) - { - NSError *e; - - e = [NSError errorWithDomain: @"Invalid redirect request" - code: 0 - userInfo: nil]; - [self stopLoading]; - [this->client URLProtocol: self - didFailWithError: e]; - } - else - { - NSMutableURLRequest *request; - - request = [this->request mutableCopy]; - [request setURL: url]; - [this->client URLProtocol: self - wasRedirectedToRequest: request - redirectResponse: _response]; - } - } - else - { - NSURLCacheStoragePolicy policy; - - /* Tell the client that we have a response and how - * it should be cached. - */ - policy = [this->request cachePolicy]; - if (policy - == (NSURLCacheStoragePolicy)NSURLRequestUseProtocolCachePolicy) - { - if ([self isKindOfClass: [_NSHTTPSURLProtocol class]] == YES) - { - /* For HTTPS we should not allow caching unless the - * request explicitly wants it. - */ - policy = NSURLCacheStorageNotAllowed; - } - else - { - /* For HTTP we allow caching unless the request - * specifically denies it. - */ - policy = NSURLCacheStorageAllowed; - } - } - [this->client URLProtocol: self - didReceiveResponse: _response - cacheStoragePolicy: policy]; - } - -#if USE_ZLIB - s = [[document headerNamed: @"content-encoding"] value]; - if ([s isEqualToString: @"gzip"] || [s isEqualToString: @"x-gzip"]) - { - this->decompressing = YES; - this->z.opaque = 0; - this->z.zalloc = zalloc; - this->z.zfree = zfree; - this->z.next_in = 0; - this->z.avail_in = 0; - inflateInit2(&this->z, 1); // FIXME - } -#endif - } - - if (_complete == YES) - { - if (_statusCode == 401) - { - NSURLProtectionSpace *space; - NSString *hdr; - NSURL *url; - int failures = 0; - - /* This was an authentication challenge. - */ - hdr = [[document headerNamed: @"WWW-Authenticate"] value]; - url = [this->request URL]; - space = [GSHTTPAuthentication - protectionSpaceForAuthentication: hdr requestURL: url]; - DESTROY(_credential); - if (space != nil) - { - /* Create credential from user and password - * stored in the URL. - * Returns nil if we have no username or password. - */ - _credential = [[NSURLCredential alloc] - initWithUser: [url user] - password: [url password] - persistence: NSURLCredentialPersistenceForSession]; - if (_credential == nil) - { - /* No credential from the URL, so we try using the - * default credential for the protection space. - */ - ASSIGN(_credential, - [[NSURLCredentialStorage sharedCredentialStorage] - defaultCredentialForProtectionSpace: space]); - } - } - - if (_challenge != nil) - { - /* The failure count is incremented if we have just - * tried a request in the same protection space. - */ - if (YES == [[_challenge protectionSpace] isEqual: space]) - { - failures = [_challenge previousFailureCount] + 1; - } - } - else if ([this->request valueForHTTPHeaderField:@"Authorization"]) - { - /* Our request had an authorization header, so we should - * count that as a failure or we wouldn't have been - * challenged. - */ - failures = 1; - } - DESTROY(_challenge); - - _challenge = [[NSURLAuthenticationChallenge alloc] - initWithProtectionSpace: space - proposedCredential: _credential - previousFailureCount: failures - failureResponse: _response - error: nil - sender: self]; - - /* Allow the client to control the credential we send - * or whether we actually send at all. - */ - [this->client URLProtocol: self - didReceiveAuthenticationChallenge: _challenge]; - - if (_challenge == nil) - { - NSError *e; - - /* The client cancelled the authentication challenge - * so we must cancel the download. - */ - e = [NSError errorWithDomain: @"Authentication cancelled" - code: 0 - userInfo: nil]; - [self stopLoading]; - [this->client URLProtocol: self - didFailWithError: e]; - } - else - { - NSString *auth = nil; - - if (_credential != nil) - { - GSHTTPAuthentication *authentication; - - /* Get information about basic or - * digest authentication. - */ - authentication = [GSHTTPAuthentication - authenticationWithCredential: _credential - inProtectionSpace: space]; - - /* Generate authentication header value for the - * authentication type in the challenge. - */ - auth = [authentication - authorizationForAuthentication: hdr - method: [this->request HTTPMethod] - path: [url fullPath]]; - } - - if (auth == nil) - { - NSURLCacheStoragePolicy policy; - - /* We have no authentication credentials so we - * treat this as a download of the challenge page. - */ - - /* Tell the client that we have a response and how - * it should be cached. - */ - policy = [this->request cachePolicy]; - if (policy == (NSURLCacheStoragePolicy) - NSURLRequestUseProtocolCachePolicy) - { - if ([self isKindOfClass: [_NSHTTPSURLProtocol class]]) - { - /* For HTTPS we should not allow caching unless - * the request explicitly wants it. - */ - policy = NSURLCacheStorageNotAllowed; - } - else - { - /* For HTTP we allow caching unless the request - * specifically denies it. - */ - policy = NSURLCacheStorageAllowed; - } - } - [this->client URLProtocol: self - didReceiveResponse: _response - cacheStoragePolicy: policy]; - /* Fall through to code providing page data. - */ - } - else - { - NSMutableURLRequest *request; - - /* To answer the authentication challenge, - * we must retry with a modified request and - * with the cached response cleared. - */ - request = [this->request mutableCopy]; - [request setValue: auth - forHTTPHeaderField: @"Authorization"]; - [self stopLoading]; - [this->request release]; - this->request = request; - DESTROY(this->cachedResponse); - [self startLoading]; - return; - } - } - } - - [this->input removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - if (_shouldClose == YES) - { - [this->input setDelegate: nil]; - [this->output setDelegate: nil]; - [this->input close]; - [this->output close]; - DESTROY(this->input); - DESTROY(this->output); - } - - /* - * Tell superclass that we have successfully loaded the data - * (as long as we haven't had the load terminated by the client). - */ - if (_isLoading == YES) - { - d = [_parser data]; - bodyLength = [d length]; - if (bodyLength > _parseOffset) - { - if (_parseOffset > 0) - { - d = [d subdataWithRange: - NSMakeRange(_parseOffset, bodyLength - _parseOffset)]; - } - _parseOffset = bodyLength; - [self _didLoad: d]; - } - - /* Check again in case the client cancelled the load inside - * the URLProtocol:didLoadData: callback. - */ - if (_isLoading == YES) - { - _isLoading = NO; - [this->client URLProtocolDidFinishLoading: self]; - } - } - } - else if (_isLoading == YES && _statusCode != 401) - { - /* - * Report partial data if possible. - */ - if ([_parser isInBody]) - { - d = [_parser data]; - bodyLength = [d length]; - if (bodyLength > _parseOffset) - { - if (_parseOffset > 0) - { - d = [d subdataWithRange: - NSMakeRange(_parseOffset, [d length] - _parseOffset)]; - } - _parseOffset = bodyLength; - [self _didLoad: d]; - } - } - } - - if (_complete == NO && readCount == 0 && _isLoading == YES) - { - /* The read failed ... dropped, but parsing is not complete. - * The request was sent, so we can't know whether it was - * lost in the network or the remote end received it and - * the response was lost. - */ - if (_debug == YES) - { - NSLog(@"%@ HTTP response not received - %@", self, _parser); - } - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: - [NSError errorWithDomain: @"receive incomplete" - code: 0 - userInfo: nil]]; - } - } -} - -- (void) stream: (NSStream*) stream handleEvent: (NSStreamEvent) event -{ - /* Make sure no action triggered by anything else destroys us prematurely. - */ - IF_NO_GC([[self retain] autorelease];) - -#if 0 - NSLog(@"stream: %@ handleEvent: %x for: %@", stream, event, self); -#endif - - if (stream == this->input) - { - switch(event) - { - case NSStreamEventHasBytesAvailable: - case NSStreamEventEndEncountered: - [self _got: stream]; - return; - - case NSStreamEventOpenCompleted: - if (_debug == YES) - { - NSLog(@"%@ HTTP input stream opened", self); - } - return; - - default: - break; - } - } - else if (stream == this->output) - { - switch(event) - { - case NSStreamEventOpenCompleted: - { - NSMutableString *m; - NSDictionary *d; - NSEnumerator *e; - NSString *s; - NSURL *u; - int l; - - if (_debug == YES) - { - NSLog(@"%@ HTTP output stream opened", self); - } - DESTROY(_writeData); - _writeOffset = 0; - if ([this->request HTTPBodyStream] == nil) - { - // Not streaming - l = [[this->request HTTPBody] length]; - _version = 1.1; - } - else - { - // Stream and close - l = -1; - _version = 1.0; - _shouldClose = YES; - } - - m = [[NSMutableString alloc] initWithCapacity: 1024]; - - /* The request line is of the form: - * method /path?query HTTP/version - * where the query part may be missing - */ - [m appendString: [this->request HTTPMethod]]; - [m appendString: @" "]; - u = [this->request URL]; - s = [[u fullPath] stringByAddingPercentEscapesUsingEncoding: - NSUTF8StringEncoding]; - if ([s hasPrefix: @"/"] == NO) - { - [m appendString: @"/"]; - } - [m appendString: s]; - s = [u query]; - if ([s length] > 0) - { - [m appendString: @"?"]; - [m appendString: s]; - } - [m appendFormat: @" HTTP/%0.1f\r\n", _version]; - - d = [this->request allHTTPHeaderFields]; - e = [d keyEnumerator]; - while ((s = [e nextObject]) != nil) - { - [m appendString: s]; - [m appendString: @": "]; - [m appendString: [d objectForKey: s]]; - [m appendString: @"\r\n"]; - } - /* Use valueForHTTPHeaderField: to check for content-type - * header as that does a case insensitive comparison and - * we therefore won't end up adding a second header by - * accident because the two header names differ in case. - */ - if ([[this->request HTTPMethod] isEqual: @"POST"] - && [this->request valueForHTTPHeaderField: - @"Content-Type"] == nil) - { - /* On MacOSX, this is automatically added to POST methods */ - [m appendString: - @"Content-Type: application/x-www-form-urlencoded\r\n"]; - } - if ([this->request valueForHTTPHeaderField: @"Host"] == nil) - { - id p = [u port]; - id h = [u host]; - - if (h == nil) - { - h = @""; // Must send an empty host header - } - if (p == nil) - { - [m appendFormat: @"Host: %@\r\n", h]; - } - else - { - [m appendFormat: @"Host: %@:%@\r\n", h, p]; - } - } - if (l >= 0 && [this->request - valueForHTTPHeaderField: @"Content-Length"] == nil) - { - [m appendFormat: @"Content-Length: %d\r\n", l]; - } - [m appendString: @"\r\n"]; // End of headers - _writeData = RETAIN([m dataUsingEncoding: NSASCIIStringEncoding]); - RELEASE(m); - } // Fall through to do the write - - case NSStreamEventHasSpaceAvailable: - { - int written; - BOOL sent = NO; - - // FIXME: should also send out relevant Cookies - if (_writeData != nil) - { - const unsigned char *bytes = [_writeData bytes]; - unsigned len = [_writeData length]; - - written = [this->output write: bytes + _writeOffset - maxLength: len - _writeOffset]; - if (written > 0) - { - if (_debug == YES) - { - NSLog(@"%@ wrote %d bytes: '%*.*s'", self, written, - written, written, bytes + _writeOffset); - } - _writeOffset += written; - if (_writeOffset >= len) - { - DESTROY(_writeData); - if (_body == nil) - { - _body = RETAIN([this->request HTTPBodyStream]); - if (_body == nil) - { - NSData *d = [this->request HTTPBody]; - - if (d != nil) - { - _body = [NSInputStream alloc]; - _body = [_body initWithData: d]; - [_body open]; - } - else - { - sent = YES; - } - } - } - } - } - } - else if (_body != nil) - { - if ([_body hasBytesAvailable]) - { - unsigned char buffer[BUFSIZ*64]; - int len; - - len = [_body read: buffer maxLength: sizeof(buffer)]; - if (len < 0) - { - if (_debug == YES) - { - NSLog(@"%@ error reading from HTTPBody stream %@", - self, [NSError _last]); - } - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: - [NSError errorWithDomain: @"can't read body" - code: 0 - userInfo: nil]]; - return; - } - else if (len > 0) - { - written = [this->output write: buffer maxLength: len]; - if (written > 0) - { - if (_debug == YES) - { - NSLog(@"%@ wrote %d bytes: '%*.*s'", self, - written, written, written, buffer); - } - len -= written; - if (len > 0) - { - /* Couldn't write it all now, save and try - * again later. - */ - _writeData = [[NSData alloc] initWithBytes: - buffer + written length: len]; - _writeOffset = 0; - } - } - } - else - { - [_body close]; - DESTROY(_body); - sent = YES; - } - } - else - { - [_body close]; - DESTROY(_body); - sent = YES; - } - } - if (sent == YES) - { - if (_debug) - { - NSLog(@"%@ request sent", self); - } - if (_shouldClose == YES) - { - [this->output removeFromRunLoop: - [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output close]; - DESTROY(this->output); - } - } - return; // done - } - default: - break; - } - } - else - { - NSLog(@"Unexpected event %d occurred on stream %@ not being used by %@", - event, stream, self); - } - if (event == NSStreamEventErrorOccurred) - { - NSError *error = [[[stream streamError] retain] autorelease]; - - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: error]; - } - else - { - NSLog(@"Unexpected event %d ignored on stream %@ of %@", - event, stream, self); - } -} - -- (void) useCredential: (NSURLCredential*)credential - forAuthenticationChallenge: (NSURLAuthenticationChallenge*)challenge -{ - if (challenge == _challenge) - { - ASSIGN(_credential, credential); - } -} -@end - -@implementation _NSHTTPSURLProtocol - -+ (BOOL) canInitWithRequest: (NSURLRequest*)request -{ - return [[[request URL] scheme] isEqualToString: @"https"]; -} - -@end - -@implementation _NSFTPURLProtocol - -+ (BOOL) canInitWithRequest: (NSURLRequest*)request -{ - return [[[request URL] scheme] isEqualToString: @"ftp"]; -} - -+ (NSURLRequest*) canonicalRequestForRequest: (NSURLRequest*)request -{ - return request; -} - -- (void) startLoading -{ - if (this->cachedResponse) - { // handle from cache - } - else - { - NSURL *url = [this->request URL]; - NSHost *host = [NSHost hostWithName: [url host]]; - - if (host == nil) - { - host = [NSHost hostWithAddress: [url host]]; - } - [NSStream getStreamsToHost: host - port: [[url port] intValue] - inputStream: &this->input - outputStream: &this->output]; - if (this->input == nil || this->output == nil) - { - [this->client URLProtocol: self didFailWithError: - [NSError errorWithDomain: @"can't connect" - code: 0 - userInfo: nil]]; - return; - } -#if !GS_WITH_GC - [this->input retain]; - [this->output retain]; -#endif - if ([[url scheme] isEqualToString: @"https"] == YES) - { - [this->input setProperty: NSStreamSocketSecurityLevelNegotiatedSSL - forKey: NSStreamSocketSecurityLevelKey]; - [this->output setProperty: NSStreamSocketSecurityLevelNegotiatedSSL - forKey: NSStreamSocketSecurityLevelKey]; - } - [this->input setDelegate: self]; - [this->output setDelegate: self]; - [this->input scheduleInRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output scheduleInRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - // set socket options for ftps requests - [this->input open]; - [this->output open]; - } -} - -- (void) stopLoading -{ - if (this->input) - { - [this->input setDelegate: nil]; - [this->output setDelegate: nil]; - [this->input removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->output removeFromRunLoop: [NSRunLoop currentRunLoop] - forMode: NSDefaultRunLoopMode]; - [this->input close]; - [this->output close]; - DESTROY(this->input); - DESTROY(this->output); - } -} - -- (void) stream: (NSStream *) stream handleEvent: (NSStreamEvent) event -{ - if (stream == this->input) - { - switch(event) - { - case NSStreamEventHasBytesAvailable: - { - NSLog(@"FTP input stream has bytes available"); - // implement FTP protocol -// [this->client URLProtocol: self didLoadData: [NSData dataWithBytes: buffer length: len]]; // notify - return; - } - case NSStreamEventEndEncountered: // can this occur in parallel to NSStreamEventHasBytesAvailable??? - NSLog(@"FTP input stream did end"); - [this->client URLProtocolDidFinishLoading: self]; - return; - case NSStreamEventOpenCompleted: - // prepare to receive header - NSLog(@"FTP input stream opened"); - return; - default: - break; - } - } - else if (stream == this->output) - { - NSLog(@"An event occurred on the output stream."); - // if successfully opened, send out FTP request header - } - else - { - NSLog(@"Unexpected event %d occurred on stream %@ not being used by %@", - event, stream, self); - } - if (event == NSStreamEventErrorOccurred) - { - NSLog(@"An error %@ occurred on stream %@ of %@", - [stream streamError], stream, self); - [self stopLoading]; - [this->client URLProtocol: self didFailWithError: [stream streamError]]; - } - else - { - NSLog(@"Unexpected event %d ignored on stream %@ of %@", - event, stream, self); - } -} - -@end - -@implementation _NSFileURLProtocol - -+ (BOOL) canInitWithRequest: (NSURLRequest*)request -{ - return [[[request URL] scheme] isEqualToString: @"file"]; -} - -+ (NSURLRequest*) canonicalRequestForRequest: (NSURLRequest*)request -{ - return request; -} - -- (void) startLoading -{ - // check for GET/PUT/DELETE etc so that we can also write to a file - NSData *data; - NSURLResponse *r; - - data = [NSData dataWithContentsOfFile: [[this->request URL] path] - /* options: error: - don't use that because it is based on self */]; - if (data == nil) - { - [this->client URLProtocol: self didFailWithError: - [NSError errorWithDomain: @"can't load file" code: 0 userInfo: - [NSDictionary dictionaryWithObjectsAndKeys: - [this->request URL], @"URL", - [[this->request URL] path], @"path", - nil]]]; - return; - } - - /* FIXME ... maybe should infer MIME type and encoding from extension or BOM - */ - r = [[NSURLResponse alloc] initWithURL: [this->request URL] - MIMEType: @"text/html" - expectedContentLength: [data length] - textEncodingName: @"unknown"]; - [this->client URLProtocol: self - didReceiveResponse: r - cacheStoragePolicy: NSURLRequestUseProtocolCachePolicy]; - [this->client URLProtocol: self didLoadData: data]; - [this->client URLProtocolDidFinishLoading: self]; - RELEASE(r); -} - -- (void) stopLoading -{ - return; -} - -@end - -@implementation _NSAboutURLProtocol - -+ (BOOL) canInitWithRequest: (NSURLRequest*)request -{ - return [[[request URL] scheme] isEqualToString: @"about"]; -} - -+ (NSURLRequest*) canonicalRequestForRequest: (NSURLRequest*)request -{ - return request; -} - -- (void) startLoading -{ - NSURLResponse *r; - NSData *data = [NSData data]; // no data - - // we could pass different content depending on the url path - r = [[NSURLResponse alloc] initWithURL: [this->request URL] - MIMEType: @"text/html" - expectedContentLength: 0 - textEncodingName: @"utf-8"]; - [this->client URLProtocol: self - didReceiveResponse: r - cacheStoragePolicy: NSURLRequestUseProtocolCachePolicy]; - [this->client URLProtocol: self didLoadData: data]; - [this->client URLProtocolDidFinishLoading: self]; - RELEASE(r); -} - -- (void) stopLoading -{ - return; -} - -@end diff --git a/Source/NSURLRequest.m b/Source/NSURLRequest.m index b3102eb6f..4d44d9e8c 100644 --- a/Source/NSURLRequest.m +++ b/Source/NSURLRequest.m @@ -1,13 +1,13 @@ /* Implementation for NSURLRequest for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,19 +16,17 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include "GSURLPrivate.h" -#define EXPOSE_NSURLRequest_IVARS 1 -#import "GSURLPrivate.h" -#import "GSPrivate.h" - -#import "Foundation/NSCoder.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSCoder.h" +#include "NSCallBacks.h" // Internal data storage @@ -36,7 +34,7 @@ typedef struct { NSData *body; NSInputStream *bodyStream; NSString *method; - NSMutableDictionary *headers; + NSMapTable *headers; BOOL shouldHandleCookies; NSURL *URL; NSURL *mainDocumentURL; @@ -48,11 +46,11 @@ typedef struct { /* Defines to get easy access to internals from mutable/immutable * versions of the class and from categories. */ -#define this ((Internal*)(self->_NSURLRequestInternal)) -#define inst ((Internal*)(((NSURLRequest*)o)->_NSURLRequestInternal)) - -@interface _GSMutableInsensitiveDictionary : NSMutableDictionary -@end +typedef struct { + @defs(NSURLRequest) +} priv; +#define this ((Internal*)(((priv*)self)->_NSURLRequestInternal)) +#define inst ((Internal*)(((priv*)o)->_NSURLRequestInternal)) @implementation NSURLRequest @@ -114,7 +112,14 @@ typedef struct { ASSIGN(inst->bodyStream, this->bodyStream); ASSIGN(inst->method, this->method); inst->shouldHandleCookies = this->shouldHandleCookies; - inst->headers = [this->headers mutableCopy]; + if (this->headers == 0) + { + inst->headers = 0; + } + else + { + inst->headers = NSCopyMapTableWithZone(this->headers, z); + } } } return o; @@ -130,7 +135,10 @@ typedef struct { RELEASE(this->URL); RELEASE(this->mainDocumentURL); RELEASE(this->properties); - RELEASE(this->headers); + if (this->headers != 0) + { + NSFreeMapTable(this->headers); + } NSZoneFree([self zone], this); } [super dealloc]; @@ -165,16 +173,11 @@ typedef struct { return self; } -- (NSUInteger) hash +- (unsigned) hash { return [this->URL hash]; } -- (id) init -{ - return [self initWithURL: nil]; -} - - (id) initWithURL: (NSURL *)URL { return [self initWithURL: URL @@ -186,17 +189,12 @@ typedef struct { cachePolicy: (NSURLRequestCachePolicy)cachePolicy timeoutInterval: (NSTimeInterval)timeoutInterval { - if ([URL isKindOfClass: [NSURL class]] == NO) - { - DESTROY(self); - } - else if ((self = [super init]) != nil) + if ((self = [super init]) != nil) { this->URL = RETAIN(URL); this->cachePolicy = cachePolicy; this->timeoutInterval = timeoutInterval; this->mainDocumentURL = nil; - this->method = @"GET"; } return self; } @@ -237,10 +235,32 @@ typedef struct { { return NO; } - if (this->headers != inst->headers - && [this->headers isEqual: inst->headers] == NO) + if (this->headers != inst->headers) { - return NO; + NSMapEnumerator enumerator; + id k; + id v; + + if (this->headers == 0 || inst->headers == 0) + { + return NO; + } + if (NSCountMapTable(this->headers) != NSCountMapTable(inst->headers)) + { + return NO; + } + enumerator = NSEnumerateMapTable(this->headers); + while (NSNextMapEnumeratorPair(&enumerator, (void **)(&k), (void**)&v)) + { + id ov = (id)NSMapGet(inst->headers, (void*)k); + + if ([v isEqual: ov] == NO) + { + NSEndMapTableEnumeration(&enumerator); + return NO; + } + } + NSEndMapTableEnumeration(&enumerator); } return YES; } @@ -267,7 +287,14 @@ typedef struct { ASSIGN(inst->bodyStream, this->bodyStream); ASSIGN(inst->method, this->method); inst->shouldHandleCookies = this->shouldHandleCookies; - inst->headers = [this->headers mutableCopy]; + if (this->headers == 0) + { + inst->headers = 0; + } + else + { + inst->headers = NSCopyMapTableWithZone(this->headers, z); + } } return o; } @@ -309,19 +336,62 @@ typedef struct { @end + + +/* + * Implement map keys for strings with case insensitive comparisons, + * so we can have case insensitive matching of http headers (correct + * behavior), but actually preserve case of headers stored and written + * in case the remote server is buggy and requires particular + * captialisation of headers (some http software is faulty like that). + */ +static unsigned int +_non_retained_id_hash(void *table, NSString* o) +{ + return [[o uppercaseString] hash]; +} + +static BOOL +_non_retained_id_is_equal(void *table, NSString *o, NSString *p) +{ + return ([o caseInsensitiveCompare: p] == NSOrderedSame) ? YES : NO; +} + +typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *); +typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *); +typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); +typedef void (*NSMT_release_func_t)(NSMapTable *, void *); +typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *); + +static const NSMapTableKeyCallBacks headerKeyCallBacks = +{ + (NSMT_hash_func_t) _non_retained_id_hash, + (NSMT_is_equal_func_t) _non_retained_id_is_equal, + (NSMT_retain_func_t) _NS_non_retained_id_retain, + (NSMT_release_func_t) _NS_non_retained_id_release, + (NSMT_describe_func_t) _NS_non_retained_id_describe, + NSNotAPointerMapKey +}; + @implementation NSURLRequest (NSHTTPURLRequest) - (NSDictionary *) allHTTPHeaderFields { - NSDictionary *fields; + NSMutableDictionary *fields; - if (this->headers == nil) + fields = [NSMutableDictionary dictionaryWithCapacity: 8]; + if (this->headers != 0) { - fields = [NSDictionary dictionary]; - } - else - { - fields = [NSDictionary dictionaryWithDictionary: this->headers]; + NSMapEnumerator enumerator; + NSString *k; + NSString *v; + + enumerator = NSEnumerateMapTable(this->headers); + while (NSNextMapEnumeratorPair(&enumerator, (void **)(&k), (void**)&v)) + { + [fields setObject: v forKey: k]; + } + NSEndMapTableEnumeration(&enumerator); } return fields; } @@ -348,7 +418,13 @@ typedef struct { - (NSString *) valueForHTTPHeaderField: (NSString *)field { - return [this->headers objectForKey: field]; + NSString *value = nil; + + if (this->headers != 0) + { + value = (NSString*)NSMapGet(this->headers, (void*)field); + } + return value; } @end @@ -398,14 +474,6 @@ typedef struct { - (void) setHTTPMethod: (NSString *)method { -/* NB. I checked MacOS-X 4.2, and this method actually lets you set any - * copyable value (including non-string classes), but setting nil is - * equivalent to resetting to the default value of 'GET' - */ - if (method == nil) - { - method = @"GET"; - } ASSIGNCOPY(this->method, method); } @@ -416,11 +484,12 @@ typedef struct { - (void) setValue: (NSString *)value forHTTPHeaderField: (NSString *)field { - if (this->headers == nil) + if (this->headers == 0) { - this->headers = [_GSMutableInsensitiveDictionary new]; + this->headers = NSCreateMapTable(headerKeyCallBacks, + NSObjectMapValueCallBacks, 8); } - [this->headers setObject: value forKey: field]; + NSMapInsert(this->headers, (void*)field, (void*)value); } @end diff --git a/Source/NSURLResponse.m b/Source/NSURLResponse.m index c463ceeb0..aa0674903 100644 --- a/Source/NSURLResponse.m +++ b/Source/NSURLResponse.m @@ -1,13 +1,13 @@ /* Implementation for NSURLResponse for GNUstep Copyright (C) 2006 Software Foundation, Inc. - Written by: Richard Frith-Macdonald + Written by: Richard Frith-Macdonald Date: 2006 This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,130 +16,104 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include "GSURLPrivate.h" -#define EXPOSE_NSURLResponse_IVARS 1 -#import "GSURLPrivate.h" -#import "GSPrivate.h" - -#import "Foundation/NSCoder.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSScanner.h" -#import "NSCallBacks.h" -#import "GNUstepBase/GSMime.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSScanner.h" +#include "NSCallBacks.h" +#include "GNUstepBase/GSMime.h" // Internal data storage typedef struct { - long long expectedContentLength; - NSURL *URL; - NSString *MIMEType; - NSString *textEncodingName; - NSString *statusText; - NSMutableDictionary *headers; /* _GSMutableInsensitiveDictionary */ - int statusCode; + long long expectedContentLength; + NSURL *URL; + NSString *MIMEType; + NSString *textEncodingName; + NSString *statusText; + NSMapTable *headers; + int statusCode; } Internal; -#define this ((Internal*)(self->_NSURLResponseInternal)) -#define inst ((Internal*)(o->_NSURLResponseInternal)) +typedef struct { + @defs(NSURLResponse) +} priv; +#define this ((Internal*)(((priv*)self)->_NSURLResponseInternal)) +#define inst ((Internal*)(((priv*)o)->_NSURLResponseInternal)) -@interface _GSMutableInsensitiveDictionary : NSMutableDictionary +/* + * Implement map keys for strings with case insensitive comparisons, + * so we can have case insensitive matching of http headers (correct + * behavior), but actually preserve case of headers stored and written + * in case the remote server is buggy and requires particular + * captialisation of headers (some http software is faulty like that). + */ +static unsigned int +_non_retained_id_hash(void *table, NSString* o) +{ + return [[o uppercaseString] hash]; +} + +static BOOL +_non_retained_id_is_equal(void *table, NSString *o, NSString *p) +{ + return ([o caseInsensitiveCompare: p] == NSOrderedSame) ? YES : NO; +} + +typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *); +typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *); +typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); +typedef void (*NSMT_release_func_t)(NSMapTable *, void *); +typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *); + +static const NSMapTableKeyCallBacks headerKeyCallBacks = +{ + (NSMT_hash_func_t) _non_retained_id_hash, + (NSMT_is_equal_func_t) _non_retained_id_is_equal, + (NSMT_retain_func_t) _NS_non_retained_id_retain, + (NSMT_release_func_t) _NS_non_retained_id_release, + (NSMT_describe_func_t) _NS_non_retained_id_describe, + NSNotAPointerMapKey +}; + +@interface NSURLResponse (Internal) +- (void) setStatusCode: (int)code text: (NSString*)text; +- (void) setValue: (NSString *)value forHTTPHeaderField: (NSString *)field; +- (NSString *) valueForHTTPHeaderField: (NSString *)field; @end -@implementation NSURLResponse (Private) - -- (void) _setHeaders: (id)headers -{ - NSEnumerator *e; - NSString *v; - NSString *contentLength = nil; - GSMimeHeader *contentType = nil; - - if ([headers isKindOfClass: [NSDictionary class]] == YES) - { - NSString *k; - - e = [headers keyEnumerator]; - while ((k = [e nextObject]) != nil) - { - v = [headers objectForKey: k]; - [self _setValue: v forHTTPHeaderField: k]; - } - } - else if ([headers isKindOfClass: [NSArray class]] == YES) - { - GSMimeHeader *h; - - e = [headers objectEnumerator]; - while ((h = [e nextObject]) != nil) - { - NSString *n = [h namePreservingCase: YES]; - NSString *v = [h fullValue]; - - if ([n caseInsensitiveCompare: @"content-type"] == NSOrderedSame) - { - contentType = h; - } - [self _setValue: v forHTTPHeaderField: n]; - } - } - - if (contentLength == nil) - { - contentLength = [self _valueForHTTPHeaderField: @"content-length"]; - } - if ([contentLength length] == 0) - { - this->expectedContentLength = -1; - } - else - { - this->expectedContentLength = [contentLength intValue]; - } - - if (contentType == nil) - { - GSMimeParser *p; - NSScanner *s; - - v = [self _valueForHTTPHeaderField: @"content-type"]; - if (v == nil) - { - v = @"text/plain"; // No content type given. - } - s = [NSScanner scannerWithString: v]; - p = [GSMimeParser new]; - contentType = AUTORELEASE([GSMimeHeader new]); - [p scanHeaderBody: s into: contentType]; - RELEASE(p); - } - ASSIGNCOPY(this->MIMEType, [contentType value]); - v = [contentType parameterForKey: @"charset"]; - ASSIGNCOPY(this->textEncodingName, v); -} -- (void) _setStatusCode: (NSInteger)code text: (NSString*)text +@implementation NSURLResponse (Internal) +- (void) setStatusCode: (int)code text: (NSString*)text { this->statusCode = code; ASSIGNCOPY(this->statusText, text); } -- (void) _setValue: (NSString *)value forHTTPHeaderField: (NSString *)field +- (void) setValue: (NSString *)value forHTTPHeaderField: (NSString *)field { if (this->headers == 0) { - this->headers = [_GSMutableInsensitiveDictionary new]; + this->headers = NSCreateMapTable(headerKeyCallBacks, + NSObjectMapValueCallBacks, 8); } - [this->headers setObject: value forKey: field]; + NSMapInsert(this->headers, (void*)field, (void*)value); } -- (NSString *) _valueForHTTPHeaderField: (NSString *)field +- (NSString *) valueForHTTPHeaderField: (NSString *)field { - return [this->headers objectForKey: field]; + NSString *value = nil; + + if (this->headers != 0) + { + value = (NSString*)NSMapGet(this->headers, (void*)field); + } + return value; } @end @@ -182,7 +156,7 @@ typedef struct { } else { - inst->headers = [this->headers mutableCopy]; + inst->headers = NSCopyMapTableWithZone(this->headers, z); } } } @@ -197,7 +171,10 @@ typedef struct { RELEASE(this->MIMEType); RELEASE(this->textEncodingName); RELEASE(this->statusText); - RELEASE(this->headers); + if (this->headers != 0) + { + NSFreeMapTable(this->headers); + } NSZoneFree([self zone], this); } [super dealloc]; @@ -237,7 +214,7 @@ typedef struct { */ - (id) initWithURL: (NSURL *)URL MIMEType: (NSString *)MIMEType - expectedContentLength: (NSInteger)length + expectedContentLength: (int)length textEncodingName: (NSString *)name { if ((self = [super init]) != nil) @@ -270,7 +247,7 @@ typedef struct { */ - (NSString *) suggestedFilename { - NSString *disp = [self _valueForHTTPHeaderField: @"content-disposition"]; + NSString *disp = [self valueForHTTPHeaderField: @"content-disposition"]; NSString *name = nil; if (disp != nil) @@ -283,7 +260,7 @@ typedef struct { p = AUTORELEASE([GSMimeParser new]); h = [[GSMimeHeader alloc] initWithName: @"content-displosition" value: disp]; - IF_NO_GC([h autorelease];) + AUTORELEASE(h); sc = [NSScanner scannerWithString: [h value]]; if ([p scanHeaderBody: sc into: h] == YES) { @@ -324,7 +301,7 @@ typedef struct { @implementation NSHTTPURLResponse -+ (NSString *) localizedStringForStatusCode: (NSInteger)statusCode ++ (NSString *) localizedStringForStatusCode: (int)statusCode { // FIXME ... put real responses in here return [NSString stringWithFormat: @"%d", statusCode]; @@ -332,12 +309,29 @@ typedef struct { - (NSDictionary *) allHeaderFields { - return AUTORELEASE([this->headers copy]); + NSMutableDictionary *fields; + + fields = [NSMutableDictionary dictionaryWithCapacity: 8]; + if (this->headers != 0) + { + NSMapEnumerator enumerator; + NSString *k; + NSString *v; + + enumerator = NSEnumerateMapTable(this->headers); + while (NSNextMapEnumeratorPair(&enumerator, (void **)(&k), (void**)&v)) + { + [fields setObject: v forKey: k]; + } + NSEndMapTableEnumeration(&enumerator); + } + return fields; } -- (NSInteger) statusCode +- (int) statusCode { return this->statusCode; } + @end diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index a9151d9c7..b9f89291d 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -25,12 +25,12 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSUnarchiver_IVARS 1 +#include "config.h" #include -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSByteOrder.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSZone.h" +#include "Foundation/NSException.h" +#include "Foundation/NSByteOrder.h" /* * Setup for inline operation of arrays. @@ -42,13 +42,15 @@ #include "GNUstepBase/GSIArray.h" #define _IN_NSUNARCHIVER_M -#import "Foundation/NSArchiver.h" +#include "Foundation/NSArchiver.h" #undef _IN_NSUNARCHIVER_M -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSData.h" -#import "Foundation/NSArray.h" +#include "Foundation/NSAutoreleasePool.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSData.h" +#include "Foundation/NSUtilities.h" +#include "Foundation/NSString.h" +#include "Foundation/NSArray.h" @class NSDataMalloc; @interface NSDataMalloc : NSObject // Help the compiler @@ -158,8 +160,13 @@ static char type_map[32] = { _C_UINT, _C_LNG, _C_ULNG, +#ifdef _C_LNG_LNG _C_LNG_LNG, _C_ULNG_LNG, +#else + 0, + 0, +#endif _C_FLT, _C_DBL, 0, @@ -183,8 +190,7 @@ static char type_map[32] = { 0 }; - -static inline BOOL +static inline void typeCheck(char t1, char t2) { if (type_map[(t2 & _GSC_MASK)] != t1) @@ -196,54 +202,29 @@ typeCheck(char t1, char t2) * can vary. */ char c = type_map[(t2 & _GSC_MASK)]; - char s1; - char s2; - - switch (t1) - { - case _C_SHT: s1 = _GSC_S_SHT; break; - case _C_USHT: s1 = _GSC_S_SHT; break; - case _C_INT: s1 = _GSC_S_INT; break; - case _C_UINT: s1 = _GSC_S_INT; break; - case _C_LNG: s1 = _GSC_S_LNG; break; - case _C_ULNG: s1 = _GSC_S_LNG; break; - case _C_LNG_LNG: s1 = _GSC_S_LNG_LNG; break; - case _C_ULNG_LNG: s1 = _GSC_S_LNG_LNG; break; - default: s1 = 0; - } - - switch (t2) - { - case _C_SHT: s2 = _GSC_S_SHT; break; - case _C_USHT: s2 = _GSC_S_SHT; break; - case _C_INT: s2 = _GSC_S_INT; break; - case _C_UINT: s2 = _GSC_S_INT; break; - case _C_LNG: s2 = _GSC_S_LNG; break; - case _C_ULNG: s2 = _GSC_S_LNG; break; - case _C_LNG_LNG: s2 = _GSC_S_LNG_LNG; break; - case _C_ULNG_LNG: s2 = _GSC_S_LNG_LNG; break; - default: s2 = 0; - } - - if ((c == _C_INT || c == _C_LNG || c == _C_LNG_LNG) - && (t1 == _C_INT || t1 == _C_LNG || t1 == _C_LNG_LNG)) - return s1 == s2 ? YES : NO; - - if ((c == _C_UINT || c == _C_ULNG || c == _C_ULNG_LNG) - && (t1 == _C_UINT || t1 == _C_ULNG || t1 == _C_ULNG_LNG)) - return s1 == s2 ? YES : NO; - -/* HACK also allow float and double to be used interchangably as MacOS-X - * intorduced CGFloat, which may be aither a float or a double. - */ - if ((c == _C_FLT || c == _C_DBL) && (t1 == _C_FLT || t1 == _C_DBL)) - return NO; + if ((c == _C_INT || c == _C_LNG +#ifdef _C_LNG_LNG + || c == _C_LNG_LNG +#endif + ) && (t1 == _C_INT || t1 == _C_LNG +#ifdef _C_LNG_LNG + || t1 == _C_LNG_LNG +#endif + )) return; + if ((c == _C_UINT || c == _C_ULNG +#ifdef _C_LNG_LNG + || c == _C_ULNG_LNG +#endif + ) && (t1 == _C_UINT || t1 == _C_ULNG +#ifdef _C_LNG_LNG + || t1 == _C_ULNG_LNG +#endif + )) return; [NSException raise: NSInternalInconsistencyException format: @"expected %s and got %s", typeToName1(t1), typeToName2(t2)]; } - return YES; } #define PREFIX "GNUstep archive" @@ -302,7 +283,7 @@ static NSMutableDictionary *clsDict; /* Class information */ @interface NSUnarchiverObjectInfo : NSUnarchiverClassInfo { @public - NSInteger version; + unsigned version; NSUnarchiverClassInfo *overrides; } @end @@ -512,7 +493,7 @@ static Class NSDataMallocClass; } NS_HANDLER { - DESTROY(self); + RELEASE(self); [localException raise]; } NS_ENDHANDLER @@ -555,8 +536,10 @@ static Class NSDataMallocClass; case _C_UINT: info = _GSC_UINT; break; case _C_LNG: info = _GSC_LNG; break; case _C_ULNG: info = _GSC_ULNG; break; +#ifdef _C_LNG_LNG case _C_LNG_LNG: info = _GSC_LNG_LNG; break; case _C_ULNG_LNG: info = _GSC_ULNG_LNG; break; +#endif case _C_FLT: info = _GSC_FLT; break; case _C_DBL: info = _GSC_DBL; break; default: info = _GSC_NONE; break; @@ -598,6 +581,15 @@ static Class NSDataMallocClass; { unsigned xref; unsigned char info; +#if GS_HAVE_I128 + gsu128 bigval; +#else +#if GS_HAVE_I64 + uint64_t bigval; +#else + uint32_t bigval; +#endif +#endif (*tagImp)(src, tagSel, &info, &xref, &cursor); @@ -748,24 +740,16 @@ static Class NSDataMallocClass; (*desImp)(src, desSel, &cver, @encode(unsigned), &cursor, nil); if (className == 0) { - NSLog(@"[%s %s] decoded nil class name", - class_getName([self class]), sel_getName(_cmd)); + NSLog(@"[%s %s] decoded nil class", + GSNameFromClass([self class]), GSNameFromSelector(_cmd)); className = @"_NSUnarchiverUnknownClass"; } classInfo = [objDict objectForKey: className]; if (classInfo == nil) { - classInfo = [NSUnarchiverObjectInfo newWithName: className]; + classInfo = [NSUnarchiverObjectInfo + newWithName: className]; c = NSClassFromString(className); - /* - * Show a warning, if the class name that's being used to - * build the class causes NSClassFromString to return nil. - * This means that the class is unknown to the runtime. - */ - if (c == nil) - { - NSLog(@"Unable to find class named '%@'", className); - } [classInfo mapToClass: c withName: className]; [objDict setObject: classInfo forKey: className]; RELEASE(classInfo); @@ -775,7 +759,7 @@ static Class NSDataMallocClass; c = classInfo->class; } RELEASE(className); - classInfo->version = (NSInteger)cver; + classInfo->version = cver; GSIArrayAddItem(clsMap, (GSIArrayItem)((id)classInfo)); *(Class*)address = mapClassObject(classInfo); /* @@ -956,8 +940,8 @@ static Class NSDataMallocClass; case _GSC_SHT: case _GSC_USHT: - if (YES == typeCheck(*type, info & _GSC_MASK) - && (info & _GSC_SIZE) == _GSC_S_SHT) + typeCheck(*type, info & _GSC_MASK); + if ((info & _GSC_SIZE) == _GSC_S_SHT) { (*desImp)(src, desSel, address, type, &cursor, nil); return; @@ -966,8 +950,8 @@ static Class NSDataMallocClass; case _GSC_INT: case _GSC_UINT: - if (YES == typeCheck(*type, info & _GSC_MASK) - && (info & _GSC_SIZE) == _GSC_S_INT) + typeCheck(*type, info & _GSC_MASK); + if ((info & _GSC_SIZE) == _GSC_S_INT) { (*desImp)(src, desSel, address, type, &cursor, nil); return; @@ -976,56 +960,34 @@ static Class NSDataMallocClass; case _GSC_LNG: case _GSC_ULNG: - if (YES == typeCheck(*type, info & _GSC_MASK) - && (info & _GSC_SIZE) == _GSC_S_LNG) + typeCheck(*type, info & _GSC_MASK); + if ((info & _GSC_SIZE) == _GSC_S_LNG) { (*desImp)(src, desSel, address, type, &cursor, nil); return; } break; +#ifdef _C_LNG_LNG case _GSC_LNG_LNG: case _GSC_ULNG_LNG: - if (YES == typeCheck(*type, info & _GSC_MASK) - && (info & _GSC_SIZE) == _GSC_S_LNG_LNG) + typeCheck(*type, info & _GSC_MASK); + if ((info & _GSC_SIZE) == _GSC_S_LNG_LNG) { (*desImp)(src, desSel, address, type, &cursor, nil); return; } break; +#endif case _GSC_FLT: - if (YES == typeCheck(*type, _GSC_FLT) - && *type == _C_FLT) - { - (*desImp)(src, desSel, address, type, &cursor, nil); - } - else - { - float val; - - /* We found a float when expecting a double ... handle it. - */ - (*desImp)(src, desSel, &val, @encode(float), &cursor, nil); - *(double*)address = (double)val; - } + typeCheck(*type, _GSC_FLT); + (*desImp)(src, desSel, address, type, &cursor, nil); return; case _GSC_DBL: - if (YES == typeCheck(*type, _GSC_DBL) - && *type == _C_DBL) - { - (*desImp)(src, desSel, address, type, &cursor, nil); - } - else - { - double val; - - /* We found a double when expecting a float ... handle it. - */ - (*desImp)(src, desSel, &val, @encode(double), &cursor, nil); - *(float*)address = (float)val; - } + typeCheck(*type, _GSC_DBL); + (*desImp)(src, desSel, address, type, &cursor, nil); return; default: @@ -1033,189 +995,104 @@ static Class NSDataMallocClass; format: @"read unknown type info - %d", info]; } -{ - uint8_t size; - /* * We fall through to here only when we have to decode a value * whose natural size on this system is not the same as on the * machine on which the archive was created. */ - switch (*type) - { - case _C_SHT: - case _C_USHT: size = sizeof(short); break; - case _C_INT: - case _C_UINT: size = sizeof(int); break; - case _C_LNG: - case _C_ULNG: size = sizeof(long); break; - case _C_LNG_LNG: - case _C_ULNG_LNG: size = sizeof(long long); break; - default: size = 1; - } - /* * First, we read the data and convert it to the largest size * this system can support. */ - if (*type == _C_SHT - || *type == _C_INT - || *type == _C_LNG - || *type == _C_LNG_LNG) + switch (info & _GSC_SIZE) { - int64_t big; + case _GSC_I16: /* Encoded as 16-bit */ + { + uint16_t val; - switch (info & _GSC_SIZE) - { - case _GSC_I16: /* Encoded as 16-bit */ - { - int16_t val; + (*desImp)(src, desSel, &val, @encode(uint16_t), &cursor, nil); + bigval = val; + break; + } - (*desImp)(src, desSel, &val, @encode(int16_t), &cursor, nil); - big = val; - break; - } + case _GSC_I32: /* Encoded as 32-bit */ + { + uint32_t val; - case _GSC_I32: /* Encoded as 32-bit */ - { - int32_t val; + (*desImp)(src, desSel, &val, @encode(uint32_t), &cursor, nil); + bigval = val; + break; + } - (*desImp)(src, desSel, &val, @encode(int32_t), &cursor, nil); - big = val; - break; - } + case _GSC_I64: /* Encoded as 64-bit */ + { + uint64_t val; - case _GSC_I64: /* Encoded as 64-bit */ - { - (*desImp)(src, desSel, &big, @encode(int64_t), &cursor, nil); - break; - } + (*desImp)(src, desSel, &val, @encode(uint64_t), &cursor, nil); +#if GS_HAVE_I64 + bigval = val; +#else + bigval = GSSwapBigI64ToHost(val); +#endif + break; + } - default: /* A 128-bit value */ - { - big = 0; - [NSException raise: NSInternalInconsistencyException - format: @"Archiving of 128bit integer not allowed"]; - } - } - /* - * Now we copy from the big value to the destination location. - */ - switch (size) - { - case 1: - *(int8_t*)address = (int8_t)big; - if (big & ~0xff) - { - if ((int8_t)big >= 0 || (big & ~0xff) != ~0xff) - { - NSLog(@"Loss of information converting decoded value to int8_t"); - } - } - return; - case 2: - *(int16_t*)address = (int16_t)big; - if (big & ~0xffff) - { - if ((int16_t)big >= 0 || (big & ~0xffff) != ~0xffff) - { - NSLog(@"Loss of information converting decoded value to int16_t"); - } - } - return; - case 4: - *(int32_t*)address = (int32_t)big; - if (big & ~0xffffffff) - { - if ((int32_t)big >= 0 || (big & ~0xffffffff) != ~0xffffffff) - { - NSLog(@"Loss of information converting decoded value to int32_t"); - } - } - return; - case 8: - *(int64_t*)address = big; - return; - default: - [NSException raise: NSInternalInconsistencyException - format: @"type/size information error"]; - } + default: /* A 128-bit value */ + { + gsu128 val; + + (*desImp)(src, desSel, &val, @encode(gsu128), &cursor, nil); +#if GS_HAVE_I128 + bigval = val; +#else + val = GSSwapBigI128ToHost(val); +#if GS_HAVE_I64 + bigval = *(uint64_t*)&val; +#else + bigval = *(uint32_t*)&val; +#endif +#endif + break; + } } - else + +/* + * Now we copy from the 'bigval' to the destination location. + */ + switch (info & _GSC_MASK) { - uint64_t big; - - switch (info & _GSC_SIZE) - { - case _GSC_I16: /* Encoded as 16-bit */ - { - uint16_t val; - - (*desImp)(src, desSel, &val, @encode(uint16_t), &cursor, nil); - big = val; - break; - } - - case _GSC_I32: /* Encoded as 32-bit */ - { - uint32_t val; - - (*desImp)(src, desSel, &val, @encode(uint32_t), &cursor, nil); - big = val; - break; - } - - case _GSC_I64: /* Encoded as 64-bit */ - { - (*desImp)(src, desSel, &big, @encode(uint64_t), &cursor, nil); - break; - } - - default: /* A 128-bit value */ - { - big = 0; - [NSException raise: NSInternalInconsistencyException - format: @"Archiving of 128bit integer not allowed"]; - } - } - /* - * Now we copy from the big value to the destination location. - */ - switch (size) - { - case 1: - if (big & ~0xff) - { - NSLog(@"Loss of information converting decoded value to uint8_t"); - } - *(uint8_t*)address = (uint8_t)big; - return; - case 2: - if (big & ~0xffff) - { - NSLog(@"Loss of information converting decoded value to uint16_t"); - } - *(uint8_t*)address = (uint8_t)big; - *(uint16_t*)address = (uint16_t)big; - return; - case 4: - if (big & ~0xffffffff) - { - NSLog(@"Loss of information converting decoded value to uint32_t"); - } - *(uint32_t*)address = (uint32_t)big; - return; - case 8: - *(uint64_t*)address = big; - return; - default: - [NSException raise: NSInternalInconsistencyException - format: @"type/size information error"]; - } + case _GSC_SHT: + *(short*)address = (short)bigval; + return; + case _GSC_USHT: + *(unsigned short*)address = (unsigned short)bigval; + return; + case _GSC_INT: + *(int*)address = (int)bigval; + return; + case _GSC_UINT: + *(unsigned int*)address = (unsigned int)bigval; + return; + case _GSC_LNG: + *(long*)address = (long)bigval; + return; + case _GSC_ULNG: + *(unsigned long*)address = (unsigned long)bigval; + return; +#ifdef _C_LNG_LNG + case _GSC_LNG_LNG: + *(long long*)address = (long long)bigval; + return; + case _GSC_ULNG_LNG: + *(unsigned long long*)address = (unsigned long long)bigval; + return; +#endif + default: + [NSException raise: NSInternalInconsistencyException + format: @"type/size information error"]; } } -} - (NSData*) decodeDataObject { @@ -1231,12 +1108,14 @@ static Class NSDataMallocClass; { void *b; NSData *d; + NSZone *z; #if GS_WITH_GC - b = NSAllocateCollectable(l, 0); + z = GSAtomicMallocZone(); #else - b = NSZoneMalloc(zone, l); + z = zone; #endif + b = NSZoneMalloc(z, l); [self decodeArrayOfObjCType: @encode(unsigned char) count: l at: b]; @@ -1318,7 +1197,7 @@ static Class NSDataMallocClass; { Class c; - c = objc_lookUpClass([trueName cString]); + c = GSClassFromName([trueName cString]); if (c == 0) { [NSException raise: NSInvalidArgumentException @@ -1370,7 +1249,7 @@ static Class NSDataMallocClass; { Class c; - c = objc_lookUpClass([trueName cString]); + c = GSClassFromName([trueName cString]); if (c == 0) { [NSException raise: NSInvalidArgumentException @@ -1412,14 +1291,14 @@ static Class NSDataMallocClass; format: @"object to be replaced does not exist"]; } -- (NSInteger) versionForClassName: (NSString*)className +- (unsigned) versionForClassName: (NSString*)className { NSUnarchiverObjectInfo *info; info = [objDict objectForKey: className]; if (info == nil) { - return (NSInteger)NSNotFound; + return NSNotFound; } return info->version; } @@ -1465,7 +1344,7 @@ static Class NSDataMallocClass; TEST_RELEASE(data); data = RETAIN(anObject); - c = object_getClass(data); + c = GSObjCClass(data); if (src != self) { src = data; diff --git a/Source/NSUndoManager.m b/Source/NSUndoManager.m index e05db26e2..3b35f154f 100644 --- a/Source/NSUndoManager.m +++ b/Source/NSUndoManager.m @@ -6,7 +6,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -24,16 +24,16 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSUndoManager_IVARS 1 -#import "Foundation/NSArray.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSInvocation.h" -#import "Foundation/NSException.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSUndoManager.h" +#include "config.h" +#include "Foundation/NSObject.h" +#include "Foundation/NSString.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSInvocation.h" +#include "Foundation/NSException.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSUndoManager.h" - /* * Private class for grouping undo/redo actions. */ @@ -155,44 +155,19 @@ * Private category for the method used to handle default grouping */ @interface NSUndoManager (Private) -- (void) _begin; - (void) _loop: (id)arg; @end @implementation NSUndoManager (Private) -/* This method is used to begin undo grouping internally. - * It's necessary to have a different mechanism from the -beginUndoGrouping - * because it seems that in MacOS X a call to -beginUndoGrouping when at the - * top level will actually create two undo groups. - */ -- (void) _begin -{ - PrivateUndoGroup *parent; - - parent = (PrivateUndoGroup*)_group; - _group = [[PrivateUndoGroup alloc] initWithParent: parent]; - if (_group == nil) - { - _group = parent; - [NSException raise: NSInternalInconsistencyException - format: @"beginUndoGrouping failed to greate group"]; - } - else - { - RELEASE(parent); - - if (_isUndoing == NO && _isRedoing == NO) - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUndoManagerDidOpenUndoGroupNotification - object: self]; - } -} - - (void) _loop: (id)arg { - if (_groupsByEvent && _group != nil) + if (_groupsByEvent) { - [self endUndoGrouping]; + if (_group != nil) + { + [self endUndoGrouping]; + } + [self beginUndoGrouping]; } _runLoopGroupingPending = NO; } @@ -215,32 +190,37 @@ /** * Starts a new grouping of undo actions which can be - * atomically undone by an [-undo] invocation.
- * This method posts an NSUndoManagerDidOpenUndoGroupNotification - * upon creating the grouping.
- * It first posts an NSUndoManagerCheckpointNotification - * unless an undo is currently in progress.
- * The order of these notifications is undefined, but the GNUstep - * implementation currently mimics the observed order in MacOS X 10.5 + * atomically undone by an [-undo] invocation. + * This method posts an NSUndoManagerCheckpointNotification + * unless an undo is currently in progress. It posts an + * NSUndoManagerDidOpenUndoGroupNotification upon creating the grouping. */ - (void) beginUndoGrouping { - /* It seems that MacOS X implicitly creates a top-level group if this - * method is called when groupsByEvent is set and there is no existing - * top level group. There is no checkpoint notification posted for the - * implicit group creation. - */ - if (_group == nil && [self groupsByEvent]) - { - [self _begin]; // Start top level group - } + PrivateUndoGroup *parent; - /* Post the checkpoint notification and THEN create the group. - */ - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUndoManagerCheckpointNotification - object: self]; - [self _begin]; // Start a new group + if (_isUndoing == NO) + { + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUndoManagerCheckpointNotification + object: self]; + } + parent = (PrivateUndoGroup*)_group; + _group = [[PrivateUndoGroup alloc] initWithParent: parent]; + if (_group == nil) + { + _group = parent; + [NSException raise: NSInternalInconsistencyException + format: @"beginUndoGrouping failed to greate group"]; + } + else + { + RELEASE(parent); + + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUndoManagerDidOpenUndoGroupNotification + object: self]; + } } /** @@ -349,14 +329,13 @@ [[NSNotificationCenter defaultCenter] postNotificationName: NSUndoManagerCheckpointNotification object: self]; - if (_isUndoing == NO && _isRedoing == NO) - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUndoManagerWillCloseUndoGroupNotification - object: self]; g = (PrivateUndoGroup*)_group; p = RETAIN([g parent]); _group = p; [g orphan]; + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUndoManagerWillCloseUndoGroupNotification + object: self]; if (p == nil) { if (_isUndoing) @@ -442,7 +421,7 @@ { if ([self groupsByEvent]) { - [self _begin]; + [self beginUndoGrouping]; } else { @@ -497,7 +476,7 @@ * groupings which can be nested, not the number of of groups on either * the undo or redo stack. */ -- (NSInteger) groupingLevel +- (int) groupingLevel { PrivateUndoGroup *g = (PrivateUndoGroup*)_group; int level = 0; @@ -573,7 +552,7 @@ * The default value is 0 meaning the number is only limited by * memory availability. */ -- (NSUInteger) levelsOfUndo +- (unsigned int) levelsOfUndo { return _levelsOfUndo; } @@ -636,7 +615,7 @@ _group = nil; _isRedoing = YES; - [self _begin]; + [self beginUndoGrouping]; [groupToRedo perform]; RELEASE(groupToRedo); [self endUndoGrouping]; @@ -685,20 +664,15 @@ */ - (NSString*) redoMenuTitleForUndoActionName: (NSString*)actionName { - /* - * FIXME: The terms @"Redo" and @"Redo %@" should be localized. - * Possibly with the introduction of GSBaseLocalizedString() private - * the the library. - */ if (actionName) { if ([actionName isEqual: @""]) { - return @"Redo"; + return _(@"Redo"); } else { - return [NSString stringWithFormat: @"Redo %@", actionName]; + return [NSString stringWithFormat: @"%@ %@", _(@"Redo"), actionName]; } } return actionName; @@ -741,7 +715,7 @@ { if ([self groupsByEvent]) { - [self _begin]; + [self beginUndoGrouping]; } else { @@ -874,7 +848,7 @@ * When set to 0 the stack size is limited by the range of a unsigned int, * available memory. */ -- (void) setLevelsOfUndo: (NSUInteger)num +- (void) setLevelsOfUndo: (unsigned)num { _levelsOfUndo = num; if (num > 0) @@ -902,18 +876,15 @@ if (_modes != newModes) { ASSIGN(_modes, newModes); - if (_runLoopGroupingPending) - { - NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - [runLoop cancelPerformSelector: @selector(_loop:) - target: self - argument: nil]; - [runLoop performSelector: @selector(_loop:) - target: self - argument: nil - order: NSUndoCloseGroupingRunLoopOrdering - modes: _modes]; - } + [[NSRunLoop currentRunLoop] cancelPerformSelector: @selector(_loop:) + target: self + argument: nil]; + [[NSRunLoop currentRunLoop] performSelector: @selector(_loop:) + target: self + argument: nil + order: NSUndoCloseGroupingRunLoopOrdering + modes: _modes]; + _runLoopGroupingPending = YES; } } @@ -970,20 +941,15 @@ */ - (NSString*) undoMenuTitleForUndoActionName: (NSString*)actionName { - /* - * FIXME: The terms @"Undo" and @"Undo %@" should be localized. - * Possibly with the introduction of GSBaseLocalizedString() private - * the the library. - */ if (actionName) { if ([actionName isEqual: @""]) { - return @"Undo"; + return _(@"Undo"); } else { - return [NSString stringWithFormat: @"Undo %@", actionName]; + return [NSString stringWithFormat: @"%@ %@", _(@"Undo"), actionName]; } } return actionName; @@ -1049,7 +1015,7 @@ name = [NSString stringWithString: [groupToUndo actionName]]; - [self _begin]; + [self beginUndoGrouping]; [groupToUndo perform]; RELEASE(groupToUndo); [self endUndoGrouping]; @@ -1066,39 +1032,3 @@ @end -/* - * Category with auxiliary method to support coalescing undo actions - * for typing events in NSTextView. However, the implementation is - * not restricted to that purpose. - */ -@interface NSUndoManager(UndoCoalescing) -- (BOOL) _canCoalesceUndoWithTarget: (id)target - selector: (SEL)aSelector - object: (id)anObject; -@end - -@implementation NSUndoManager(UndoCoalescing) -- (BOOL) _canCoalesceUndoWithTarget: (id)target - selector: (SEL)aSelector - object: (id)anObject -{ - if (_isUndoing == NO && _isRedoing == NO && [_undoStack count] > 0) - { - int i; - NSArray *a = [[_undoStack lastObject] actions]; - - for (i = 0; i < [a count]; i++) - { - NSInvocation *inv = [a objectAtIndex: i]; - if ([inv target] == target && [inv selector] == aSelector) - { - id object; - [inv getArgument: &object atIndex: 2]; - if (object == anObject) - return YES; - } - } - } - return NO; -} -@end diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index caaa57730..aad59c0d6 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,38 +27,36 @@ $Date$ $Revision$ */ -#import "common.h" -#define EXPOSE_NSUserDefaults_IVARS 1 +#include "config.h" +#include "GNUstepBase/preface.h" #include #include #include -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSArchiver.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDate.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSDistributedLock.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSPropertyList.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSThread.h" -#import "Foundation/NSTimer.h" -#import "Foundation/NSValue.h" -#import "GNUstepBase/GSLocale.h" -#import "GNUstepBase/GSLock.h" -#import "GNUstepBase/NSProcessInfo+GNUstepBase.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GNUstepBase/NSString+GNUstepBase.h" +#include "Foundation/NSUserDefaults.h" +#include "Foundation/NSArchiver.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDate.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSDistributedLock.h" +#include "Foundation/NSException.h" +#include "Foundation/NSFileManager.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSNotification.h" +#include "Foundation/NSPathUtilities.h" +#include "Foundation/NSProcessInfo.h" +#include "Foundation/NSRunLoop.h" +#include "Foundation/NSSet.h" +#include "Foundation/NSThread.h" +#include "Foundation/NSTimer.h" +#include "Foundation/NSUtilities.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSDebug.h" +#include "GNUstepBase/GSLocale.h" +#include "GNUstepBase/GSLock.h" -#if defined(__MINGW__) +#if defined(__MINGW32__) @class NSUserDefaultsWin32; #endif @@ -66,7 +64,7 @@ #include #endif -#import "GSPrivate.h" +#include "GSPrivate.h" /* Wait for access */ #define _MAX_COUNT 5 /* Max 10 sec. */ @@ -137,42 +135,6 @@ static void updateCache(NSUserDefaults *self) } } -static BOOL -writeDictionary(NSDictionary *dict, NSString *file) -{ - if (dict == nil) - { - NSLog(@"Defaults database is nil when writing"); - } - else if ([file length] == 0) - { - NSLog(@"Defaults database filename is empty when writing"); - } - else - { - NSData *data; - NSString *err; - - err = nil; - data = [NSPropertyListSerialization dataFromPropertyList: dict - format: NSPropertyListXMLFormat_v1_0 - errorDescription: &err]; - if (data == nil) - { - NSLog(@"Failed to serialize defaults database for writing: %@", err); - } - else if ([data writeToFile: file atomically: YES] == NO) - { - NSLog(@"Failed to write defaults database to file: %@", file); - } - else - { - return YES; - } - } - return NO; -} - /************************************************************************* *** Local method definitions *************************************************************************/ @@ -236,13 +198,7 @@ writeDictionary(NSDictionary *dict, NSString *file) * Information retrieved from the GNUstep configuration system. * Usually the system wide and user specific GNUstep.conf files, * or from information compiled in when the base library was - * built.
- * In addition to this standard configuration information, this - * domain contains all values from the GlobalDefaults.plist file - * stored in the same directory as the system widw GNUstep.conf - * file. The GlobalDefaults.plist allows packagers and system - * administrators to provide global defaults settings for all - * users of a particular GNUstep installation. + * built. * * NSRegistrationDomain ... volatile * @@ -307,47 +263,32 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ + (void) resetStandardUserDefaults { [classLock lock]; - NS_DURING + if (sharedDefaults != nil) { - if (sharedDefaults != nil) - { - NSDictionary *regDefs; - - /* To ensure that we don't try to synchronise the old defaults to disk - * after creating the new ones, remove as housekeeping notification - * observer. - */ - [[NSNotificationCenter defaultCenter] removeObserver: sharedDefaults]; + NSDictionary *regDefs; - /* Ensure changes are written, and no changes left so we can't end up - * writing old changes to the new defaults. - */ - [sharedDefaults synchronize]; - DESTROY(sharedDefaults->_changedDomains); - - regDefs = RETAIN([sharedDefaults->_tempDomains - objectForKey: NSRegistrationDomain]); - setSharedDefaults = NO; - DESTROY(sharedDefaults); - if (regDefs != nil) + [sharedDefaults synchronize]; // Ensure changes are written. + regDefs = RETAIN([sharedDefaults->_tempDomains + objectForKey: NSRegistrationDomain]); + /* To ensure that we don't try to synchronise the old defaults to disk + * after creating the new ones, remove as housekeeping notification + * observer. + */ + [[NSNotificationCenter defaultCenter] removeObserver: sharedDefaults]; + setSharedDefaults = NO; + DESTROY(sharedDefaults); + if (regDefs != nil) + { + [self standardUserDefaults]; + if (sharedDefaults != nil) { - [self standardUserDefaults]; - if (sharedDefaults != nil) - { - [sharedDefaults->_tempDomains setObject: regDefs - forKey: NSRegistrationDomain]; - } - RELEASE(regDefs); + [sharedDefaults->_tempDomains setObject: regDefs + forKey: NSRegistrationDomain]; } - } - [classLock unlock]; + RELEASE(regDefs); + } } - NS_HANDLER - { - [classLock unlock]; - [localException raise]; - } - NS_ENDHANDLER + [classLock unlock]; } /* Create a locale dictionary when we have absolutely no information @@ -488,17 +429,6 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ * +userLanguages uses this to rebuild language information and return it. */ - /* Return the sharedDefaults without locking in the simple case. - * We need to lock and check again before CREATING sharedDefaults if it doesn't exist, - * so that two threads can't create it at once (or call resetStandardUserDefaults at - * the same time). - * By not locking here, we avoid a deadlock that can occur between classLock and _lock. */ - if (setSharedDefaults == YES) - { - IF_NO_GC([sharedDefaults retain];) - return AUTORELEASE(sharedDefaults); - } - [classLock lock]; /* @@ -508,201 +438,194 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ */ if (setSharedDefaults == YES) { - IF_NO_GC([sharedDefaults retain];) + RETAIN(sharedDefaults); [classLock unlock]; return AUTORELEASE(sharedDefaults); } setSharedDefaults = YES; - NS_DURING - { - // Create new sharedDefaults (NOTE: Not added to the autorelease pool!) -#if defined(__MINGW__) + // Create new sharedDefaults (NOTE: Not added to the autorelease pool!) +#if defined(__MINGW32__) + { + NSString *path = GSDefaultsRootForUser(NSUserName()); + NSRange r = [path rangeOfString: @":REGISTRY:"]; + + if (r.length > 0) { - NSString *path = GSDefaultsRootForUser(NSUserName()); - NSRange r = [path rangeOfString: @":REGISTRY:"]; - - if (r.length > 0) - { - sharedDefaults = [[NSUserDefaultsWin32 alloc] init]; - } - else - { - sharedDefaults = [[self alloc] init]; - } + sharedDefaults = [[NSUserDefaultsWin32 alloc] init]; } -#else - sharedDefaults = [[self alloc] init]; -#endif - if (sharedDefaults == nil) - { - NSLog(@"WARNING - unable to create shared user defaults!\n"); - [classLock unlock]; - NS_VALRETURN(nil); - } - - /* - * Set up search list (excluding language list, which we don't know yet) - */ - [sharedDefaults->_searchList addObject: NSArgumentDomain]; - [sharedDefaults->_searchList addObject: processName]; - [sharedDefaults->_searchList addObject: NSGlobalDomain]; - [sharedDefaults->_searchList addObject: GSConfigDomain]; - [sharedDefaults->_searchList addObject: NSRegistrationDomain]; - - /* - * Look up user languages list and insert language specific domains - * into search list before NSRegistrationDomain - */ - uL = [self userLanguages]; - enumerator = [uL objectEnumerator]; - while ((lang = [enumerator nextObject])) - { - unsigned index = [sharedDefaults->_searchList count] - 1; - - [sharedDefaults->_searchList insertObject: lang atIndex: index]; - } - - /* Set up language constants */ - - /* We lookup gnustep-base resources manually here to prevent - * bootstrap problems. NSBundle's lookup routines depend on having - * NSUserDefaults already bootstrapped, but we're still - * bootstrapping here! So we can't really use NSBundle without - * incurring massive bootstrap complications (btw, most of the times - * we're here as a consequence of [NSBundle +initialize] creating - * the gnustep-base bundle! So trying to use the gnustep-base - * bundle here wouldn't really work.). - */ - /* - * We are looking for: - * - * GNUSTEP_LIBRARY/Libraries/gnustep-base/Versions//Resources/Languages/ - * - * We iterate over , and for each we iterate over GNUSTEP_LIBRARY. - */ - + else { - /* These variables are reused for all languages so we set them up - * once here and then reuse them. - */ - NSFileManager *fm = [NSFileManager defaultManager]; - NSString *tail = [[[[[@"Libraries" - stringByAppendingPathComponent: @"gnustep-base"] - stringByAppendingPathComponent: @"Versions"] - stringByAppendingPathComponent: - OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)] - stringByAppendingPathComponent: @"Resources"] - stringByAppendingPathComponent: @"Languages"]; - NSArray *paths = NSSearchPathForDirectoriesInDomains - (NSLibraryDirectory, NSAllDomainsMask, YES); - - added_lang = NO; - added_locale = NO; - enumerator = [uL objectEnumerator]; - while ((lang = [enumerator nextObject])) - { - NSDictionary *dict = nil; - NSString *path = nil; - NSEnumerator *pathEnumerator = [paths objectEnumerator]; + sharedDefaults = [[self alloc] init]; + } + } +#else + sharedDefaults = [[self alloc] init]; +#endif + if (sharedDefaults == nil) + { + NSLog(@"WARNING - unable to create shared user defaults!\n"); + [classLock unlock]; + return nil; + } - while ((path = [pathEnumerator nextObject]) != nil) + /* + * Set up search list (excluding language list, which we don't know yet) + */ + [sharedDefaults->_searchList addObject: NSArgumentDomain]; + [sharedDefaults->_searchList addObject: processName]; + [sharedDefaults->_searchList addObject: NSGlobalDomain]; + [sharedDefaults->_searchList addObject: GSConfigDomain]; + [sharedDefaults->_searchList addObject: NSRegistrationDomain]; + + /* + * Look up user languages list and insert language specific domains + * into search list before NSRegistrationDomain + */ + uL = [self userLanguages]; + enumerator = [uL objectEnumerator]; + while ((lang = [enumerator nextObject])) + { + unsigned index = [sharedDefaults->_searchList count] - 1; + + [sharedDefaults->_searchList insertObject: lang atIndex: index]; + } + + /* Set up language constants */ + + /* We lookup gnustep-base resources manually here to prevent + * bootstrap problems. NSBundle's lookup routines depend on having + * NSUserDefaults already bootstrapped, but we're still + * bootstrapping here! So we can't really use NSBundle without + * incurring massive bootstrap complications (btw, most of the times + * we're here as a consequence of [NSBundle +initialize] creating + * the gnustep-base bundle! So trying to use the gnustep-base + * bundle here wouldn't really work.). + */ + /* + * We are looking for: + * + * GNUSTEP_LIBRARY/Libraries/gnustep-base/Versions//Resources/Languages/ + * + * We iterate over , and for each we iterate over GNUSTEP_LIBRARY. + */ + + { + /* These variables are reused for all languages so we set them up + * once here and then reuse them. + */ + NSFileManager *fm = [NSFileManager defaultManager]; + NSString *tail = [[[[[@"Libraries" + stringByAppendingPathComponent: @"gnustep-base"] + stringByAppendingPathComponent: @"Versions"] + stringByAppendingPathComponent: + OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)] + stringByAppendingPathComponent: @"Resources"] + stringByAppendingPathComponent: @"Languages"]; + NSArray *paths = NSSearchPathForDirectoriesInDomains (NSLibraryDirectory, + NSAllDomainsMask, YES); + + added_lang = NO; + added_locale = NO; + enumerator = [uL objectEnumerator]; + while ((lang = [enumerator nextObject])) + { + NSDictionary *dict = nil; + NSString *path = nil; + NSEnumerator *pathEnumerator = [paths objectEnumerator]; + + while ((path = [pathEnumerator nextObject]) != nil) + { + path = [[path stringByAppendingPathComponent: tail] + stringByAppendingPathComponent: lang]; + + if ([fm fileExistsAtPath: path]) { - path = [[path stringByAppendingPathComponent: tail] - stringByAppendingPathComponent: lang]; - - if ([fm fileExistsAtPath: path]) - { - /* Path found! */ - break; - } + /* Path found! */ + break; } + } + + if (path != nil) + { + dict = [NSDictionary dictionaryWithContentsOfFile: path]; + } + if (dict != nil) + { + [sharedDefaults setVolatileDomain: dict forName: lang]; + added_lang = YES; + } + else if (added_locale == NO) + { + /* The resources for the language that we were looking for + * were not found. If this was the currently set locale + * in the C library, try to get the same information from + * the C library. This would usually happen for the + * language that was added to the list of languages + * precisely because it is the currently set locale in the + * C library. + */ + NSString *locale = nil; - if (path != nil) - { - dict = [NSDictionary dictionaryWithContentsOfFile: path]; - } - if (dict != nil) - { - [sharedDefaults setVolatileDomain: dict forName: lang]; - added_lang = YES; - } - else if (added_locale == NO) - { - /* The resources for the language that we were looking for - * were not found. If this was the currently set locale - * in the C library, try to get the same information from - * the C library. This would usually happen for the - * language that was added to the list of languages - * precisely because it is the currently set locale in the - * C library. - */ - NSString *locale = nil; - #ifdef HAVE_LOCALE_H #ifdef LC_MESSAGES - locale = GSSetLocale(LC_MESSAGES, nil); + locale = GSSetLocale(LC_MESSAGES, nil); #endif #endif - if (locale != nil) - { - /* See if we can get the dictionary from i18n - * functions. I don't think that the i18n routines - * can handle more than one locale, so we don't try to - * look 'lang' up but just get what we get and use it - * if it matches 'lang' ... but tell me if I'm wrong - * ... + if (locale != nil) + { + /* See if we can get the dictionary from i18n + * functions. I don't think that the i18n routines + * can handle more than one locale, so we don't try to + * look 'lang' up but just get what we get and use it + * if it matches 'lang' ... but tell me if I'm wrong + * ... + */ + if ([lang isEqualToString: GSLanguageFromLocale (locale)]) + { + /* We set added_locale to YES to avoid so that we + * won't do this C library locale lookup again + * later on. */ - if ([lang isEqualToString: GSLanguageFromLocale (locale)]) + added_locale = YES; + + dict = GSDomainFromDefaultLocale (); + if (dict != nil) { - /* We set added_locale to YES to avoid so that we - * won't do this C library locale lookup again - * later on. - */ - added_locale = YES; - - dict = GSDomainFromDefaultLocale (); - if (dict != nil) - { - [sharedDefaults setVolatileDomain: dict - forName: lang]; + [sharedDefaults setVolatileDomain: dict forName: lang]; - /* We do not set added_lang to YES here - * because we want the basic hardcoded defaults - * to be used in that case. - */ - } + /* We do not set added_lang to YES here + * because we want the improper installation + * warning to be printed below if our own + * English language dictionary is not found, + * and we want the basic hardcoded defaults to + * be used in that case. (FIXME: Review this + * decision). + */ } - } + } } - } + } } - - if (added_lang == NO) - { - /* No language information found ... probably because the base - * library is being used 'standalone' without resources. - * We need to use hard-coded defaults. - */ - /* FIXME - should we set this as volatile domain for English ? */ - [sharedDefaults registerDefaults: [self _unlocalizedDefaults]]; - } - IF_NO_GC([sharedDefaults retain];) - updateCache(sharedDefaults); - [classLock unlock]; - } - NS_HANDLER + } + + if (added_lang == NO) { - [classLock unlock]; - [localException raise]; + /* Ack! We should never get here. */ + NSWarnMLog(@"Improper installation: No language locale found"); + + /* FIXME - should we set this as volatile domain for English ? */ + [sharedDefaults registerDefaults: [self _unlocalizedDefaults]]; } - NS_ENDHANDLER + RETAIN(sharedDefaults); + updateCache(sharedDefaults); + [classLock unlock]; return AUTORELEASE(sharedDefaults); } + (NSArray*) userLanguages { - NSArray *result = nil; + NSArray *result; /* * Calling +standardUserDefaults and +userLanguages is horribly interrelated. @@ -730,93 +653,84 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ */ [classLock lock]; - NS_DURING + if (invalidatedLanguages == YES) { - if (invalidatedLanguages == YES) - { - invalidatedLanguages = NO; - DESTROY(userLanguages); - } - if (userLanguages == nil) - { - NSArray *currLang = nil; - NSString *locale = nil; + invalidatedLanguages = NO; + DESTROY(userLanguages); + } + if (userLanguages == nil) + { + NSArray *currLang = nil; + NSString *locale = nil; #ifdef HAVE_LOCALE_H #ifdef LC_MESSAGES - locale = GSSetLocale(LC_MESSAGES, nil); + locale = GSSetLocale(LC_MESSAGES, nil); #endif #endif - currLang = [[NSUserDefaults standardUserDefaults] - stringArrayForKey: @"NSLanguages"]; + currLang = [[NSUserDefaults standardUserDefaults] + stringArrayForKey: @"NSLanguages"]; - userLanguages = [[NSMutableArray alloc] initWithCapacity: 5]; + userLanguages = [[NSMutableArray alloc] initWithCapacity: 5]; - if (currLang == nil && locale != nil && GSLanguageFromLocale(locale)) - { - currLang = [NSArray arrayWithObject: GSLanguageFromLocale(locale)]; - } -#ifdef __MINGW__ - if (currLang == nil && locale != nil) - { - /* Check for language as the first part of the locale string */ - NSRange under = [locale rangeOfString: @"_"]; - if (under.location) - currLang = [NSArray arrayWithObject: - [locale substringToIndex: under.location]]; - } + if (currLang == nil && locale != nil && GSLanguageFromLocale(locale)) + { + currLang = [NSArray arrayWithObject: GSLanguageFromLocale(locale)]; + } +#ifdef __MINGW32__ + if (currLang == nil && locale != nil) + { + /* Check for language as the first part of the locale string */ + NSRange under = [locale rangeOfString: @"_"]; + if (under.location) + currLang = [NSArray arrayWithObject: + [locale substringToIndex: under.location]]; + } #endif - if (currLang == nil) + if (currLang == nil) + { + NSString *env; + + env = [[[NSProcessInfo processInfo] environment] + objectForKey: @"LANGUAGES"]; + if (env != nil) { - NSString *env; - - env = [[[NSProcessInfo processInfo] environment] - objectForKey: @"LANGUAGES"]; - if (env != nil) - { - currLang = [env componentsSeparatedByString: @";"]; - } + currLang = [env componentsSeparatedByString: @";"]; } + } - if (currLang != nil) + if (currLang != nil) + { + NSMutableArray *a = [currLang mutableCopy]; + unsigned c = [a count]; + + while (c-- > 0) { - NSMutableArray *a = [currLang mutableCopy]; - unsigned c = [a count]; + NSString *s = [[a objectAtIndex: c] stringByTrimmingSpaces]; - while (c-- > 0) - { - NSString *s = [[a objectAtIndex: c] stringByTrimmingSpaces]; - - if ([s length] == 0) - { - [a removeObjectAtIndex: c]; - } - else - { - [a replaceObjectAtIndex: c withObject: s]; - } - } - [userLanguages addObjectsFromArray: a]; - RELEASE(a); + if ([s length] == 0) + { + [a removeObjectAtIndex: c]; + } + else + { + [a replaceObjectAtIndex: c withObject: s]; + } } + [userLanguages addObjectsFromArray: a]; + RELEASE(a); + } - /* Check if "English" is included. We do this to make sure all the - required language constants are set somewhere if they aren't set - in the default language */ - if ([userLanguages containsObject: @"English"] == NO) - { - [userLanguages addObject: @"English"]; - } - } - result = RETAIN(userLanguages); - [classLock unlock]; + /* Check if "English" is included. We do this to make sure all the + required language constants are set somewhere if they aren't set + in the default language */ + if ([userLanguages containsObject: @"English"] == NO) + { + [userLanguages addObject: @"English"]; + } } - NS_HANDLER - { - [classLock unlock]; - [localException raise]; - } - NS_ENDHANDLER + result = RETAIN(userLanguages); + [classLock unlock]; return AUTORELEASE(result); } @@ -875,7 +789,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ } r = [path rangeOfString: @":INTERNAL:"]; -#if defined(__MINGW__) +#if defined(__MINGW32__) if (r.length == 0) { r = [path rangeOfString: @":REGISTRY:"]; @@ -975,23 +889,14 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ - (NSString*) description { - NSMutableString *desc = nil; + NSMutableString *desc; [_lock lock]; - NS_DURING - { - desc = [NSMutableString stringWithFormat: @"%@", [super description]]; - [desc appendFormat: @" SearchList: %@", _searchList]; - [desc appendFormat: @" Persistant: %@", _persDomains]; - [desc appendFormat: @" Temporary: %@", _tempDomains]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + desc = [NSMutableString stringWithFormat: @"%@", [super description]]; + [desc appendFormat: @" SearchList: %@", _searchList]; + [desc appendFormat: @" Persistant: %@", _persDomains]; + [desc appendFormat: @" Temporary: %@", _tempDomains]; + [_lock unlock]; return desc; } @@ -1005,23 +910,14 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ format: @"attempt to add suite with nil name"]; } [_lock lock]; - NS_DURING - { - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - [_searchList removeObject: aName]; - index = [_searchList indexOfObject: processName]; - index = (index == NSNotFound) ? 0 : (index + 1); - aName = [aName copy]; - [_searchList insertObject: aName atIndex: index]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + [_searchList removeObject: aName]; + index = [_searchList indexOfObject: processName]; + index++; // NSNotFound wraps to zero ... insert at start. + aName = [aName copy]; + [_searchList insertObject: aName atIndex: index]; + [_lock unlock]; RELEASE(aName); } @@ -1078,14 +974,14 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ return 0.0; } -- (NSInteger) integerForKey: (NSString*)defaultName +- (int) integerForKey: (NSString*)defaultName { id obj = [self objectForKey: defaultName]; if (obj != nil && ([obj isKindOfClass: NSStringClass] || [obj isKindOfClass: NSNumberClass])) { - return [obj integerValue]; + return [obj intValue]; } return 0; } @@ -1094,40 +990,31 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ { NSEnumerator *enumerator; IMP nImp; - id object = nil; + id object; id dN; IMP pImp; IMP tImp; [_lock lock]; - NS_DURING - { - enumerator = [_searchList objectEnumerator]; - nImp = [enumerator methodForSelector: nextObjectSel]; - object = nil; - pImp = [_persDomains methodForSelector: objectForKeySel]; - tImp = [_tempDomains methodForSelector: objectForKeySel]; + enumerator = [_searchList objectEnumerator]; + nImp = [enumerator methodForSelector: nextObjectSel]; + object = nil; + pImp = [_persDomains methodForSelector: objectForKeySel]; + tImp = [_tempDomains methodForSelector: objectForKeySel]; - while ((dN = (*nImp)(enumerator, nextObjectSel)) != nil) - { - NSDictionary *dict; - - dict = (*pImp)(_persDomains, objectForKeySel, dN); - if (dict != nil && (object = [dict objectForKey: defaultName])) - break; - dict = (*tImp)(_tempDomains, objectForKeySel, dN); - if (dict != nil && (object = [dict objectForKey: defaultName])) - break; - } - IF_NO_GC([object retain];) - [_lock unlock]; - } - NS_HANDLER + while ((dN = (*nImp)(enumerator, nextObjectSel)) != nil) { - [_lock unlock]; - [localException raise]; + NSDictionary *dict; + + dict = (*pImp)(_persDomains, objectForKeySel, dN); + if (dict != nil && (object = [dict objectForKey: defaultName])) + break; + dict = (*tImp)(_tempDomains, objectForKeySel, dN); + if (dict != nil && (object = [dict objectForKey: defaultName])) + break; } - NS_ENDHANDLER + RETAIN(object); + [_lock unlock]; return AUTORELEASE(object); } @@ -1136,47 +1023,33 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ id obj; [_lock lock]; - NS_DURING + obj = [_persDomains objectForKey: processName]; + obj = [(NSDictionary*)obj objectForKey: defaultName]; + if (obj != nil) { - obj = [_persDomains objectForKey: processName]; - obj = [(NSDictionary*)obj objectForKey: defaultName]; - if (obj != nil) - { - NSMutableDictionary *dict; - id obj = [_persDomains objectForKey: processName]; + NSMutableDictionary *dict; + id obj = [_persDomains objectForKey: processName]; - if ([obj isKindOfClass: NSMutableDictionaryClass] == YES) - { - dict = obj; - } - else - { - dict = [obj mutableCopy]; - [_persDomains setObject: dict forKey: processName]; - } - [dict removeObjectForKey: defaultName]; - [self __changePersistentDomain: processName]; - } - [_lock unlock]; + if ([obj isKindOfClass: NSMutableDictionaryClass] == YES) + { + dict = obj; + } + else + { + dict = [obj mutableCopy]; + [_persDomains setObject: dict forKey: processName]; + } + [dict removeObjectForKey: defaultName]; + [self __changePersistentDomain: processName]; } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + [_lock unlock]; } - (void) setBool: (BOOL)value forKey: (NSString*)defaultName { - if (value == YES) - { - [self setObject: @"YES" forKey: defaultName]; - } - else - { - [self setObject: @"NO" forKey: defaultName]; - } + NSNumber *n = [NSNumberClass numberWithBool: value]; + + [self setObject: n forKey: defaultName]; } - (void) setFloat: (float)value forKey: (NSString*)defaultName @@ -1186,9 +1059,9 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ [self setObject: n forKey: defaultName]; } -- (void) setInteger: (NSInteger)value forKey: (NSString*)defaultName +- (void) setInteger: (int)value forKey: (NSString*)defaultName { - NSNumber *n = [NSNumberClass numberWithInteger: value]; + NSNumber *n = [NSNumberClass numberWithInt: value]; [self setObject: n forKey: defaultName]; } @@ -1269,37 +1142,21 @@ static BOOL isPlistObject(id o) value, defaultName]; } - value = [value copy]; [_lock lock]; - NS_DURING + obj = [_persDomains objectForKey: processName]; + if ([obj isKindOfClass: NSMutableDictionaryClass] == YES) { - obj = [_persDomains objectForKey: processName]; - if ([obj isKindOfClass: NSMutableDictionaryClass] == YES) - { - dict = obj; - } - else - { - dict = [obj mutableCopy]; - [_persDomains setObject: dict forKey: processName]; - RELEASE(dict); - } - [dict setObject: value forKey: defaultName]; - [self __changePersistentDomain: processName]; - [_lock unlock]; + dict = obj; } - NS_HANDLER + else { - [_lock unlock]; - [localException raise]; + dict = [obj mutableCopy]; + [_persDomains setObject: dict forKey: processName]; + RELEASE(dict); } - NS_ENDHANDLER - RELEASE(value); -} - -- (void) setValue: (id)value forKey: (NSString*)defaultName -{ - [self setObject: value forKey: (NSString*)defaultName]; + [dict setObject: value forKey: defaultName]; + [self __changePersistentDomain: processName]; + [_lock unlock]; } - (NSArray*) stringArrayForKey: (NSString*)defaultName @@ -1334,98 +1191,53 @@ static BOOL isPlistObject(id o) - (NSArray*) searchList { - NSArray *copy = nil; + NSArray *copy; [_lock lock]; - NS_DURING - { - copy = [_searchList copy]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + copy = [_searchList copy]; + [_lock unlock]; return AUTORELEASE(copy); } - (void) setSearchList: (NSArray*)newList { [_lock lock]; - NS_DURING - { - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - RELEASE(_searchList); - _searchList = [newList mutableCopy]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + RELEASE(_searchList); + _searchList = [newList mutableCopy]; + [_lock unlock]; } - (NSDictionary*) persistentDomainForName: (NSString*)domainName { - NSDictionary *copy = nil; + NSDictionary *copy; [_lock lock]; - NS_DURING - { - copy = [[_persDomains objectForKey: domainName] copy]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + copy = [[_persDomains objectForKey: domainName] copy]; + [_lock unlock]; return AUTORELEASE(copy); } - (NSArray*) persistentDomainNames { - NSArray *keys = nil; + NSArray *keys; [_lock lock]; - NS_DURING - { - keys = [_persDomains allKeys]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + keys = [_persDomains allKeys]; + [_lock unlock]; return keys; } - (void) removePersistentDomainForName: (NSString*)domainName { [_lock lock]; - NS_DURING + if ([_persDomains objectForKey: domainName]) { - if ([_persDomains objectForKey: domainName]) - { - [_persDomains removeObjectForKey: domainName]; - [self __changePersistentDomain: domainName]; - } - [_lock unlock]; + [_persDomains removeObjectForKey: domainName]; + [self __changePersistentDomain: domainName]; } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + [_lock unlock]; } - (void) setPersistentDomain: (NSDictionary*)domain @@ -1434,31 +1246,18 @@ static BOOL isPlistObject(id o) NSDictionary *dict; [_lock lock]; - NS_DURING - { - dict = [_tempDomains objectForKey: domainName]; - if (dict != nil) - { - [NSException raise: NSInvalidArgumentException - format: @"a volatile domain called %@ exists", domainName]; - } - domain = [domain mutableCopy]; - [_persDomains setObject: domain forKey: domainName]; - RELEASE(domain); - [self __changePersistentDomain: domainName]; - [_lock unlock]; - } - NS_HANDLER + dict = [_tempDomains objectForKey: domainName]; + if (dict != nil) { [_lock unlock]; - [localException raise]; + [NSException raise: NSInvalidArgumentException + format: @"a volatile domain called %@ exists", domainName]; } - NS_ENDHANDLER -} - -- (id) valueForKey: (NSString*)aKey -{ - return [self objectForKey: aKey]; + domain = [domain mutableCopy]; + [_persDomains setObject: domain forKey: domainName]; + RELEASE(domain); + [self __changePersistentDomain: domainName]; + [_lock unlock]; } - (BOOL) wantToReadDefaultsSince: (NSDate*)lastSyncDate @@ -1604,17 +1403,16 @@ static BOOL isLocked = NO; uint32_t attributes; /* - * If the lock did not exist ... make sure the database exists. + * If the lock did not exist ... make sure the databsase exists. */ if ([mgr isReadableFileAtPath: _defaultsDatabase] == NO) { NSDictionary *empty = [NSDictionary new]; -NSLog(@"Creating empty user defaults database"); /* * Create empty database. */ - if (writeDictionary(empty, _defaultsDatabase) == NO) + if ([empty writeToFile: _defaultsDatabase atomically: NO] == NO) { NSLog(@"Failed to create defaults database file %@", _defaultsDatabase); @@ -1654,17 +1452,7 @@ NSLog(@"Creating empty user defaults database"); - (void) unlockDefaultsFile { - NS_DURING - { - [_fileLock unlock]; - } - NS_HANDLER - { - NSLog(@"Warning ... someone broke our lock (%@) ... and may have" - @" interfered with updating defaults data in file.", - [_defaultsDatabase stringByAppendingPathExtension: @"lck"]); - } - NS_ENDHANDLER + [_fileLock unlock]; isLocked = NO; } @@ -1696,7 +1484,10 @@ NSLog(@"Creating empty user defaults database"); // Save the changes if we have an external database file if (_fileLock != nil) { - return writeDictionary(defaults, _defaultsDatabase); + if ([defaults writeToFile: _defaultsDatabase atomically: YES] == NO) + { + return NO; + } } return YES; } @@ -1707,103 +1498,95 @@ NSLog(@"Creating empty user defaults database"); BOOL wasLocked; [_lock lock]; - NS_DURING - { - /* - * If we haven't changed anything, we only need to synchronise if - * the on-disk database has been changed by someone else. - */ - - if (_changedDomains == nil) - { - if ([self wantToReadDefaultsSince: _lastSync] == NO) - { - [_lock unlock]; - NS_VALRETURN(YES); - } - } - DESTROY(_dictionaryRep); - if (self == sharedDefaults) - { - invalidatedLanguages = YES; - } - - if ([self lockDefaultsFile: &wasLocked] == NO) - { - [_lock unlock]; - NS_VALRETURN(NO); - } + /* + * If we haven't changed anything, we only need to synchronise if + * the on-disk database has been changed by someone else. + */ + + if (_changedDomains == nil) + { + if ([self wantToReadDefaultsSince: _lastSync] == NO) + { + [_lock unlock]; + return YES; + } + } + + DESTROY(_dictionaryRep); + if (self == sharedDefaults) + { + invalidatedLanguages = YES; + } - newDict = [self readDefaults]; + if ([self lockDefaultsFile: &wasLocked] == NO) + { + [_lock unlock]; + return NO; + } - if (newDict == nil) - { - if (wasLocked == NO) + newDict = [self readDefaults]; + + if (newDict == nil) + { + if (wasLocked == NO) + { + [self unlockDefaultsFile]; + } + [_lock unlock]; + return NO; + } + + if (_changedDomains != nil) + { // Synchronize both dictionaries + NSEnumerator *enumerator = [_changedDomains objectEnumerator]; + NSString *domainName; + NSDictionary *domain; + NSDictionary *oldData = AUTORELEASE([newDict copy]); + + DESTROY(_changedDomains); // Retained by enumerator. + while ((domainName = [enumerator nextObject]) != nil) + { + domain = [_persDomains objectForKey: domainName]; + if (domain != nil) // Domain was added or changed + { + [newDict setObject: domain forKey: domainName]; + } + else // Domain was removed + { + [newDict removeObjectForKey: domainName]; + } + } + ASSIGN(_persDomains, newDict); + if ([self writeDefaults: _persDomains oldData: oldData] == NO) + { + if (wasLocked == NO) { [self unlockDefaultsFile]; } - [_lock unlock]; - NS_VALRETURN(NO); - } - - if (_changedDomains != nil) - { // Synchronize both dictionaries - NSEnumerator *enumerator = [_changedDomains objectEnumerator]; - NSString *domainName; - NSDictionary *domain; - NSDictionary *oldData = AUTORELEASE([newDict copy]); - - DESTROY(_changedDomains); // Retained by enumerator. - while ((domainName = [enumerator nextObject]) != nil) - { - domain = [_persDomains objectForKey: domainName]; - if (domain != nil) // Domain was added or changed - { - [newDict setObject: domain forKey: domainName]; - } - else // Domain was removed - { - [newDict removeObjectForKey: domainName]; - } - } - ASSIGN(_persDomains, newDict); - if ([self writeDefaults: _persDomains oldData: oldData] == NO) - { - if (wasLocked == NO) - { - [self unlockDefaultsFile]; - } - [_lock unlock]; - NS_VALRETURN(NO); - } - ASSIGN(_lastSync, [NSDateClass date]); - } - else - { - ASSIGN(_lastSync, [NSDateClass date]); - if ([_persDomains isEqual: newDict] == NO) - { - ASSIGN(_persDomains, newDict); - updateCache(self); - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUserDefaultsDidChangeNotification - object: self]; - } - } - - if (wasLocked == NO) - { - [self unlockDefaultsFile]; - } - [_lock unlock]; + [_lock unlock]; + return NO; + } + ASSIGN(_lastSync, [NSDateClass date]); } - NS_HANDLER + else { - [_lock unlock]; - [localException raise]; + ASSIGN(_lastSync, [NSDateClass date]); + if ([_persDomains isEqual: newDict] == NO) + { + ASSIGN(_persDomains, newDict); + updateCache(self); + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUserDefaultsDidChangeNotification + object: self]; + } } - NS_ENDHANDLER + + if (wasLocked == NO) + { + [self unlockDefaultsFile]; + } + [_lock unlock]; return YES; } @@ -1811,19 +1594,10 @@ NSLog(@"Creating empty user defaults database"); - (void) removeVolatileDomainForName: (NSString*)domainName { [_lock lock]; - NS_DURING - { - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - [_tempDomains removeObjectForKey: domainName]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + [_tempDomains removeObjectForKey: domainName]; + [_lock unlock]; } - (void) setVolatileDomain: (NSDictionary*)domain @@ -1832,121 +1606,86 @@ NSLog(@"Creating empty user defaults database"); id dict; [_lock lock]; - NS_DURING + dict = [_persDomains objectForKey: domainName]; + if (dict != nil) { - dict = [_persDomains objectForKey: domainName]; - if (dict != nil) - { - [NSException raise: NSInvalidArgumentException - format: @"a persistent domain called %@ exists", domainName]; - } - dict = [_tempDomains objectForKey: domainName]; - if (dict != nil) - { - [NSException raise: NSInvalidArgumentException - format: @"the volatile domain %@ already exists", domainName]; - } + [_lock unlock]; + [NSException raise: NSInvalidArgumentException + format: @"a persistent domain called %@ exists", domainName]; + } + dict = [_tempDomains objectForKey: domainName]; + if (dict != nil) + { + [_lock unlock]; + [NSException raise: NSInvalidArgumentException + format: @"the volatile domain %@ already exists", domainName]; + } - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - domain = [domain mutableCopy]; - [_tempDomains setObject: domain forKey: domainName]; - RELEASE(domain); - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + domain = [domain mutableCopy]; + [_tempDomains setObject: domain forKey: domainName]; + RELEASE(domain); + [_lock unlock]; } - (NSDictionary*) volatileDomainForName: (NSString*)domainName { - NSDictionary *copy = nil; + NSDictionary *copy; [_lock lock]; - NS_DURING - { - copy = [[_tempDomains objectForKey: domainName] copy]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + copy = [[_tempDomains objectForKey: domainName] copy]; + [_lock unlock]; return AUTORELEASE(copy); } - (NSArray*) volatileDomainNames { - NSArray *keys = nil; + NSArray *keys; [_lock lock]; - NS_DURING - { - keys = [_tempDomains allKeys]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + keys = [_tempDomains allKeys]; + [_lock unlock]; return keys; } - (NSDictionary*) dictionaryRepresentation { - NSDictionary *rep = nil; + NSDictionary *rep; [_lock lock]; - NS_DURING + if (_dictionaryRep == nil) { - if (_dictionaryRep == nil) - { - NSEnumerator *enumerator; - NSMutableDictionary *dictRep; - id obj; - id dict; - IMP nImp; - IMP pImp; - IMP tImp; - IMP addImp; + NSEnumerator *enumerator; + NSMutableDictionary *dictRep; + id obj; + id dict; + IMP nImp; + IMP pImp; + IMP tImp; + IMP addImp; - pImp = [_persDomains methodForSelector: objectForKeySel]; - tImp = [_tempDomains methodForSelector: objectForKeySel]; + pImp = [_persDomains methodForSelector: objectForKeySel]; + tImp = [_tempDomains methodForSelector: objectForKeySel]; - enumerator = [_searchList reverseObjectEnumerator]; - nImp = [enumerator methodForSelector: nextObjectSel]; + enumerator = [_searchList reverseObjectEnumerator]; + nImp = [enumerator methodForSelector: nextObjectSel]; - dictRep = [NSMutableDictionaryClass allocWithZone: NSDefaultMallocZone()]; - dictRep = [dictRep initWithCapacity: 512]; - addImp = [dictRep methodForSelector: addSel]; + dictRep = [NSMutableDictionaryClass allocWithZone: NSDefaultMallocZone()]; + dictRep = [dictRep initWithCapacity: 512]; + addImp = [dictRep methodForSelector: addSel]; - while ((obj = (*nImp)(enumerator, nextObjectSel)) != nil) - { - if ((dict = (*pImp)(_persDomains, objectForKeySel, obj)) != nil - || (dict = (*tImp)(_tempDomains, objectForKeySel, obj)) != nil) - { - (*addImp)(dictRep, addSel, dict); - } - } - _dictionaryRep = [dictRep makeImmutableCopyOnFail: NO]; - } - rep = RETAIN(_dictionaryRep); - [_lock unlock]; + while ((obj = (*nImp)(enumerator, nextObjectSel)) != nil) + { + if ((dict = (*pImp)(_persDomains, objectForKeySel, obj)) != nil + || (dict = (*tImp)(_tempDomains, objectForKeySel, obj)) != nil) + (*addImp)(dictRep, addSel, dict); + } + _dictionaryRep = [dictRep copy]; + RELEASE(dictRep); } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + rep = RETAIN(_dictionaryRep); + [_lock unlock]; return AUTORELEASE(rep); } @@ -1955,26 +1694,17 @@ NSLog(@"Creating empty user defaults database"); NSMutableDictionary *regDefs; [_lock lock]; - NS_DURING + regDefs = [_tempDomains objectForKey: NSRegistrationDomain]; + if (regDefs == nil) { - regDefs = [_tempDomains objectForKey: NSRegistrationDomain]; - if (regDefs == nil) - { - regDefs = [NSMutableDictionaryClass - dictionaryWithCapacity: [newVals count]]; - [_tempDomains setObject: regDefs forKey: NSRegistrationDomain]; - } - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - [regDefs addEntriesFromDictionary: newVals]; - [_lock unlock]; + regDefs = [NSMutableDictionaryClass + dictionaryWithCapacity: [newVals count]]; + [_tempDomains setObject: regDefs forKey: NSRegistrationDomain]; } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + [regDefs addEntriesFromDictionary: newVals]; + [_lock unlock]; } - (void) removeSuiteNamed: (NSString*)aName @@ -1985,19 +1715,10 @@ NSLog(@"Creating empty user defaults database"); format: @"attempt to remove suite with nil name"]; } [_lock lock]; - NS_DURING - { - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - [_searchList removeObject: aName]; - [_lock unlock]; - } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + [_searchList removeObject: aName]; + [_lock unlock]; } /************************************************************************* @@ -2008,128 +1729,110 @@ NSLog(@"Creating empty user defaults database"); { NSArray *args; NSEnumerator *enumerator; - NSMutableDictionary *argDict = nil; + NSMutableDictionary *argDict; BOOL done; id key, val; [_lock lock]; - NS_DURING - { - args = [[NSProcessInfo processInfo] arguments]; - enumerator = [args objectEnumerator]; - argDict = [NSMutableDictionaryClass dictionaryWithCapacity: 2]; - [enumerator nextObject]; // Skip process name. - done = ((key = [enumerator nextObject]) == nil) ? YES : NO; + args = [[NSProcessInfo processInfo] arguments]; + enumerator = [args objectEnumerator]; + argDict = [NSMutableDictionaryClass dictionaryWithCapacity: 2]; + [enumerator nextObject]; // Skip process name. + done = ((key = [enumerator nextObject]) == nil) ? YES : NO; - while (done == NO) - { - if ([key hasPrefix: @"-"] == YES && [key isEqual: @"-"] == NO) + while (done == NO) + { + if ([key hasPrefix: @"-"] == YES && [key isEqual: @"-"] == NO) + { + NSString *old = nil; + + /* anything beginning with a '-' is a defaults key and we must strip + the '-' from it. As a special case, we leave the '- in place + for '-GS...' and '--GS...' for backward compatibility. */ + if ([key hasPrefix: @"-GS"] == YES || [key hasPrefix: @"--GS"] == YES) { - NSString *old = nil; - - /* anything beginning with a '-' is a defaults key and we must strip - the '-' from it. As a special case, we leave the '- in place - for '-GS...' and '--GS...' for backward compatibility. */ - if ([key hasPrefix: @"-GS"] == YES || [key hasPrefix: @"--GS"] == YES) - { - old = key; - } - key = [key substringFromIndex: 1]; - val = [enumerator nextObject]; - if (val == nil) - { // No more args - [argDict setObject: @"" forKey: key]; // arg is empty. - if (old != nil) - { - [argDict setObject: @"" forKey: old]; - } - done = YES; - continue; - } - else if ([val hasPrefix: @"-"] == YES && [val isEqual: @"-"] == NO) - { // Yet another argument - [argDict setObject: @"" forKey: key]; // arg is empty. - if (old != nil) - { - [argDict setObject: @"" forKey: old]; - } - key = val; - continue; - } - else - { // Real parameter - /* Parsing the argument as a property list is very - delicate. We *MUST NOT* crash here just because a - strange parameter (such as `(load "test.scm")`) is - passed, otherwise the whole library is useless in a - foreign environment. */ - NSObject *plist_val; - - NS_DURING - { - plist_val = [val propertyList]; - } - NS_HANDLER - { - plist_val = val; - } - NS_ENDHANDLER - - /* Make sure we don't crash being caught adding nil to - a dictionary. */ - if (plist_val == nil) - { - plist_val = val; - } - - [argDict setObject: plist_val forKey: key]; - if (old != nil) - { - [argDict setObject: plist_val forKey: old]; - } - } + old = key; } - done = ((key = [enumerator nextObject]) == nil); - } - [_lock unlock]; + key = [key substringFromIndex: 1]; + val = [enumerator nextObject]; + if (val == nil) + { // No more args + [argDict setObject: @"" forKey: key]; // arg is empty. + if (old != nil) + { + [argDict setObject: @"" forKey: old]; + } + done = YES; + continue; + } + else if ([val hasPrefix: @"-"] == YES && [val isEqual: @"-"] == NO) + { // Yet another argument + [argDict setObject: @"" forKey: key]; // arg is empty. + if (old != nil) + { + [argDict setObject: @"" forKey: old]; + } + key = val; + continue; + } + else + { // Real parameter + /* Parsing the argument as a property list is very + delicate. We *MUST NOT* crash here just because a + strange parameter (such as `(load "test.scm")`) is + passed, otherwise the whole library is useless in a + foreign environment. */ + NSObject *plist_val; + + NS_DURING + { + plist_val = [val propertyList]; + } + NS_HANDLER + { + plist_val = val; + } + NS_ENDHANDLER + + /* Make sure we don't crash being caught adding nil to + a dictionary. */ + if (plist_val == nil) + { + plist_val = val; + } + + [argDict setObject: plist_val forKey: key]; + if (old != nil) + { + [argDict setObject: plist_val forKey: old]; + } + } + } + done = ((key = [enumerator nextObject]) == nil); } - NS_HANDLER - { - [_lock unlock]; - [localException raise]; - } - NS_ENDHANDLER + [_lock unlock]; return argDict; } - (void) __changePersistentDomain: (NSString*)domainName { [_lock lock]; - NS_DURING + DESTROY(_dictionaryRep); + if (self == sharedDefaults) invalidatedLanguages = YES; + if (_changedDomains == nil) { - DESTROY(_dictionaryRep); - if (self == sharedDefaults) invalidatedLanguages = YES; - if (_changedDomains == nil) - { - _changedDomains = [[NSMutableArray alloc] initWithObjects: &domainName - count: 1]; - updateCache(self); - [[NSNotificationCenter defaultCenter] - postNotificationName: NSUserDefaultsDidChangeNotification - object: self]; - } - else if ([_changedDomains containsObject: domainName] == NO) - { - [_changedDomains addObject: domainName]; - } - [_lock unlock]; + _changedDomains = [[NSMutableArray alloc] initWithObjects: &domainName + count: 1]; + updateCache(self); + [[NSNotificationCenter defaultCenter] + postNotificationName: NSUserDefaultsDidChangeNotification + object: self]; } - NS_HANDLER + else if ([_changedDomains containsObject: domainName] == NO) { - [_lock unlock]; - [localException raise]; + [_changedDomains addObject: domainName]; } - NS_ENDHANDLER + [_lock unlock]; } @end @@ -2143,39 +1846,25 @@ GSPrivateDefaultsFlag(GSUserDefaultFlagType type) return flags[type]; } -/* Slightly faster than +/* FIXME ... Slightly faster than * [[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - * Avoiding the autorelease of the standard defaults turns out to be - * a modest but significant gain when making heavy use of methods which - * need localisation. + * but is it really worthwile? */ NSDictionary *GSPrivateDefaultLocale() { - NSDictionary *locale = nil; - NSUserDefaults *defs = nil; + NSDictionary *locale; if (classLock == nil) { [NSUserDefaults standardUserDefaults]; } [classLock lock]; - NS_DURING + if (sharedDefaults == nil) { - if (sharedDefaults == nil) - { - [NSUserDefaults standardUserDefaults]; - } - defs = [sharedDefaults retain]; - [classLock unlock]; + [NSUserDefaults standardUserDefaults]; } - NS_HANDLER - { - [classLock unlock]; - [localException raise]; - } - NS_ENDHANDLER - locale = [defs dictionaryRepresentation]; - [defs release]; + locale = [sharedDefaults dictionaryRepresentation]; + [classLock unlock]; return locale; } diff --git a/Source/NSValue.m b/Source/NSValue.m index 9e6ffb234..29a585c55 100644 --- a/Source/NSValue.m +++ b/Source/NSValue.m @@ -9,7 +9,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -27,15 +27,17 @@ $Date$ $Revision$ */ -#import "common.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSCoder.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSData.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSValue.h" +#include "Foundation/NSCoder.h" +#include "Foundation/NSDictionary.h" +#include "Foundation/NSZone.h" +#include "Foundation/NSException.h" +#include "Foundation/NSMapTable.h" +#include "Foundation/NSLock.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDebug.h" @interface GSPlaceholderValue : NSValue @end @@ -88,7 +90,7 @@ static NSLock *placeholderLock; if (self == [NSValue class]) { abstractClass = self; - [abstractClass setVersion: 3]; // Version 3 + [abstractClass setVersion: 2]; // Version 2 concreteClass = [GSValue class]; nonretainedObjectValueClass = [GSNonretainedObjectValue class]; pointValueClass = [GSPointValue class]; @@ -278,6 +280,7 @@ static NSLock *placeholderLock; NSRange range; range = NSMakeRange([[dict objectForKey: @"location"] intValue], [[dict objectForKey: @"length"] intValue]); + return [abstractClass valueWithRange: range]; } else if ([dict objectForKey: @"width"] && [dict objectForKey: @"x"]) { @@ -390,37 +393,8 @@ static NSLock *placeholderLock; size = strlen(objctype)+1; [coder encodeValueOfObjCType: @encode(unsigned) at: &size]; [coder encodeArrayOfObjCType: @encode(signed char) count: size at: objctype]; - if (strncmp("{_NSSize=", objctype, 9) == 0) - { - NSSize v = [self sizeValue]; - - [coder encodeValueOfObjCType: objctype at: &v]; - return; - } - else if (strncmp("{_NSPoint=", objctype, 10) == 0) - { - NSPoint v = [self pointValue]; - - [coder encodeValueOfObjCType: objctype at: &v]; - return; - } - else if (strncmp("{_NSRect=", objctype, 9) == 0) - { - NSRect v = [self rectValue]; - - [coder encodeValueOfObjCType: objctype at: &v]; - return; - } - else if (strncmp("{_NSRange=", objctype, 10) == 0) - { - NSRange v = [self rangeValue]; - - [coder encodeValueOfObjCType: objctype at: &v]; - return; - } - size = objc_sizeof_type(objctype); - data = (void *)NSZoneMalloc([self zone], size); + data = (void *)NSZoneMalloc(GSObjCZone(self), size); [self getValue: (void*)data]; d = [NSMutableData new]; [d serializeDataAt: data ofObjCType: objctype context: nil]; @@ -458,55 +432,10 @@ static NSLock *placeholderLock; [coder decodeArrayOfObjCType: @encode(signed char) count: size at: (void*)objctype]; - if (strncmp("{_NSSize=", objctype, 9) == 0) - c = [abstractClass valueClassWithObjCType: @encode(NSSize)]; - else if (strncmp("{_NSPoint=", objctype, 10) == 0) - c = [abstractClass valueClassWithObjCType: @encode(NSPoint)]; - else if (strncmp("{_NSRect=", objctype, 9) == 0) - c = [abstractClass valueClassWithObjCType: @encode(NSRect)]; - else if (strncmp("{_NSRange=", objctype, 10) == 0) - c = [abstractClass valueClassWithObjCType: @encode(NSRange)]; - else - c = [abstractClass valueClassWithObjCType: objctype]; + c = [abstractClass valueClassWithObjCType: objctype]; o = [c allocWithZone: [coder objectZone]]; ver = [coder versionForClassName: @"NSValue"]; - if (ver > 2) - { - if (c == pointValueClass) - { - NSPoint v; - - [coder decodeValueOfObjCType: @encode(NSPoint) at: &v]; - DESTROY(self); - return [o initWithBytes: &v objCType: @encode(NSPoint)]; - } - else if (c == sizeValueClass) - { - NSSize v; - - [coder decodeValueOfObjCType: @encode(NSSize) at: &v]; - DESTROY(self); - return [o initWithBytes: &v objCType: @encode(NSSize)]; - } - else if (c == rangeValueClass) - { - NSRange v; - - [coder decodeValueOfObjCType: @encode(NSRange) at: &v]; - DESTROY(self); - return [o initWithBytes: &v objCType: @encode(NSRange)]; - } - else if (c == rectValueClass) - { - NSRect v; - - [coder decodeValueOfObjCType: @encode(NSRect) at: &v]; - DESTROY(self); - return [o initWithBytes: &v objCType: @encode(NSRect)]; - } - } - if (ver < 2) { if (ver < 1) @@ -554,8 +483,8 @@ static NSLock *placeholderLock; } else { - NSData *d; - unsigned cursor = 0; + NSData *d; + unsigned cursor = 0; /* * For performance, decode small values directly onto the stack, @@ -593,7 +522,7 @@ static NSLock *placeholderLock; else { static NSData *d = nil; - unsigned cursor = 0; + unsigned cursor = 0; if (d == nil) { @@ -651,7 +580,7 @@ static NSLock *placeholderLock; { NSZoneFree(NSDefaultMallocZone(), (void*)objctype); } - DESTROY(self); + RELEASE(self); self = o; return self; } @@ -673,7 +602,7 @@ static NSLock *placeholderLock; GSNOSUPERDEALLOC; // placeholders never get deallocated. } -- (void) getData: (void*)data +- (void) getValue: (void*)data { [NSException raise: NSInternalInconsistencyException format: @"attempt to use uninitialised value"]; @@ -683,7 +612,7 @@ static NSLock *placeholderLock; { Class c = [abstractClass valueClassWithObjCType: type]; - self = (id)NSAllocateObject(c, 0, [self zone]); + self = (id)NSAllocateObject(c, 0, GSObjCZone(self)); return [self initWithBytes: data objCType: type]; } diff --git a/Source/NSValueTransformer.m b/Source/NSValueTransformer.m index 260483825..aa9a1ff78 100644 --- a/Source/NSValueTransformer.m +++ b/Source/NSValueTransformer.m @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,22 +17,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#define EXPOSE_NSValueTransformer_IVARS 1 -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSKeyedArchiver.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSValueTransformer.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#import "Foundation/Foundation.h" #import "GNUstepBase/GSLock.h" @interface NSNegateBooleanTransformer : NSValueTransformer @@ -50,6 +41,15 @@ @implementation NSValueTransformer +NSString * const NSNegateBooleanTransformerName + = @"NSNegateBooleanTransformerName"; +NSString * const NSIsNilTransformerName + = @"NSIsNilTransformerName"; +NSString * const NSIsNotNilTransformerName + = @"NSIsNotNilTransformerName"; +NSString * const NSUnarchiveFromDataTransformerName + = @"NSUnarchiveFromDataTransformerName"; + // non-abstract methods static NSMutableDictionary *registry = nil; @@ -100,7 +100,7 @@ static GSLazyLock *lock = nil; [lock lock]; transformer = [registry objectForKey: name]; - IF_NO_GC([transformer retain];) + RETAIN(transformer); [lock unlock]; return AUTORELEASE(transformer); } diff --git a/Source/NSXMLDTD.m b/Source/NSXMLDTD.m deleted file mode 100644 index e44223d1f..000000000 --- a/Source/NSXMLDTD.m +++ /dev/null @@ -1,170 +0,0 @@ -/* Inmplementation for NSXMLDTD for GNUStep - Copyright (C) 2008 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Created: September 2008 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. -*/ - -#import "common.h" - -#import "NSXMLPrivate.h" - -@implementation NSXMLDTD - -+ (NSXMLDTDNode*) predefinedEntityDeclarationForName: (NSString*)name -{ - [self notImplemented: _cmd]; - return nil; -} - -- (void) dealloc -{ - [_name release]; - [_publicID release]; - [_systemID release]; - [_children release]; - [_entities release]; - [_elements release]; - [_notations release]; - [_attributes release]; - [_original release]; - [super dealloc]; -} - -- (void) addChild: (NSXMLNode*)child -{ - [self notImplemented: _cmd]; -} - -- (NSXMLDTDNode*) attributeDeclarationForName: (NSString*)name - elementName: (NSString*)elementName -{ - [self notImplemented: _cmd]; - return nil; -} - -- (NSXMLDTDNode*) elementDeclarationForName: (NSString*)name -{ - [self notImplemented: _cmd]; - return nil; -} - -- (NSXMLDTDNode*) entityDeclarationForName: (NSString*)name -{ - [self notImplemented: _cmd]; - return nil; -} - -- (id) initWithContentsOfURL: (NSURL*)url - options: (NSUInteger)mask - error: (NSError**)error -{ - NSData *data; - NSXMLDTD *doc; - - data = [NSData dataWithContentsOfURL: url]; - doc = [self initWithData: data options: 0 error: 0]; - [doc setURI: [url absoluteString]]; - return doc; -} - -- (id) initWithData: (NSData*)data - options: (NSUInteger)mask - error: (NSError**)error -{ - [self notImplemented: _cmd]; - return nil; -} - -- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index -{ - [self notImplemented: _cmd]; - _childrenHaveMutated = YES; -} - -- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index -{ - NSEnumerator *enumerator = [children objectEnumerator]; - NSXMLNode *child; - - while ((child = [enumerator nextObject]) != nil) - { - [self insertChild: child atIndex: index++]; - } -} - -- (NSXMLDTDNode*) notationDeclarationForName: (NSString*)name -{ - NSXMLDTDNode *notation = [_notations objectForKey: name]; - - if (notation == nil) - { - [self notImplemented: _cmd]; - } - return notation; -} - -- (NSString*) publicID -{ - if (_publicID == nil) - { - [self notImplemented: _cmd]; - } - return _publicID; -} - -- (void) removeChildAtIndex: (NSUInteger)index -{ - [self notImplemented: _cmd]; -} - -- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node -{ - [self notImplemented: _cmd]; -} - -- (void) setChildren: (NSArray*)children -{ - [self notImplemented: _cmd]; -} - -- (void) setPublicID: (NSString*)publicID -{ - [self notImplemented: _cmd]; - _modified = YES; -} - -- (void) setSystemID: (NSString*)systemID -{ - [self notImplemented: _cmd]; - _modified = YES; -} - -- (NSString*) systemID -{ - if (_systemID == nil) - { - [self notImplemented: _cmd]; - } - return _systemID; -} - -@end - diff --git a/Source/NSXMLDTDNode.m b/Source/NSXMLDTDNode.m deleted file mode 100644 index 9a34e7685..000000000 --- a/Source/NSXMLDTDNode.m +++ /dev/null @@ -1,113 +0,0 @@ -/* Implementation for NSXMLDTDNode for GNUStep - Copyright (C) 2008 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Created: September 2008 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. -*/ - -#import "common.h" - -#import "NSXMLPrivate.h" - -@implementation NSXMLDTDNode - -- (void) dealloc -{ - [_name release]; - [_notationName release]; - [_publicID release]; - [_systemID release]; - [super dealloc]; -} - -- (NSXMLDTDNodeKind) DTDKind -{ - return _DTDKind; -} - -- (id) initWithXMLString: (NSString*)string -{ - [self notImplemented: _cmd]; - return nil; -} - -- (BOOL) isExternal -{ - if (_systemID != nil) - { -// FIXME ... libxml integration? - return YES; - } - return NO; -} - -- (NSString*) notationName -{ - if (_notationName == nil) - { - [self notImplemented: _cmd]; - } - return _notationName; -} - -- (NSString*) publicID -{ - if (_publicID == nil) - { - [self notImplemented: _cmd]; - } - return _publicID; -} - -- (void) setDTDKind: (NSXMLDTDNodeKind)kind -{ - _DTDKind = kind; - // FIXME ... libxml integration? -} - -- (void) setNotationName: (NSString*)notationName -{ - ASSIGNCOPY(_notationName, notationName); - // FIXME ... libxml integration? -} - -- (void) setPublicID: (NSString*)publicID -{ - ASSIGNCOPY(_publicID, publicID); - // FIXME ... libxml integration? -} - -- (void) setSystemID: (NSString*)systemID -{ - ASSIGNCOPY(_systemID, systemID); - // FIXME ... libxml integration? -} - -- (NSString*) systemID -{ - if (_systemID == nil) - { - [self notImplemented: _cmd]; - } - return _systemID; -} - -@end - diff --git a/Source/NSXMLDocument.m b/Source/NSXMLDocument.m deleted file mode 100644 index c3738fc39..000000000 --- a/Source/NSXMLDocument.m +++ /dev/null @@ -1,250 +0,0 @@ -/* Implementation for NSXMLDocument for GNUStep - Copyright (C) 2008 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Created: September 2008 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. -*/ - -#import "common.h" - -#import "NSXMLPrivate.h" - -@implementation NSXMLDocument - -+ (Class) replacementClassForClass: (Class)cls -{ - return Nil; -} - -- (void) dealloc -{ - [_encoding release]; - [_version release]; - [_docType release]; - [_children release]; - [_URI release]; - [_MIMEType release]; - [super dealloc]; -} - -- (NSString*) characterEncoding -{ - return _encoding; -} - -- (NSXMLDocumentContentKind) documentContentKind -{ - return _contentKind; -} - -- (NSXMLDTD*) DTD -{ - return _docType; -} - -- (id) initWithContentsOfURL: (NSURL*)url - options: (NSUInteger)mask - error: (NSError**)error -{ - NSData *data; - NSXMLDocument *doc; - - data = [NSData dataWithContentsOfURL: url]; - doc = [self initWithData: data options: 0 error: 0]; - [doc setURI: [url absoluteString]]; - return doc; -} - - -- (id) initWithData: (NSData*)data - options: (NSUInteger)mask - error: (NSError**)error -{ - [self notImplemented: _cmd]; - _children = [NSMutableArray new]; - return nil; -} - -- (id) initWithRootElement: (NSXMLElement*)element -{ - self = [self initWithData: nil options: 0 error: 0]; - [self setRootElement: (NSXMLNode*)element]; - return self; -} - -- (id) initWithXMLString: (NSString*)string - options: (NSUInteger)mask - error: (NSError**)error -{ - [self notImplemented: _cmd]; - return nil; -} - -- (BOOL) isStandalone -{ - return _standalone; -} - -- (NSString*) MIMEType -{ - return _MIMEType; -} - -- (NSXMLElement*) rootElement -{ - return _rootElement; -} - -- (void) setCharacterEncoding: (NSString*)encoding -{ - ASSIGNCOPY(_encoding, encoding); -} - -- (void) setDocumentContentKind: (NSXMLDocumentContentKind)kind -{ - _contentKind = kind; -} - -- (void) setDTD: (NSXMLDTD*)documentTypeDeclaration -{ - ASSIGNCOPY(_docType, documentTypeDeclaration); -} - -- (void) setMIMEType: (NSString*)MIMEType -{ - ASSIGNCOPY(_MIMEType, MIMEType); -} - -- (void) setRootElement: (NSXMLNode*)root -{ - NSAssert(_rootElement == nil, NSGenericException); - [self insertChild: root atIndex: [_children count]]; - _rootElement = (NSXMLElement*)root; -} - -- (void) setStandalone: (BOOL)standalone -{ - _standalone = standalone; -} - -- (void) setVersion: (NSString*)version -{ - if ([version isEqualToString: @"1.0"] || [version isEqualToString: @"1.1"]) - { - ASSIGNCOPY(_version, version); - } - else - { - [NSException raise: NSInvalidArgumentException - format: @"Bad XML version (%@)", version]; - } -} - -- (NSString*) version -{ - return _version; -} - -- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index -{ - [self notImplemented: _cmd]; -} - -- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index -{ - NSEnumerator *enumerator = [children objectEnumerator]; - NSXMLNode *node; - - while ((node = [enumerator nextObject]) != nil) - { - [self insertChild: node atIndex: index++]; - } -} - -- (void) removeChildAtIndex: (NSUInteger)index -{ - [self notImplemented: _cmd]; -} - -- (void) setChildren: (NSArray*)children -{ - unsigned count; - - while ((count = [_children count]) > 0) - { - [self removeChildAtIndex: count - 1]; - } - [self insertChildren: children atIndex: 0]; -} - -- (void) addChild: (NSXMLNode*)child -{ - [self insertChild: child atIndex: [_children count]]; -} - -- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node -{ - [self removeChildAtIndex: index]; - [self insertChild: node atIndex: index]; -} - -- (NSData*) XMLData -{ - return [self XMLDataWithOptions: NSXMLNodeOptionsNone]; -} - -- (NSData*) XMLDataWithOptions: (NSUInteger)options -{ - [self notImplemented: _cmd]; - return nil; -} - -- (id) objectByApplyingXSLT: (NSData*)xslt - arguments: (NSDictionary*)arguments - error: (NSError**)error -{ - [self notImplemented: _cmd]; - return nil; -} - -- (id) objectByApplyingXSLTString: (NSString*)xslt - arguments: (NSDictionary*)arguments - error: (NSError**)error -{ - [self notImplemented: _cmd]; - return nil; -} - -- (id) objectByApplyingXSLTAtURL: (NSURL*)xsltURL - arguments: (NSDictionary*)argument - error: (NSError**)error -{ - [self notImplemented: _cmd]; - return nil; -} - -- (BOOL) validateAndReturnError: (NSError**)error -{ - [self notImplemented: _cmd]; - return NO; -} - -@end - diff --git a/Source/NSXMLElement.m b/Source/NSXMLElement.m deleted file mode 100644 index 3625d4a1a..000000000 --- a/Source/NSXMLElement.m +++ /dev/null @@ -1,217 +0,0 @@ -/* Implementation for NSXMLElement for GNUStep - Copyright (C) 2008 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Created: September 2008 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. -*/ - -#import "common.h" - -#import "NSXMLPrivate.h" - -@implementation NSXMLElement - -- (void) dealloc -{ - [_name release]; - [_attributes release]; - [_namespaces release]; - [_children release]; - [_URI release]; - [super dealloc]; -} - -- (id) initWithName: (NSString*)name -{ - return [self initWithName: name URI: nil]; -} - -- (id) initWithName: (NSString*)name URI: (NSString*)URI -{ - [self notImplemented: _cmd]; - return nil; -} - -- (id) initWithName: (NSString*)name stringValue: (NSString*)string -{ - [self notImplemented: _cmd]; - return nil; -} - -- (id) initWithXMLString: (NSString*)string error: (NSError**)error -{ - [self notImplemented: _cmd]; - return nil; -} - -- (NSArray*) elementsForName: (NSString*)name -{ - [self notImplemented: _cmd]; - return nil; -} - -- (NSArray*) elementsForLocalName: (NSString*)localName URI: (NSString*)URI -{ - [self notImplemented: _cmd]; - return nil; -} - -- (void) addAttribute: (NSXMLNode*)attribute -{ - [self notImplemented: _cmd]; -} - -- (void) removeAttributeForName: (NSString*)name -{ - [self notImplemented: _cmd]; -} - -- (void) setAttributes: (NSArray*)attributes -{ - NSEnumerator *enumerator = [attributes objectEnumerator]; - NSXMLNode *attribute; - - while ((attribute = [enumerator nextObject]) != nil) - { - [self addAttribute: attribute]; - } -} - -- (void) setAttributesAsDictionary: (NSDictionary*)attributes -{ - [self notImplemented: _cmd]; -} - -- (NSArray*) attributes -{ - if (_attributes == nil) - { - [self notImplemented: _cmd]; - } - return _attributes; -} - -- (NSXMLNode*) attributeForName: (NSString*)name -{ - NSEnumerator *enumerator = [[self attributes] objectEnumerator]; - NSXMLNode *attribute; - - while ((attribute = [enumerator nextObject]) != nil) - { - if ([name isEqualToString: [attribute name]] == YES) - { - return attribute; - } - } - return nil; -} - -- (NSXMLNode*) attributeForLocalName: (NSString*)localName - URI: (NSString*)URI -{ - [self notImplemented: _cmd]; - return nil; -} - -- (void) addNamespace: (NSXMLNode*)aNamespace -{ - [self notImplemented: _cmd]; -} - -- (void) removeNamespaceForPrefix: (NSString*)name -{ - [self notImplemented: _cmd]; -} - -- (void) setNamespaces: (NSArray*)namespaces -{ - [self notImplemented: _cmd]; -} - -- (NSArray*) namespaces -{ - if (_namespaces == nil) - { - [self notImplemented: _cmd]; - } - return _namespaces; -} - -- (NSXMLNode*) namespaceForPrefix: (NSString*)name -{ - [self notImplemented: _cmd]; - return nil; -} - -- (NSXMLNode*) resolveNamespaceForName: (NSString*)name -{ - [self notImplemented: _cmd]; - return nil; -} - -- (NSString*) resolvePrefixForNamespaceURI: (NSString*)namespaceURI -{ - [self notImplemented: _cmd]; - return nil; -} - -- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index -{ - [self notImplemented: _cmd]; -} - -- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index -{ - NSEnumerator *enumerator = [children objectEnumerator]; - NSXMLNode *child; - - while ((child = [enumerator nextObject]) != nil) - { - [self insertChild: child atIndex: index++]; - } -} - -- (void) removeChildAtIndex: (NSUInteger)index -{ - [self notImplemented: _cmd]; -} - -- (void) setChildren: (NSArray*)children -{ - [self notImplemented: _cmd]; -} - -- (void) addChild: (NSXMLNode*)child -{ - [self notImplemented: _cmd]; -} - -- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node -{ - [self notImplemented: _cmd]; -} - -- (void) normalizeAdjacentTextNodesPreservingCDATA: (BOOL)preserve -{ - [self notImplemented: _cmd]; -} - -@end - diff --git a/Source/NSXMLNode.m b/Source/NSXMLNode.m deleted file mode 100644 index ae6dadbb0..000000000 --- a/Source/NSXMLNode.m +++ /dev/null @@ -1,372 +0,0 @@ -/* Implementation for NSXMLNode for GNUStep - Copyright (C) 2008 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Created: September 2008 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. -*/ - -#import "common.h" - -#import "NSXMLPrivate.h" - -@implementation NSXMLNode - -+ (id) attributeWithName: (NSString*)name - stringValue: (NSString*)stringValue -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLAttributeKind] autorelease]; - [n setStringValue: stringValue]; - return n; -} - -+ (id) attributeWithName: (NSString*)name - URI: (NSString*)URI - stringValue: (NSString*)stringValue -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLAttributeKind] autorelease]; - [n setURI: URI]; - [n setStringValue: stringValue]; - return n; -} - -+ (id) commentWithStringValue: (NSString*)stringValue -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLCommentKind] autorelease]; - [n setStringValue: stringValue]; - return n; -} - -+ (id) DTDNodeWithXMLString: (NSString*)string -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLDTDKind] autorelease]; - [n setStringValue: string]; - return n; -} - -+ (id) document -{ - NSXMLNode *n; - - n = [[[NSXMLDocument alloc] initWithKind:NSXMLDocumentKind] autorelease]; - return n; -} - -+ (id) documentWithRootElement: (NSXMLElement*)element -{ - NSXMLDocument *d; - - d = [NSXMLDocument alloc]; - d = [[d initWithRootElement: element] autorelease]; - return d; -} - -+ (id) elementWithName: (NSString*)name -{ - NSXMLNode *n; - - n = [[[NSXMLElement alloc] initWithName: name] autorelease]; - return n; -} - -+ (id) elementWithName: (NSString*)name - children: (NSArray*)children - attributes: (NSArray*)attributes -{ - NSXMLElement *e = [self elementWithName: name]; - - [e insertChildren: children atIndex: 0]; - [e setAttributes: attributes]; - return e; -} - -+ (id) elementWithName: (NSString*)name - URI: (NSString*)URI -{ - NSXMLNode *n; - - n = [[[NSXMLElement alloc] initWithName: name URI: URI] autorelease]; - return n; -} - -+ (id) elementWithName: (NSString*)name - stringValue: (NSString*)string -{ - NSXMLElement *e; - NSXMLNode *t; - - e = [self elementWithName: name]; - t = [[self alloc] initWithKind: NSXMLTextKind]; - [t setStringValue: string]; - [e addChild: t]; - [t release]; - return e; -} - -+ (NSString*) localNameForName: (NSString*)name -{ - return [self notImplemented: _cmd]; -} - -+ (id) namespaceWithName: (NSString*)name - stringValue: (NSString*)stringValue -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLNamespaceKind] autorelease]; - [n setStringValue: stringValue]; - return n; -} - -+ (NSXMLNode*) predefinedNamespaceForPrefix: (NSString*)name -{ - return [self notImplemented: _cmd]; -} - -+ (NSString*) prefixForName: (NSString*)name -{ - return [self notImplemented: _cmd]; -} - -+ (id) processingInstructionWithName: (NSString*)name - stringValue: (NSString*)stringValue -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLProcessingInstructionKind] autorelease]; - [n setStringValue: stringValue]; - return n; -} - -+ (id) textWithStringValue: (NSString*)stringValue -{ - NSXMLNode *n; - - n = [[[self alloc] initWithKind: NSXMLTextKind] autorelease]; - [n setStringValue: stringValue]; - return n; -} - -- (NSString*) canonicalXMLStringPreservingComments: (BOOL)comments -{ - return [self notImplemented: _cmd]; // FIXME ... generate from libxml -} - -- (NSXMLNode*) childAtIndex: (NSUInteger)index -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSUInteger) childCount -{ - [self notImplemented: _cmd]; // FIXME ... fetch from libxml - return 0; -} - -- (NSArray*)children -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (id) copyWithZone: (NSZone*)zone -{ - return [self notImplemented: _cmd]; -} - -- (void) dealloc -{ - [self detach]; - [_objectValue release]; - [super dealloc]; -} - -- (void) detach -{ - if (_parent != nil) - { - [self notImplemented: _cmd]; // FIXME ... remove from libxml - } -} - -- (NSUInteger) index -{ - return _index; -} - -- (id) initWithKind:(NSXMLNodeKind) kind -{ - self = [self initWithKind: kind options: 0]; - return self; -} - -- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)options -{ - if ((self = [super init]) != nil) - { - [self notImplemented: _cmd]; // FIXME ... use libxml - } - return self; -} - -- (NSXMLNodeKind) kind -{ - return _kind; -} - -- (NSUInteger) level -{ - NSUInteger level = 0; - NSXMLNode *tmp = _parent; - - while (tmp != nil) - { - level++; - tmp = tmp->_parent; - } - return level; -} - -- (NSString*) localName -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSString*) name -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSXMLNode*) nextNode -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSXMLNode*) nextSibling -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (id) objectValue -{ - return _objectValue; -} - -- (NSXMLNode*) parent -{ - return _parent; -} - -- (NSString*) prefix -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSXMLNode*) previousNode -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSXMLNode*) previousSibling -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSXMLDocument*) rootDocument -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSString*) stringValue -{ - // FIXME - return _objectValue; -} - -- (NSString*) URI -{ - return [self notImplemented: _cmd]; // FIXME ... fetch from libxml -} - -- (NSString*) XMLString -{ - return [self XMLStringWithOptions: 0]; -} - -- (NSString*) XMLStringWithOptions: (NSUInteger)options -{ - return [self notImplemented: _cmd]; // FIXME ... generate from libxml -} - -- (void) setObjectValue: (id)value -{ - ASSIGN(_objectValue, value); -} - -- (void) setName: (NSString*)name -{ - [self notImplemented: _cmd]; // FIXME ... set in libxml -} - -- (void) setStringValue: (NSString*)string -{ - [self setStringValue: string resolvingEntities: NO]; -} - -- (void) setURI: (NSString*)URI -{ - [self notImplemented: _cmd]; // FIXME ... set in libxml -} - -- (void) setStringValue: (NSString*)string resolvingEntities: (BOOL)resolve -{ - [self notImplemented: _cmd]; // FIXME ... set in libxml -} - -- (NSString*) XPath -{ - return [self notImplemented: _cmd]; -} - - - (NSArray*) nodesForXPath: (NSString*)xpath error: (NSError**)error -{ - return [self notImplemented: _cmd]; -} - - - (NSArray*) objectsForXQuery: (NSString*)xquery - constants: (NSDictionary*)constants - error: (NSError**)error -{ - return [self notImplemented: _cmd]; -} - -- (NSArray*) objectsForXQuery: (NSString*)xquery error: (NSError**)error -{ - return [self notImplemented: _cmd]; -} - -@end - diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 133ebec16..ec8309d19 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -4,12 +4,10 @@ Written by: Richard Frith-Macdonald Date: May 2004 - SloppyParser additions based on code by Nikolaus Schaller - This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,84 +16,42 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" -#define EXPOSE_NSXMLParser_IVARS 1 -#import "Foundation/NSArray.h" -#import "Foundation/NSError.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSXMLParser.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSNull.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" -#import "GNUstepBase/GSMime.h" - -@interface GSMimeDocument (internal) -+ (NSString*) charsetForXml: (NSData*)xml; -@end +#include "config.h" +#include +#include +#include +#include +#include +#include NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain"; -static NSNull *null = nil; +#ifdef HAVE_LIBXML -#if defined(HAVE_LIBXML) - -/* We support a strict libxml2 based parser ... but sometimes we need a - * sloppier parser which copes with bad XML generated by Apple's software, - * so we call the sloppy parser GSSloppyXMLParser. - */ -#define SloppyXMLParser GSSloppyXMLParser -@interface GSSloppyXMLParser : NSXMLParser -@end - -#include +#include @interface NSXMLSAXHandler : GSSAXHandler { @public - id _delegate; // Not retained - id _owner; // Not retained + id _delegate; + id _owner; NSError *_lastError; BOOL _shouldProcessNamespaces; BOOL _shouldReportNamespacePrefixes; BOOL _shouldResolveExternalEntities; - NSMutableArray *_namespaces; } - (void) _setOwner: (id)owner; @end @implementation NSXMLSAXHandler -+ (void) initialize -{ - GSMakeWeakPointer(self, "_delegate"); - GSMakeWeakPointer(self, "_owner"); -} - -- (void) dealloc -{ - DESTROY(_namespaces); - DESTROY(_lastError); - [super dealloc]; -} - -- (id) init -{ - if ((self = [super init]) != nil) - { - _namespaces = [NSMutableArray new]; - } - return self; -} - - (void) endDocument { [_delegate parserDidEndDocument: _owner]; @@ -109,124 +65,43 @@ static NSNull *null = nil; prefix: (NSString*)prefix href: (NSString*)href attributes: (NSMutableDictionary*)elementAttributes - namespaces: (NSMutableDictionary*)elementNamespaces { - NSString *qName = elementName; - - if ([prefix length] > 0) - { - qName = [NSString stringWithFormat: @"%@:%@", prefix, qName]; - } - - if ([elementNamespaces count] > 0) - { - [_namespaces addObject: [elementNamespaces allKeys]]; - if (_shouldReportNamespacePrefixes) - { - NSEnumerator *e = [elementNamespaces keyEnumerator]; - NSString *k; - - while ((k = [e nextObject]) != nil) - { - NSString *v = [elementNamespaces objectForKey: k]; - - [_delegate parser: _owner - didStartMappingPrefix: k - toURI: v]; - } - } - } - else - { - [_namespaces addObject: null]; - } - if (_shouldProcessNamespaces) { [_delegate parser: _owner didStartElement: elementName namespaceURI: href - qualifiedName: qName + qualifiedName: prefix attributes: elementAttributes]; } else { - /* When we are not handling namespaces specially, any namespaces - * should appear as attributes of the element. - */ - if ([elementNamespaces count] > 0) - { - NSEnumerator *e = [elementNamespaces keyEnumerator]; - NSString *k; - - if (elementAttributes == nil) - { - elementAttributes = [NSMutableDictionary dictionary]; - } - while ((k = [e nextObject]) != nil) - { - NSString *v = [elementNamespaces objectForKey: k]; - - if ([k length] == 0) - { - [elementAttributes setObject: v forKey: @"xmlns"]; - } - else - { - k = [@"xmlns:" stringByAppendingString: k]; - [elementAttributes setObject: v forKey: k]; - } - } - } [_delegate parser: _owner - didStartElement: qName + didStartElement: elementName namespaceURI: nil qualifiedName: nil attributes: elementAttributes]; } } -- (void) endElement: (NSString*)elementName +- (void) endElement: (NSString*) elementName prefix: (NSString*)prefix href: (NSString*)href { - NSString *qName = elementName; - - if ([prefix length] > 0) - { - qName = [NSString stringWithFormat: @"%@:%@", prefix, qName]; - } if (_shouldProcessNamespaces) { [_delegate parser: _owner didEndElement: elementName namespaceURI: href - qualifiedName: qName]; + qualifiedName: prefix]; } else { [_delegate parser: _owner - didEndElement: qName + didEndElement: elementName namespaceURI: nil qualifiedName: nil]; } - - if (_shouldReportNamespacePrefixes) - { - id o = [_namespaces lastObject]; - - if (o != (id)null) - { - NSEnumerator *e = [(NSArray*)o objectEnumerator]; - NSString *k; - - while ((k = [e nextObject]) != nil) - { - [_delegate parser: _owner didEndMappingPrefix: k]; - } - } - } - [_namespaces removeLastObject]; } - (void) attribute: (NSString*) name value: (NSString*)value { @@ -427,7 +302,7 @@ static NSNull *null = nil; - (void) _setOwner: (id)owner { - _owner = owner; + ASSIGN(_owner, owner); } @end @@ -436,14 +311,6 @@ static NSNull *null = nil; @implementation NSXMLParser -+ (void) initialize -{ - if (null == nil) - { - null = RETAIN([NSNull null]); - } -} - #define myParser ((GSXMLParser*)_parser) #define myHandler ((NSXMLSAXHandler*)_handler) @@ -551,12 +418,12 @@ static NSNull *null = nil; @end @implementation NSXMLParser (NSXMLParserLocatorAdditions) -- (NSInteger) columnNumber +- (int) columnNumber { return [myParser columnNumber]; } -- (NSInteger) lineNumber +- (int) lineNumber { return [myParser lineNumber]; } @@ -575,18 +442,6 @@ static NSNull *null = nil; #else -/* We have no strict libxml based parser, so we use the sloppy parser - * as the normal NSXMLParser and create a GSSloppyXMLParser subclass - * so that we can still specify GSSloppyXMLParser in other files. - */ -#define SloppyXMLParser NSXMLParser -@interface GSSloppyXMLParser : NSXMLParser -@end -@implementation GSSloppyXMLParser -@end -#endif - - @implementation NSString (NSXMLParser) - (NSString *) _stringByExpandingXMLEntities @@ -602,8 +457,7 @@ static NSNull *null = nil; @end -static inline NSString * -NewUTF8STR(const void *ptr, int len) +static NSString *UTF8STR(const void *ptr, int len) { NSString *s; @@ -611,89 +465,37 @@ NewUTF8STR(const void *ptr, int len) length: len encoding: NSUTF8StringEncoding]; if (s == nil) - NSLog(@"could not convert to UTF8 string! bytes=%p len=%d", ptr, len); - return s; + NSLog(@"could not convert to UTF8 string! bytes=%08x len=%d", ptr, len); + return AUTORELEASE(s); } typedef struct NSXMLParserIvarsType { - NSMutableArray *tagPath; // hierarchy of tags - NSMutableArray *namespaces; - NSData *data; - NSError *error; - const unsigned char *cp; // character pointer - const unsigned char *cend; // end of data + NSMutableArray *tagPath; // hierarchy of tags + NSData *data; + NSError *error; + const unsigned char *cp; // character pointer + const unsigned char *cend; // end of data int line; // current line (counts from 0) int column; // current column (counts from 0) BOOL abort; // abort parse loop - BOOL ignorable; // whitespace is ignorable - BOOL whitespace; // had only whitespace in current data BOOL shouldProcessNamespaces; BOOL shouldReportNamespacePrefixes; BOOL shouldResolveExternalEntities; BOOL acceptHTML; // be lazy with bad tag nesting - IMP didEndElement; - IMP didEndMappingPrefix; - IMP didStartElement; - IMP didStartMappingPrefix; - IMP foundCDATA; - IMP foundCharacters; - IMP foundComment; - IMP foundIgnorable; - } NSXMLParserIvars; -static SEL didEndElementSel = 0; -static SEL didEndMappingPrefixSel; -static SEL didStartElementSel; -static SEL didStartMappingPrefixSel; -static SEL foundCDATASel; -static SEL foundCharactersSel; -static SEL foundCommentSel; -static SEL foundIgnorableSel; +@implementation NSXMLParser -@implementation SloppyXMLParser - -#define EXTRA_DEBUG 0 - -#define _parser (self->_parser) -#define _handler (self->_handler) -#define this ((NSXMLParserIvars*)_parser) +#define this ((NSXMLParserIvars*)_parser) #define _del ((id)_handler) -+ (void) initialize -{ - if (null == nil) - { - null = RETAIN([NSNull null]); - } - if (didEndElementSel == 0) - { - didEndElementSel - = @selector(parser:didEndElement:namespaceURI:qualifiedName:); - didEndMappingPrefixSel - = @selector(parser:didEndMappingPrefix:); - didStartElementSel -= @selector(parser:didStartElement:namespaceURI:qualifiedName:attributes:); - didStartMappingPrefixSel - = @selector(parser:didStartMappingPrefix:toURI:); - foundCDATASel - = @selector(parser:foundCDATA:); - foundCharactersSel - = @selector(parser:foundCharacters:); - foundCommentSel - = @selector(parser:foundComment:); - foundIgnorableSel - = @selector(parser:foundIgnorableWhitespace:); - } -} - - (void) abortParsing { this->abort = YES; } -- (NSInteger) columnNumber +- (int) columnNumber { return this->column; } @@ -705,10 +507,7 @@ static SEL foundIgnorableSel; RELEASE(this->data); RELEASE(this->error); RELEASE(this->tagPath); - RELEASE(this->namespaces); NSZoneFree([self zone], this); - _parser = 0; - _handler = 0; } [super dealloc]; } @@ -734,131 +533,25 @@ static SEL foundIgnorableSel; self = [super init]; if (self) { - NSStringEncoding enc; - _parser = NSZoneMalloc([self zone], sizeof(NSXMLParserIvars)); memset(_parser, '\0', sizeof(NSXMLParserIvars)); - /* Determine character encoding and convert to utf-8 if needed. - */ - enc = [GSMimeDocument encodingFromCharset: - [GSMimeDocument charsetForXml: data]]; - if (enc == NSUTF8StringEncoding || enc == NSASCIIStringEncoding) - { - this->data = [data copy]; - } - else - { - NSString *tmp; - - tmp = [[NSString alloc] initWithData: data encoding: enc]; - data = [[tmp dataUsingEncoding: NSUTF8StringEncoding] retain]; - [tmp release]; - } + this->data = [data copy]; this->tagPath = [[NSMutableArray alloc] init]; - this->namespaces = [[NSMutableArray alloc] init]; this->cp = [this->data bytes]; this->cend = this->cp + [this->data length]; - /* If the data contained utf-8 with a BOM, we must skip it. - */ - if ((this->cend - this->cp) > 2 && this->cp[0] == 0xef - && this->cp[1] == 0xbb && this->cp[2] == 0xbf) - { - this->cp += 3; // Skip BOM - } } } return self; } -- (NSInteger) lineNumber +- (int) lineNumber { return this->line; } - (void) setDelegate: (id)delegate { - if (_handler != delegate) - { - _handler = delegate; - - if ([_del respondsToSelector: didEndElementSel]) - { - this->didEndElement = [_del methodForSelector: didEndElementSel]; - } - else - { - this->didEndElement = 0; - } - - if ([_del respondsToSelector: didEndMappingPrefixSel]) - { - this->didEndMappingPrefix - = [_del methodForSelector: didEndMappingPrefixSel]; - } - else - { - this->didEndMappingPrefix = 0; - } - - if ([_del respondsToSelector: didStartElementSel]) - { - this->didStartElement = [_del methodForSelector: didStartElementSel]; - } - else - { - this->didStartElement = 0; - } - - if ([_del respondsToSelector: didStartMappingPrefixSel]) - { - this->didStartMappingPrefix - = [_del methodForSelector: didStartMappingPrefixSel]; - } - else - { - this->didStartMappingPrefix = 0; - } - - if ([_del respondsToSelector: foundCDATASel]) - { - this->foundCDATA - = [_del methodForSelector: foundCDATASel]; - } - else - { - this->foundCDATA = 0; - } - - if ([_del respondsToSelector: foundCharactersSel]) - { - this->foundCharacters - = [_del methodForSelector: foundCharactersSel]; - } - else - { - this->foundCharacters = 0; - } - - if ([_del respondsToSelector: foundCommentSel]) - { - this->foundComment - = [_del methodForSelector: foundCommentSel]; - } - else - { - this->foundComment = 0; - } - - if ([_del respondsToSelector: foundIgnorableSel]) - { - this->foundIgnorable - = [_del methodForSelector: foundIgnorableSel]; - } - else - { - this->foundIgnorable = 0; - } - } + _handler = delegate; } - (NSError *) parserError @@ -873,254 +566,117 @@ static SEL foundIgnorableSel; #define cget() ((this->cp < this->cend)?(this->column++, *this->cp++): -1) -- (BOOL) _parseError: (NSString *)message code: (NSInteger)code +- (BOOL) _parseError: (NSString *)message { -#if EXTRA_DEBUG +#if 0 NSLog(@"XML parseError: %@", message); #endif - NSDictionary *info = nil; + NSError *err = nil; - [this->error release]; - if (message != nil) - { - info = [[NSDictionary alloc] initWithObjectsAndKeys: - message, NSLocalizedFailureReasonErrorKey, nil]; - } - this->error = [[NSError alloc] initWithDomain: NSXMLParserErrorDomain - code: code - userInfo: info]; - [info release]; - this->abort = YES; + ASSIGN(this->error, err); + this->abort = YES; // break look if ([_del respondsToSelector: @selector(parser:parseErrorOccurred:)]) - [_del parser: self parseErrorOccurred: this->error]; + [_del parser: self parseErrorOccurred: this->error]; // pass error return NO; } -/* Go up the namespace stack looking for a mapping from p to - * a URI. Return the first URI found (or nil if none is found). - */ -- (NSString*) _uriForPrefix: (NSString*)p -{ - unsigned i = [this->namespaces count]; - NSString *uri = nil; - - while (uri == nil && i-- > 0) - { - id o = [this->namespaces objectAtIndex: i]; - - if (o != (id)null) - { - uri = [(NSDictionary*)o objectForKey: p]; - } - } - return uri; -} - -- (void) _closeLastTag -{ - NSString *tag = [this->tagPath lastObject]; - - if (this->didEndElement != 0) - { - NSString *qualified = nil; - NSString *uri = nil; - - if (this->shouldProcessNamespaces) - { - NSRange r = [tag rangeOfString: @":"]; - NSString *p = @""; - - qualified = tag; - if (r.length > 0) - { - p = [tag substringToIndex: r.location]; - tag = [tag substringFromIndex: NSMaxRange(r)]; - } - uri = [self _uriForPrefix: p]; - } - (*this->didEndElement)(_del, - didEndElementSel, self, tag, uri, qualified); - } - - if (this->shouldReportNamespacePrefixes) - { - if (this->didEndMappingPrefix != 0) - { - id d = [this->namespaces lastObject]; - - if (d != (id)null) - { - NSEnumerator *e = [(NSDictionary*)d keyEnumerator]; - NSString *k; - - while ((k = [e nextObject]) != nil) - { - (*this->didEndMappingPrefix)(_del, - didEndMappingPrefixSel, self, k); - } - } - } - } - - [this->tagPath removeLastObject]; - [this->namespaces removeLastObject]; -} - - (void) _processTag: (NSString *)tag isEnd: (BOOL)flag withAttributes: (NSDictionary *)attributes { if (this->acceptHTML) - { - tag = [tag lowercaseString]; // not case sensitive - } + tag = [tag lowercaseString]; // not case sensitive if (!flag) { if ([tag isEqualToString: @"?xml"]) { -#if EXTRA_DEBUG +#if 0 NSLog(@"parserDidStartDocument: "); #endif if ([_del respondsToSelector: @selector(parserDidStartDocument:)]) - { - [_del parserDidStartDocument: self]; - } + [_del parserDidStartDocument: self]; return; } - else if ([tag hasPrefix: @"?"]) + if ([tag hasPrefix: @"?"]) { -#if EXTRA_DEBUG +#if 0 NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); #endif // parser: foundProcessingInstructionWithTarget: data: return; } - else if ([tag isEqualToString: @"!DOCTYPE"]) + if ([tag isEqualToString: @"!DOCTYPE"]) { -#if EXTRA_DEBUG +#if 0 NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); #endif return; } - else if ([tag isEqualToString: @"!ENTITY"]) + if ([tag isEqualToString: @"!ENTITY"]) { -#if EXTRA_DEBUG +#if 0 NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); #endif return; } - else - { - NSMutableDictionary *ns = nil; - NSMutableDictionary *attr = nil; - NSEnumerator *enumerator = [attributes keyEnumerator]; - NSString *k; - NSString *uri; - NSString *qualified; - - while ((k = [enumerator nextObject]) != nil) - { - NSString *prefix = nil; - - if ([k isEqualToString: @"xmlns"] == YES) - { - prefix = @""; - } - else if ([k hasPrefix: @"xmlns:"] == YES) - { - prefix = [k substringFromIndex: 6]; - } - if (prefix != nil) - { - if (ns == nil) - { - ns = [NSMutableDictionary new]; - if (this->shouldProcessNamespaces) - { - attr = [attributes mutableCopy]; - } - } - uri = [attributes objectForKey: k]; - [ns setObject: uri forKey: prefix]; - if (attr != nil) - { - [attr removeObjectForKey: k]; - } - if (this->shouldReportNamespacePrefixes) - { - if (this->didStartMappingPrefix != 0) - { - (*this->didStartMappingPrefix)(_del, - didStartMappingPrefixSel, self, prefix, uri); - } - } - if (attr != nil) - { - attributes = attr; - } - } - } - - [this->tagPath addObject: tag]; - [this->namespaces addObject: ((ns == nil) ? (id)null : (id)ns)]; - - if (this->didStartElement != 0) - { - if (this->shouldProcessNamespaces) - { - NSRange r = [tag rangeOfString: @":"]; - NSString *p = @""; - - qualified = tag; - if (r.length > 0) - { - p = [tag substringToIndex: r.location]; - tag = [tag substringFromIndex: NSMaxRange(r)]; - } - uri = [self _uriForPrefix: p]; - } - else - { - qualified = nil; - uri = nil; - } - (*this->didStartElement)(_del, - didStartElementSel, self, tag, uri, qualified, attributes); - } - if (ns != nil) [ns release]; - if (attr != nil) [attr release]; - } + if ([tag isEqualToString: @"!CDATA"]) + { + // pass through as NSData + // parser: foundCDATA: +#if 0 +NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); +#endif + return; + } + [this->tagPath addObject: tag]; // push on stack + if ([_del respondsToSelector: + @selector(parser:didStartElement:namespaceURI:qualifiedName:attributes:)]) + [_del parser: self + didStartElement: tag + namespaceURI: nil + qualifiedName: nil + attributes: attributes]; } else { - // closing tag +// closing tag if (this->acceptHTML) { // lazily close any missing tags on stack while ([this->tagPath count] > 0 && ![[this->tagPath lastObject] isEqualToString: tag]) { - [self _closeLastTag]; + if ([_del respondsToSelector: + @selector(parser:didEndElement:namespaceURI:qualifiedName:)]) + [_del parser: self + didEndElement: [this->tagPath lastObject] + namespaceURI: nil + qualifiedName: nil]; + [this->tagPath removeLastObject]; // pop from stack } if ([this->tagPath count] == 0) - { - return; // ignore closing tag without matching open... - } + return; // ignore closing tag without matching open... } else if (![[this->tagPath lastObject] isEqualToString: tag]) { [self _parseError: [NSString stringWithFormat: @"tag nesting error ( expected, found)", - [this->tagPath lastObject], tag] - code: NSXMLParserNotWellBalancedError]; + [this->tagPath lastObject], tag]]; return; } - [self _closeLastTag]; + if ([_del respondsToSelector: + @selector(parser:didEndElement:namespaceURI:qualifiedName:)]) + [_del parser: self + didEndElement: tag + namespaceURI: nil + qualifiedName: nil]; + [this->tagPath removeLastObject]; // pop from stack } } -- (BOOL) _parseEntity: (NSString**)result +- (NSString *) _entity { +// parse &xxx; sequence int c; const unsigned char *ep = this->cp; // should be position behind & int len; @@ -1132,125 +688,76 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); } while (c != EOF && c != '<' && c != ';'); if (c != ';') - { - // invalid sequence - end of file or missing ; before next tag - return NO; - } + return nil; // invalid sequence - end of file or missing ; before next tag len = this->cp - ep - 1; - if (*ep == '#') { - // &#ddd; or &#xhh; +// &#ddd; or &#xhh; // !!! ep+1 is not 0-terminated - but by ;!! - if (sscanf((char *)ep+1, "x%x;", &val)) - { - // &#xhh; hex value - if (result != 0) - { - *result = [[NSString alloc] initWithFormat: @"%C", val]; - } - return YES; - } - else if (sscanf((char *)ep+1, "%d;", &val)) - { - // &ddd; decimal value - if (result != 0) - { - *result = [[NSString alloc] initWithFormat: @"%C", val]; - } - return YES; - } + if (sscanf((char *)ep+1, "x%x;", &val)) + return [NSString stringWithFormat: @"%C", val]; // &#xhh; hex value + else if (sscanf((char *)ep+1, "%d;", &val)) + return [NSString stringWithFormat: @"%C", val]; // &ddd; decimal value } else { - // the five predefined entities - if (len == 3 && strncmp((char *)ep, "amp", len) == 0) - { - if (result != 0) *result = @"&"; - return YES; - } - else if (len == 2 && strncmp((char *)ep, "lt", len) == 0) - { - if (result != 0) *result = @"<"; - return YES; - } - else if (len == 2 && strncmp((char *)ep, "gt", len) == 0) - { - if (result != 0) *result = @">"; - return YES; - } - else if (len == 4 && strncmp((char *)ep, "quot", len) == 0) - { - if (result != 0) *result = @"\""; - return YES; - } - else if (len == 4 && strncmp((char *)ep, "apos", len) == 0) - { - if (result != 0) *result = @"'"; - return YES; - } +// the five predefined entities + if (len == 3 && strncmp((char *)ep, "amp", len) == 0) + return @"&"; + if (len == 2 && strncmp((char *)ep, "lt", len) == 0) + return @"<"; + if (len == 2 && strncmp((char *)ep, "gt", len) == 0) + return @">"; + if (len == 4 && strncmp((char *)ep, "quot", len) == 0) + return @"\""; + if (len == 4 && strncmp((char *)ep, "apos", len) == 0) + return @"'"; } - entity = NewUTF8STR(ep, len); - + entity = UTF8STR(ep, len); #if 1 NSLog(@"NSXMLParser: unrecognized entity: &%@;", entity); #endif // entity=[entitiesTable objectForKey: entity]; // look up string in entity translation table - - if (entity == nil) - { - entity = @"&??;"; // unknown entity - } - if (result != 0) - { - *result = entity; - } - return YES; + if (!entity) + entity=@"&??;"; // unknown entity + return entity; } -- (NSString *) _newQarg +- (NSString *) _qarg { // get argument (might be quoted) const unsigned char *ap = --this->cp; // argument start pointer int c = cget(); // refetch first character -#if EXTRA_DEBUG - NSLog(@"_newQarg: %02x %c", c, isprint(c)?c: ' '); +#if 0 + NSLog(@"_qarg: %02x %c", c, isprint(c)?c: ' '); #endif if (c == '\"') { - do - { - c = cget(); - if (c == EOF) - { - return nil; // unterminated! - } - } - while (c != '\"'); - return NewUTF8STR(ap + 1, this->cp - ap - 2); +// quoted argument + do { + c = cget(); + if (c == EOF) + return nil; // unterminated! + } while (c != '\"'); + return UTF8STR(ap + 1, this->cp - ap - 2); } if (c == '\'') { - do - { - c = cget(); - if (c == EOF) - { - return nil; // unterminated! - } - } - while (c != '\''); - return NewUTF8STR(ap + 1, this->cp - ap - 2); +// apostrophed argument + do { + c = cget(); + if (c == EOF) + return nil; // unterminated! + } while (c != '\''); + return UTF8STR(ap + 1, this->cp - ap - 2); } - /* strict XML requires quoting (?) if (!this->acceptHTML) - ; - */ + ; // strict XML requires quoting (?) while (!isspace(c) && c != '>' && c != '/' && c != '?' && c != '=' &&c != EOF) c = cget(); this->cp--; // go back to terminating character - return NewUTF8STR(ap, this->cp - ap); + return UTF8STR(ap, this->cp - ap); } - (BOOL) parse @@ -1264,364 +771,170 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); || strncmp((char *)this->cp, " preamble" - code: NSXMLParserDocumentStartError]; + return [self _parseError: @"missing preamble"]; } - /* Start by accumulating ignorable whitespace. - */ - this->ignorable = YES; - this->whitespace = YES; c = cget(); // get first character while (!this->abort) { -#if EXTRA_DEBUG +// parse next element +#if 0 NSLog(@"_nextelement %02x %c", c, isprint(c)?c: ' '); #endif - switch(c) + switch(c) + { + case '\r': + this->column = 0; + break; + case '\n': + this->line++; + this->column = 0; + case EOF: + case '<': + case '&': { - case '\r': - this->column = 0; - break; - - case '\n': - this->line++; - this->column = 0; - break; - - case '<': - /* Whitespace immediately before an element is always ignorable. - */ - this->ignorable = YES; /* Fall through to push out data */ - case EOF: - case '&': - { - /* push out any characters that have been collected so far - */ - if (this->cp - vp > 1) - { - const unsigned char *p; - NSString *s; - - p = this->cp - 1; - if (YES == this->ignorable) - { - if (YES == this->whitespace) - { - p = vp; // all whitespace - } - else - { - /* step through trailing whitespace (if any) - */ - while (p > vp && isspace(p[-1])) - { - p--; - } - } - } - if (p - vp > 0 && this->foundCharacters != 0) - { - /* Process initial data as characters - */ - s = NewUTF8STR(vp, p - vp); - (*this->foundCharacters)(_del, - foundCharactersSel, self, s); - [s release]; - } - if (p < this->cp - 1 && this->foundIgnorable != 0) - { - /* Process data as ignorable whitespace - */ - s = NewUTF8STR(p, this->cp - p - 1); - (*this->foundIgnorable)(_del, - foundIgnorableSel, self, s); - [s release]; - } - vp = this->cp; - } - } +// push out any characters that have been collected so far + if (this->cp - vp > 1) + { + // check for whitespace only - might set/reset a flag to indicate so + if ([_del respondsToSelector: @selector(parser: foundCharacters: )]) + [_del parser: self foundCharacters: UTF8STR(vp, this->cp - vp - 1)]; + vp = this->cp; + } } - - switch(c) + } + switch(c) + { + default: + c = cget(); // just collect until we push out (again) + continue; + case EOF: // end of file { - default: - if (YES == this->whitespace && !isspace(c)) - { - if (YES == this->ignorable && this->cp - vp > 1) - { - /* We have accumulated ignorable whitespace ... - * push it out. - */ - if (this->foundIgnorable != 0) - { - NSString *s; - - s = NewUTF8STR(vp, this->cp - vp - 1); - (*this->foundIgnorable)(_del, - foundIgnorableSel, self, s); - [s release]; - } - vp = this->cp - 1; - } - /* We have read non-space data, so whitespace is no longer - * ignorable, and the buffer no loinger contains only space. - */ - this->ignorable = NO; - this->whitespace = NO; - } - c = cget(); // just collect until we push out (again) + if ([this->tagPath count] != 0) + { + if (!this->acceptHTML) + return [self _parseError: @"unexpected end of file"]; // strict XML nesting error + while ([this->tagPath count] > 0) + { +// lazily close all open tags + if ([_del respondsToSelector: @selector(parser: didEndElement: namespaceURI: qualifiedName: )]) + [_del parser: self didEndElement: [this->tagPath lastObject] namespaceURI: nil qualifiedName: nil]; + [this->tagPath removeLastObject]; // pop from stack + } + } +#if 0 + NSLog(@"parserDidEndDocument: "); +#endif + + if ([_del respondsToSelector: @selector(parserDidEndDocument: )]) + [_del parserDidEndDocument: self]; + return YES; + } + case '&': + { +// escape entity begins + NSString *entity=[self _entity]; + if (!entity) + return [self _parseError: @"empty entity name"]; + if ([_del respondsToSelector: @selector(parser: foundCharacters: )]) + [_del parser: self foundCharacters: entity]; + vp = this->cp; // next value sequence starts here + c = cget(); // first character behind ; + continue; + } + case '<': + { +// tag begins + NSString *tag; + NSMutableDictionary *parameters; + NSString *arg; + const unsigned char *tp = this->cp; // tag pointer + if (this->cp < this->cend-3 && strncmp((char *)this->cp, "!--", 3) == 0) + { +// start of comment skip all characters until "-->" + this->cp+=3; + while (this->cp < this->cend-3 && strncmp((char *)this->cp, "-->", 3) != 0) + this->cp++; // search + // if _del responds to parser: foundComment: + // convert to string (tp+4 ... cp) + this->cp+=3; // might go beyond cend but does not care + vp = this->cp; // value might continue + c = cget(); // get first character behind comment continue; - - case EOF: - { - if ([this->tagPath count] != 0) - { - if (!this->acceptHTML) - { - /* strict XML nesting error - */ - return [self _parseError: @"unexpected end of file" - code: NSXMLParserNotWellBalancedError]; - } - while ([this->tagPath count] > 0) - { - // lazily close all open tags - if (this->didEndElement != 0) - { - (*this->didEndElement)(_del, - didEndElementSel, self, - [this->tagPath lastObject], nil, nil); - } - [this->tagPath removeLastObject]; // pop from stack - } - } -#if EXTRA_DEBUG - NSLog(@"parserDidEndDocument: "); -#endif - - if ([_del respondsToSelector: @selector(parserDidEndDocument: )]) - { - [_del parserDidEndDocument: self]; - } - return YES; } - - case '&': + c = cget(); // get first character of tag + if (c == '/') + c = cget(); // closing tag ignorable = NO; - this->whitespace = YES; - - if ([self _parseEntity: &entity] == NO) - { - return [self _parseError: @"empty entity name" - code: NSXMLParserEntityRefAtEOFError]; - } - if (this->foundCharacters != 0) - { - (*this->foundCharacters)(_del, - foundCharactersSel, self, entity); - } - [entity release]; - vp = this->cp; // next value sequence starts here - c = cget(); // first character behind ; - continue; +// special tag should process this tag in a special way so that e.g. is read as a single tag! + // to do this properly, we need a notion of comments and quoted string constants... } - - case '<': + while (!isspace(c) && c != '>' && (c != '/') && (c != '?')) + c = cget(); // scan tag until we find a delimiting character + if (*tp == '/') + tag = UTF8STR(tp + 1, this->cp - tp - 2); // don't include / and delimiting character + else + tag = UTF8STR(tp, this->cp - tp - 1); // don't include delimiting character +#if 0 + NSLog(@"tag=%@ - %02x %c", tag, c, isprint(c)?c: ' '); +#endif + parameters=[NSMutableDictionary dictionaryWithCapacity: 5]; + while (c != EOF) { - NSString *tag; - NSMutableDictionary *parameters; - NSString *arg; - const unsigned char *tp = this->cp; // tag pointer - - /* After processing a tag, whitespace will be ignorable and - * we can start accumulating it in our buffer. - */ - this->ignorable = YES; - this->whitespace = YES; - - if (this->cp < this->cend-3 - && strncmp((char *)this->cp, "!--", 3) == 0) - { - /* start of comment skip all characters until "-->" - */ - this->cp += 3; - tp = this->cp; - while (this->cp < this->cend-3 - && strncmp((char *)this->cp, "-->", 3) != 0) - { - this->cp++; // search - } - if (this->foundComment != 0) - { - NSString *c = NewUTF8STR(tp, this->cp - tp); - - (*this->foundComment)(_del, - foundCommentSel, self, c); - [c release]; - } - this->cp += 3; // might go beyond cend ... ok - vp = this->cp; // value might continue - c = cget(); // get first character after comment - continue; - } - if (this->cp < this->cend-8 - && strncmp((char *)this->cp, "![CDATA[", 8) == 0) - { - /* start of CDATA skip all characters until "]>" - */ - this->cp += 8; - tp = this->cp; - while (this->cp < this->cend-3 - && strncmp((char *)this->cp, "]]>", 3) != 0) - { - this->cp++; // search - } - if (this->foundCDATA != 0) - { - NSData *d; - - d = [[NSData alloc] initWithBytes: tp - length: this->cp - tp]; - (*this->foundCDATA)(_del, - foundCDATASel, self, d); - [d release]; - } - this->cp += 3; // might go beyond cend ... ok - vp = this->cp; // value might continue - c = cget(); // get first character after CDATA - continue; - } - - c = cget(); // get first character of tag - if (c == '/') - { - c = cget(); // closing tag should process this tag in a special - * way so that e.g. is read - * as a single tag! - * to do this properly, we need a notion of comments - * and quoted string constants... - */ - } - - while (c != EOF && !isspace(c) - && c != '>' && c != '/' && c != '?') - { - c = cget(); // scan tag until we find a delimiting character - } - if (*tp == '/') - { - tag = NewUTF8STR(tp + 1, this->cp - tp - 2); - } - else - { - tag = NewUTF8STR(tp, this->cp - tp - 1); - } -#if EXTRA_DEBUG - NSLog(@"tag=%@ - %02x %c", tag, c, isprint(c)?c: ' '); +// collect arguments + if (c == '/' && *tp != '/') + { +// appears to be a /> + c = cget(); + if (c != '>') + return [self _parseError: @""]; + [self _processTag: tag isEnd: NO withAttributes: parameters]; // opening tag + [self _processTag: tag isEnd: YES withAttributes: nil]; // closing tag + break; // done + } + if (c == '?' && *tp == '?') + { +// appears to be a ?> + c = cget(); + if (c != '>') + return [self _parseError: @""]; + // process + [self _processTag: tag isEnd: NO withAttributes: parameters]; // single + break; // done + } + while (isspace(c)) // this->should also allow for line break and tab + c = cget(); + if (c == '>') + { + [self _processTag: tag isEnd: (*tp=='/') withAttributes: parameters]; // handle tag + break; + } + arg=[self _qarg]; // get next argument (eats up to /, ?, >, =, space) +#if 0 + NSLog(@"arg=%@", arg); #endif - parameters = [[NSMutableDictionary alloc] initWithCapacity: 5]; - while (isspace(c)) - { - c = cget(); - } - while (c != EOF) - { - if (c == '/' && *tp != '/') - { - // appears to be a /> - c = cget(); - if (c != '>') - { - return [self _parseError: @"" - code: NSXMLParserGTRequiredError]; - } - [self _processTag: tag - isEnd: NO - withAttributes: parameters]; - [self _processTag: tag isEnd: YES withAttributes: nil]; - break; - } - - if (c == '?' && *tp == '?') - { - // appears to be a ?> - c = cget(); - if (c != '>') - { - return [self _parseError: - @"" - code: NSXMLParserGTRequiredError]; - } - // process - [self _processTag: tag - isEnd: NO - withAttributes: parameters]; // single - break; // done - } - // this should also allow for line break and tab - while (isspace(c)) - { - c = cget(); - } - if (c == '>') - { - [self _processTag: tag - isEnd: (*tp == '/') - withAttributes: parameters]; - break; - } - /* get next argument (eats up to /, ?, >, =, space) - */ - arg = [self _newQarg]; -#if EXTRA_DEBUG - NSLog(@"arg=%@", arg); -#endif - if (!this->acceptHTML && [arg length] == 0) - { - return [self _parseError: @"empty attribute name" - code: NSXMLParserAttributeNotStartedError]; - } - c = cget(); // get delimiting character - if (c == '=') - { - NSString *val; - - // explicit assignment - c = cget(); // skip = - val = [self _newQarg]; - [parameters setObject: val forKey: arg]; - [val release]; - c = cget(); // get character behind qarg value - } - else // implicit - { - [parameters setObject: @"" forKey: arg]; - } - [arg release]; - } - [parameters release]; - [tag release]; - vp = this->cp; // prepare for next value - c = cget(); // skip > and fetch next character + if (!this->acceptHTML && [arg length] == 0) + return [self _parseError: @"empty attribute name"]; + c = cget(); // get delimiting character + if (c == '=') + { +// explicit assignment + c = cget(); // skip = + [parameters setObject: [self _qarg] forKey: arg]; + c = cget(); // get character behind qarg value + } + else // implicit + [parameters setObject: @"" forKey: arg]; } + vp = this->cp; // prepare for next value + c = cget(); // skip > and fetch next character } + } } - return [self _parseError: @"aborted" - code: NSXMLParserDelegateAbortedParseError]; + return [self _parseError: @"this->aborted"]; // this->aborted } - (BOOL) acceptsHTML @@ -1676,6 +989,8 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); @end +#endif + @implementation NSObject (NSXMLParserDelegateEventAdditions) - (NSData*) parser: (NSXMLParser*)aParser resolveExternalEntityName: (NSString*)aName diff --git a/Source/NSXMLPrivate.h b/Source/NSXMLPrivate.h deleted file mode 100644 index 908c70091..000000000 --- a/Source/NSXMLPrivate.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Private header for libxml2 wrapping components - Copyright (C) 2009 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Created: Februrary 2009 - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. -*/ - -#ifndef _INCLUDED_NSXMLPRIVATE_H -#define _INCLUDED_NSXMLPRIVATE_H - -#import "config.h" -#define EXPOSE_NSXMLDTD_IVARS 1 -#define EXPOSE_NSXMLDTDNode_IVARS 1 -#define EXPOSE_NSXMLDocument_IVARS 1 -#define EXPOSE_NSXMLElement_IVARS 1 -#define EXPOSE_NSXMLNode_IVARS 1 -#import "GNUstepBase/preface.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDebug.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSString.h" -#import "Foundation/NSURL.h" -#import "Foundation/NSXMLNode.h" -#import "Foundation/NSXMLDocument.h" -#import "Foundation/NSXMLDTDNode.h" -#import "Foundation/NSXMLDTD.h" -#import "Foundation/NSXMLElement.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" - -#ifdef HAVE_LIBXML - -/* Avoid problems on systems where the xml headers use 'id' - */ -#define id GSXMLID - -/* libxml headers */ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_LIBXSLT -#include -#include -#include -#include -#endif /* HAVE_LIBXSLT */ - -#undef id - -#endif /* HAVE_LIBXML */ - -#endif diff --git a/Source/NSZone.m b/Source/NSZone.m index e3958089b..ad79f6aaa 100644 --- a/Source/NSZone.m +++ b/Source/NSZone.m @@ -8,16 +8,16 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. This library 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 Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -86,13 +86,15 @@ #define IN_NSZONE_M 1 -#import "common.h" +#include "config.h" +#include "GNUstepBase/preface.h" #include #include -#import "Foundation/NSException.h" -#import "Foundation/NSLock.h" -#import "GSPrivate.h" -#import "GSPThread.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSException.h" +#include "Foundation/NSString.h" +#include "Foundation/NSZone.h" +#include "Foundation/NSLock.h" /** * Try to get more memory - the normal process has failed. @@ -100,375 +102,14 @@ * Try to do some logging if possible. */ void * -GSOutOfMemory(NSUInteger size, BOOL retry) +GSOutOfMemory(size_t size, BOOL retry) { fprintf(stderr, "GSOutOfMemory ... wanting %lu bytes.\n", (unsigned long)size); return 0; } -/* Default zone functions for default zone. */ -static void* default_malloc (NSZone *zone, size_t size); -static void* default_realloc (NSZone *zone, void *ptr, size_t size); -static void default_free (NSZone *zone, void *ptr); -static void default_recycle (NSZone *zone); -static BOOL default_check (NSZone *zone); -static BOOL default_lookup (NSZone *zone, void *ptr); -static struct NSZoneStats default_stats (NSZone *zone); - -static void* -default_malloc (NSZone *zone, size_t size) -{ - void *mem; - - mem = objc_malloc(size); - if (mem == NULL) - [NSException raise: NSMallocException - format: @"Default zone has run out of memory"]; - return mem; -} - -static void* -default_realloc (NSZone *zone, void *ptr, size_t size) -{ - void *mem; - - if (size == 0) - { - objc_free(ptr); - return NULL; - } - if (ptr == 0) - { - mem = objc_malloc(size); - if (mem == NULL) - [NSException raise: NSMallocException - format: @"Default zone has run out of memory"]; - return mem; - } - mem = objc_realloc(ptr, size); - if (mem == NULL) - [NSException raise: NSMallocException - format: @"Default zone has run out of memory"]; - return mem; -} - -static void -default_free (NSZone *zone, void *ptr) -{ - objc_free(ptr); -} - -static void -default_recycle (NSZone *zone) -{ - /* Recycle the default zone? Thou hast got to be kiddin'. */ - [NSException raise: NSGenericException - format: @"Trying to recycle default zone"]; -} - -static BOOL -default_check (NSZone *zone) -{ - /* We can't check memory managed by objc_malloc(). */ - [NSException raise: NSGenericException - format: @"No checking for default zone"]; - return NO; -} - -static BOOL -default_lookup (NSZone *zone, void *ptr) -{ - /* Assume all memory is in default zone. */ - return YES; -} - -static struct NSZoneStats -default_stats (NSZone *zone) -{ - struct NSZoneStats dummy = {0,0,0,0,0}; - - /* We can't obtain statistics from the memory managed by objc_malloc(). */ - [NSException raise: NSGenericException - format: @"No statistics for default zone"]; - return dummy; -} - -static NSZone default_zone = -{ - default_malloc, default_realloc, default_free, default_recycle, - default_check, default_lookup, default_stats, 0, @"default", 0 -}; - -/* - * For backward compatibility. - */ -NSZone *__nszone_private_hidden_default_zone = &default_zone; - - - -void -NSSetZoneName (NSZone *zone, NSString *name) -{ - if (!zone) - zone = NSDefaultMallocZone(); - [gnustep_global_lock lock]; - name = [name copy]; - if (zone->name != nil) - [zone->name release]; - zone->name = name; - [gnustep_global_lock unlock]; -} - -NSString* -NSZoneName (NSZone *zone) -{ - if (!zone) - zone = NSDefaultMallocZone(); - return zone->name; -} - -#if GS_WITH_GC - -#if defined(DEBUG) -#define GC_DEBUG 1 -#endif /* DEBUG */ - -#include - -/* - * Dummy zones used with garbage collection. - * The 'atomic' zone is for memory that will be assumed not to contain - * pointers for garbage collection purposes. - */ -static NSZone atomic_zone = -{ - 0, 0, 0, 0, 0, 0, 0, 0, @"default", 0 -}; - -void * -NSAllocateCollectable(NSUInteger size, NSUInteger options) -{ - void *ptr; - - if (options & NSScannedOption) - { - if (options & NSCollectorDisabledOption) - { - ptr = (void*)GC_MALLOC_UNCOLLECTABLE(size); - memset(ptr, '\0', size); - } - else - { - ptr = (void*)GC_MALLOC_IGNORE_OFF_PAGE(size); - memset(ptr, '\0', size); - } - } - else - { - if (options & NSCollectorDisabledOption) - { - ptr = (void*)calloc(1, size); - } - else - { - ptr = (void*)GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(size); - memset(ptr, '\0', size); - } - } - return ptr; -} - -void * -NSReallocateCollectable(void *ptr, NSUInteger size, NSUInteger options) -{ - if (ptr == 0) - { - ptr = NSAllocateCollectable(size, options); - } - else if (size > 0 && GC_base(ptr) == 0) - { - /* This is not collectable memory, so we don't know how big it is. - * that means we must use realloc first, to get a known size, and - * then, if needed, allocate a chunk the right size and copy to it. - */ - ptr = realloc(ptr, size); - if (ptr != 0) - { - if ((options & NSScannedOption) - || !(options & NSCollectorDisabledOption)) - { - void *tmp = NSAllocateCollectable(size, options); - - memcpy(tmp, ptr, size); - free(ptr); - ptr = tmp; - } - } - } - else - { - void *tmp = NSAllocateCollectable(size, options); - unsigned length = GC_size(ptr); - - if (length > size) - { - length = size; - } - if (tmp != 0 && length > 0) - { - memcpy(tmp, ptr, length); - } - GC_FREE(ptr); - ptr = tmp; - } - return ptr; -} - -NSZone* -NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree) -{ - NSLog(@" *** Creating a zone while running GC is ignored."); - return &default_zone; -} - -NSZone* -NSDefaultMallocZone (void) -{ - return &default_zone; -} - -NSZone* -GSAtomicMallocZone (void) -{ - return &atomic_zone; -} - -NSZone* -NSZoneFromPointer (void *ptr) -{ - return &default_zone; -} - -void -NSRecycleZone (NSZone *zone) -{ -} - -BOOL -NSZoneCheck (NSZone *zone) -{ - return YES; -} - -struct -NSZoneStats NSZoneStats (NSZone *zone) -{ - struct NSZoneStats stats = { 0 }; - return stats; -} - -void -GSMakeWeakPointer(Class theClass, const char *iVarName) -{ - class_ivar_set_gcinvisible(theClass, iVarName, YES); -} - -BOOL -GSAssignZeroingWeakPointer(void **destination, void *source) -{ - if (destination == 0) - { - return NO; // Bad destination pointer - } - if (*destination == source) - { - return YES; // Already assigned. - } - if (source != 0 && GC_base(source) == 0) - { - return NO; // Source is not garbage collectable. - } - if (*destination != 0) - { - GC_unregister_disappearing_link(destination); - } - *destination = source; - if (source != 0) - { - GC_general_register_disappearing_link(destination, source); - } - return YES; -} - -void* -NSZoneMalloc (NSZone *zone, NSUInteger size) -{ - return NSZoneCalloc(zone, 1, size); -} - -void* -NSZoneCalloc (NSZone *zone, NSUInteger elems, NSUInteger bytes) -{ - size_t size = elems * bytes; - void *ptr; - - if (zone == &atomic_zone) - { - ptr = (void*)GC_MALLOC_ATOMIC(size); - memset(ptr, '\0', size); - } - else - { - ptr = (void*)malloc(size); - if (ptr == 0) - { - ptr = GSOutOfMemory(size, NO); - } - if (ptr != 0) - { - memset(ptr, '\0', size); - } - } - return ptr; -} - -void* -NSZoneRealloc (NSZone *zone, void *ptr, NSUInteger size) -{ - if (GC_base(ptr) != 0) - { - ptr = GC_REALLOC(ptr, size); - } - else - { - ptr = realloc(ptr, size); - } - return ptr; -} - -void -NSZoneFree (NSZone *zone, void *ptr) -{ - if (GC_base(ptr) != 0) - { - GC_FREE(ptr); - } - else - { - free(ptr); - } -} - -BOOL -GSPrivateIsCollectable(const void *ptr) -{ - if (GC_base((void*)ptr) == 0) return NO; - else return YES; -} - -#else /* GS_WITH_GC */ - +#if GS_WITH_GC == 0 /* Alignment */ #ifdef ALIGN @@ -552,7 +193,7 @@ struct _ffree_free_link struct _ffree_zone_struct { NSZone common; - pthread_mutex_t lock; + objc_mutex_t lock; ff_block *blocks; // Linked list of blocks ff_link *segheadlist[MAX_SEG]; // Segregated list, holds heads ff_link *segtaillist[MAX_SEG]; // Segregated list, holds tails @@ -707,13 +348,24 @@ chunkPrev(ff_block *ptr) struct _nfree_zone_struct { NSZone common; - pthread_mutex_t lock; + objc_mutex_t lock; /* Linked list of blocks in decreasing order of free space, except maybe for the first block. */ nf_block *blocks; size_t use; }; + + +/* Default zone functions for default zone. */ +static void* default_malloc (NSZone *zone, size_t size); +static void* default_realloc (NSZone *zone, void *ptr, size_t size); +static void default_free (NSZone *zone, void *ptr); +static void default_recycle (NSZone *zone); +static BOOL default_check (NSZone *zone); +static BOOL default_lookup (NSZone *zone, void *ptr); +static struct NSZoneStats default_stats (NSZone *zone); + /* Memory management functions for freeable zones. */ static void* fmalloc (NSZone *zone, size_t size); static void* frealloc (NSZone *zone, void *ptr, size_t size); @@ -746,11 +398,49 @@ static void* rrealloc (NSZone *zone, void *ptr, size_t size); static void rffree (NSZone *zone, void *ptr); static void rnfree (NSZone *zone, void *ptr); + +static NSZone default_zone = +{ + default_malloc, default_realloc, default_free, default_recycle, + default_check, default_lookup, default_stats, DEFBLOCK, @"default", 0 +}; + +/* Default zone. Name is hopelessly long so that no one will ever + want to use it. ;) */ +NSZone* __nszone_private_hidden_default_zone = &default_zone; + /* * Lists of zones to be used to determine if a pointer is in a zone. */ static NSZone *zone_list = 0; +/** + * Searches and finds the zone ptr was allocated from. The speed depends + * upon the number of zones and their size. + */ +GS_DECLARE NSZone* +NSZoneFromPointer(void *ptr) +{ + NSZone *zone; + + if (ptr == 0) return 0; + if (zone_list == 0) return __nszone_private_hidden_default_zone; + + /* + * See if we can find the zone in our list of all zones. + */ + [gnustep_global_lock lock]; + for (zone = zone_list; zone != 0; zone = zone->next) + { + if ((zone->lookup)(zone, ptr) == YES) + { + break; + } + } + [gnustep_global_lock unlock]; + return (zone == 0) ? __nszone_private_hidden_default_zone : zone; +} + static inline void destroy_zone(NSZone* zone) { @@ -768,6 +458,84 @@ destroy_zone(NSZone* zone) objc_free((void*)zone); } +static void* +default_malloc (NSZone *zone, size_t size) +{ + void *mem; + + mem = objc_malloc(size); + if (mem == NULL) + [NSException raise: NSMallocException + format: @"Default zone has run out of memory"]; + return mem; +} + +static void* +default_realloc (NSZone *zone, void *ptr, size_t size) +{ + void *mem; + + if (size == 0) + { + objc_free(ptr); + return NULL; + } + if (ptr == 0) + { + mem = objc_malloc(size); + if (mem == NULL) + [NSException raise: NSMallocException + format: @"Default zone has run out of memory"]; + return mem; + } + mem = objc_realloc(ptr, size); + if (mem == NULL) + [NSException raise: NSMallocException + format: @"Default zone has run out of memory"]; + return mem; +} + +static void +default_free (NSZone *zone, void *ptr) +{ + objc_free(ptr); +} + +static void +default_recycle (NSZone *zone) +{ + /* Recycle the default zone? Thou hast got to be kiddin'. */ + [NSException raise: NSGenericException + format: @"Trying to recycle default zone"]; +} + +static BOOL +default_check (NSZone *zone) +{ + /* We can't check memory managed by objc_malloc(). */ + [NSException raise: NSGenericException + format: @"No checking for default zone"]; + return NO; +} + +static BOOL +default_lookup (NSZone *zone, void *ptr) +{ + /* Assume all memory is in default zone. */ + return YES; +} + +static struct NSZoneStats +default_stats (NSZone *zone) +{ + struct NSZoneStats dummy = {0,0,0,0,0}; + + /* We can't obtain statistics from the memory managed by objc_malloc(). */ + [NSException raise: NSGenericException + format: @"No statistics for default zone"]; + return dummy; +} + /* Search the buffer to see if there is any memory chunks large enough to satisfy request using first fit. If the memory chunk found has a size exactly equal to the one requested, remove it from the buffer @@ -788,7 +556,7 @@ fmalloc (NSZone *zone, size_t size) ff_block *chunkhead; void *result; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); bufsize = zptr->bufsize; while ((i < bufsize) && (chunksize > size_buf[i])) i++; @@ -827,7 +595,7 @@ fmalloc (NSZone *zone, size_t size) chunkhead = get_chunk(zptr, chunksize); if (chunkhead == NULL) { - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); if (zone->name != nil) [NSException raise: NSMallocException format: @"Zone %@ has run out of memory", zone->name]; @@ -846,7 +614,7 @@ fmalloc (NSZone *zone, size_t size) *((char*)chunkhead->next) = (char)42; chunkSetLive(chunkhead); result = chunkToPointer(chunkhead); - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return result; } @@ -870,7 +638,7 @@ frealloc (NSZone *zone, void *ptr, size_t size) if (ptr == NULL) return fmalloc(zone, size); chunkhead = pointerToChunk(ptr); - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); realsize = chunkSize(chunkhead); NSAssert(chunkIsInUse(chunkhead), NSInternalInconsistencyException); @@ -926,7 +694,7 @@ frealloc (NSZone *zone, void *ptr, size_t size) newchunk = get_chunk(zptr, chunksize); if (newchunk == NULL) { - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); if (zone->name != nil) [NSException raise: NSMallocException format: @"Zone %@ has run out of memory", @@ -944,7 +712,7 @@ frealloc (NSZone *zone, void *ptr, size_t size) *((char*)chunkhead->next) = (char)42; chunkSetLive(chunkhead); result = chunkToPointer(chunkhead); - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return result; } @@ -954,14 +722,14 @@ ffree (NSZone *zone, void *ptr) { ff_block *chunk; NSAssert(NSZoneFromPointer(ptr) == zone, NSInternalInconsistencyException); - pthread_mutex_lock(&(((ffree_zone*)zone)->lock)); + objc_mutex_lock(((ffree_zone*)zone)->lock); chunk = pointerToChunk(ptr); if (chunkIsLive(chunk) == 0) [NSException raise: NSMallocException format: @"Attempt to free freed memory"]; NSAssert(*((char*)chunk->next) == (char)42, NSInternalInconsistencyException); add_buf((ffree_zone*)zone, chunk); - pthread_mutex_unlock(&(((ffree_zone*)zone)->lock)); + objc_mutex_unlock(((ffree_zone*)zone)->lock); } static BOOL @@ -971,7 +739,7 @@ frecycle1(NSZone *zone) ff_block *block; ff_block *nextblock; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); flush_buf(zptr); block = zptr->blocks; while (block != NULL) @@ -993,10 +761,10 @@ frecycle1(NSZone *zone) } block = nextblock; } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); if (zptr->blocks == 0) { - pthread_mutex_destroy(&(zptr->lock)); + objc_mutex_deallocate(zptr->lock); return YES; } return NO; @@ -1045,7 +813,7 @@ fcheck (NSZone *zone) ffree_zone *zptr = (ffree_zone*)zone; ff_block *block; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); /* Check integrity of each block the zone owns. */ block = zptr->blocks; while (block != NULL) @@ -1138,11 +906,11 @@ fcheck (NSZone *zone) if ((zptr->size_buf[i] != chunkSize(chunk)) || !chunkIsInUse(chunk)) goto inconsistent; } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return YES; inconsistent: // Jump here if an inconsistency was found. - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return NO; } @@ -1153,7 +921,7 @@ flookup (NSZone *zone, void *ptr) ff_block *block; BOOL found = NO; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); for (block = zptr->blocks; block != NULL; block = block->next) { if (ptr >= (void*)block && ptr < (void*)chunkNext(block)) @@ -1162,7 +930,7 @@ flookup (NSZone *zone, void *ptr) break; } } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return found; } @@ -1181,7 +949,7 @@ fstats (NSZone *zone) stats.bytes_used = 0; stats.chunks_free = 0; stats.bytes_free = 0; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); block = zptr->blocks; /* Go through each block. */ while (block != NULL) @@ -1216,7 +984,7 @@ fstats (NSZone *zone) stats.bytes_used -= zptr->size_buf[i]; stats.bytes_free += zptr->size_buf[i]; } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); /* Remove overhead. */ stats.bytes_used -= FBSZ*stats.chunks_used; return stats; @@ -1537,7 +1305,7 @@ nmalloc (NSZone *zone, size_t size) nf_block *block; size_t top; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); block = zptr->blocks; top = block->top; freesize = block->size-top; @@ -1572,7 +1340,7 @@ nmalloc (NSZone *zone, size_t size) block = objc_malloc(blocksize); if (block == NULL) { - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); if (zone->name != nil) [NSException raise: NSMallocException format: @"Zone %@ has run out of memory", @@ -1590,7 +1358,7 @@ nmalloc (NSZone *zone, size_t size) block->top += chunksize; } zptr->use++; - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return chunkhead; } @@ -1601,7 +1369,7 @@ nrecycle1 (NSZone *zone) { nfree_zone *zptr = (nfree_zone*)zone; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); if (zptr->use == 0) { nf_block *nextblock; @@ -1615,10 +1383,10 @@ nrecycle1 (NSZone *zone) } zptr->blocks = 0; } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); if (zptr->blocks == 0) { - pthread_mutex_destroy(&(zptr->lock)); + objc_mutex_deallocate(zptr->lock); return YES; } return NO; @@ -1655,7 +1423,7 @@ nrealloc (NSZone *zone, void *ptr, size_t size) if (ptr != 0) { - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); if (tmp) { nf_block *block; @@ -1675,7 +1443,7 @@ nrealloc (NSZone *zone, void *ptr, size_t size) } } zptr->use--; - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); } return tmp; } @@ -1691,9 +1459,9 @@ nfree (NSZone *zone, void *ptr) { nfree_zone *zptr = (nfree_zone*)zone; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); zptr->use--; - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); } static void @@ -1719,19 +1487,19 @@ ncheck (NSZone *zone) nfree_zone *zptr = (nfree_zone*)zone; nf_block *block; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); block = zptr->blocks; while (block != NULL) { if (block->size < block->top) { - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return NO; } block = block->next; } /* FIXME: Do more checking? */ - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return YES; } @@ -1742,7 +1510,7 @@ nlookup (NSZone *zone, void *ptr) nf_block *block; BOOL found = NO; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); for (block = zptr->blocks; block != NULL; block = block->next) { if (ptr >= (void*)block && ptr < ((void*)block)+block->size) @@ -1751,7 +1519,7 @@ nlookup (NSZone *zone, void *ptr) break; } } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return found; } @@ -1769,7 +1537,7 @@ nstats (NSZone *zone) stats.bytes_used = 0; stats.chunks_free = 0; stats.bytes_free = 0; - pthread_mutex_lock(&(zptr->lock)); + objc_mutex_lock(zptr->lock); block = zptr->blocks; while (block != NULL) { @@ -1790,7 +1558,7 @@ nstats (NSZone *zone) } block = block->next; } - pthread_mutex_unlock(&(zptr->lock)); + objc_mutex_unlock(zptr->lock); return stats; } @@ -1820,31 +1588,16 @@ rrealloc (NSZone *zone, void *ptr, size_t size) static void rnfree (NSZone *zone, void *ptr); -GS_DECLARE NSZone* -NSZoneFromPointer(void *ptr) -{ - NSZone *zone; - - if (ptr == 0) return 0; - if (zone_list == 0) return &default_zone; - - /* - * See if we can find the zone in our list of all zones. - */ - [gnustep_global_lock lock]; - for (zone = zone_list; zone != 0; zone = zone->next) - { - if ((zone->lookup)(zone, ptr) == YES) - { - break; - } - } - [gnustep_global_lock unlock]; - return (zone == 0) ? &default_zone : zone; -} - +/** + * Creates a new zone of start bytes, which will grow and shrink by + * granularity bytes. If canFree is 0, memory in zone is allocated but + * never freed, meaning allocation will be very fast. The whole zone can + * still be freed with NSRecycleZone(), and you should still call NSZoneFree + * on memory in the zone that is no longer needed, since a count of allocated + * pointers is kept and must reach zero before freeing the zone. + */ NSZone* -NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree) +NSCreateZone (size_t start, size_t gran, BOOL canFree) { size_t i, startsize, granularity; NSZone *newZone; @@ -1877,7 +1630,7 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree) zone->common.stats = fstats; zone->common.gran = granularity; zone->common.name = nil; - GS_INIT_RECURSIVE_MUTEX(zone->lock); + zone->lock = objc_mutex_allocate(); for (i = 0; i < MAX_SEG; i++) { zone->segheadlist[i] = NULL; @@ -1887,7 +1640,7 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree) zone->blocks = objc_malloc(startsize + 2*FBSZ); if (zone->blocks == NULL) { - pthread_mutex_destroy(&(zone->lock)); + objc_mutex_deallocate(zone->lock); objc_free(zone); [NSException raise: NSMallocException format: @"No memory to create zone"]; @@ -1932,12 +1685,12 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree) zone->common.stats = nstats; zone->common.gran = granularity; zone->common.name = nil; - GS_INIT_RECURSIVE_MUTEX(zone->lock); + zone->lock = objc_mutex_allocate(); zone->blocks = objc_malloc(startsize); zone->use = 0; if (zone->blocks == NULL) { - pthread_mutex_destroy(&(zone->lock)); + objc_mutex_deallocate(zone->lock); objc_free(zone); [NSException raise: NSMallocException format: @"No memory to create zone"]; @@ -1958,105 +1711,55 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree) return newZone; } +/** + * Allocates and returns cleared memory for elems items of size bytes, in the + * given zone. Returns NULL if allocation of size 0 requested. Raises + * NSMallocException if not enough free memory in zone to + * allocate and no more can be obtained from system. + */ void* -NSZoneCalloc (NSZone *zone, NSUInteger elems, NSUInteger bytes) +NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes) { return memset(NSZoneMalloc(zone, elems*bytes), 0, elems*bytes); } -void * -NSAllocateCollectable(NSUInteger size, NSUInteger options) -{ - return NSZoneCalloc(NSDefaultMallocZone(), 1, size); -} - -void * -NSReallocateCollectable(void *ptr, NSUInteger size, NSUInteger options) -{ - return NSZoneRealloc(0, ptr, size); -} - -NSZone* -NSDefaultMallocZone (void) -{ - return &default_zone; -} - -NSZone* -GSAtomicMallocZone (void) -{ - return &default_zone; -} - +/** + * Sets name of the given zone (useful for debugging and logging). + */ void -GSMakeWeakPointer(Class theClass, const char *iVarName) -{ - return; -} - -BOOL -GSAssignZeroingWeakPointer(void **destination, void *source) -{ - if (destination == 0) - { - return NO; - } - *destination = source; - return YES; -} - -void* -NSZoneMalloc (NSZone *zone, NSUInteger size) +NSSetZoneName (NSZone *zone, NSString *name) { if (!zone) zone = NSDefaultMallocZone(); - return (zone->malloc)(zone, size); + [gnustep_global_lock lock]; + name = [name copy]; + if (zone->name != nil) + [zone->name release]; + zone->name = name; + [gnustep_global_lock unlock]; } -void* -NSZoneRealloc (NSZone *zone, void *ptr, NSUInteger size) -{ - if (!zone) - zone = NSDefaultMallocZone(); - return (zone->realloc)(zone, ptr, size); -} +#else -void -NSRecycleZone (NSZone *zone) -{ - if (!zone) - zone = NSDefaultMallocZone(); - (zone->recycle)(zone); -} +#include -void -NSZoneFree (NSZone *zone, void *ptr) +/* + * Dummy zones used with garbage collection. + * The 'atomic' zone is for memory that will be assumed not to contain + * pointers for garbage collection purposes. + */ +static NSZone default_zone = { - if (!zone) - zone = NSDefaultMallocZone(); - (zone->free)(zone, ptr); -} + 0, 0, 0, 0, 0, 0, 0, 0, @"default", 0 +}; +NSZone* __nszone_private_hidden_default_zone = &default_zone; -BOOL -NSZoneCheck (NSZone *zone) +static NSZone atomic_zone = { - if (!zone) - zone = NSDefaultMallocZone(); - return (zone->check)(zone); -} + 0, 0, 0, 0, 0, 0, 0, 0, @"default", 0 +}; +NSZone* __nszone_private_hidden_atomic_zone = &atomic_zone; -struct NSZoneStats -NSZoneStats (NSZone *zone) -{ - if (!zone) - zone = NSDefaultMallocZone(); - return (zone->stats)(zone); -} - -BOOL -GSPrivateIsCollectable(const void *ptr) -{ - return NO; -} #endif /* GS_WITH_GC */ + diff --git a/Source/ObjectiveC2/GNUmakefile b/Source/ObjectiveC2/GNUmakefile index ef9a8d233..5ebbe1290 100644 --- a/Source/ObjectiveC2/GNUmakefile +++ b/Source/ObjectiveC2/GNUmakefile @@ -31,29 +31,34 @@ include ../../config.mak SUBPROJECT_NAME = ObjectiveC2 -ObjectiveC2_OBJC_FILES = \ - blocks_runtime.m\ - properties.m\ +ObjectiveC2_C_FILES = +ObjectiveC2_OBJC_FILES = +ifeq ($(OBJC2RUNTIME),0) -ifeq ($(OBJCSYNC), 0) -ObjectiveC2_OBJC_FILES += sync.m +ObjectiveC2_OBJC_FILES += \ + properties.m + +ifneq ($(OBJCSYNC), 1) +ObjectiveC2_OBJC_FILES += \ + sync.m endif -ObjectiveC2_C_FILES = \ - runtime.c +ObjectiveC2_C_FILES += caps.c runtime.c -ObjectiveC2_HEADER_FILES = \ - Availability.h\ - blocks_runtime.h\ - runtime.h +endif + +ifeq ($(HAVE_BLOCKS),0) + +ObjectiveC2_OBJC_FILES += \ + blocks_runtime.m\ + NSBlocks.m + +endif ifeq ($(CC), clang) ADDITIONAL_OBJCFLAGS = -fblocks endif -ifeq ($(GNUSTEP_TARGET_CPU), ix86) - ADDITIONAL_OBJCFLAGS += -march=i686 -endif -include Makefile.preamble diff --git a/Source/ObjectiveC2/Makefile.preamble b/Source/ObjectiveC2/Makefile.preamble index 99a80dd8c..4154eb106 100644 --- a/Source/ObjectiveC2/Makefile.preamble +++ b/Source/ObjectiveC2/Makefile.preamble @@ -56,12 +56,7 @@ ADDITIONAL_CFLAGS = # Additional include directories the compiler should search # FIXME - the -I../ is for GSPrivate.h -ADDITIONAL_INCLUDE_DIRS = -I../../Headers/Additions \ - -I../$(GNUSTEP_TARGET_DIR) -I../ - -ifeq ($(FOUNDATION_LIB),gnu) - ADDITIONAL_INCLUDE_DIRS += -I../../Headers -endif +ADDITIONAL_INCLUDE_DIRS = -I../$(GNUSTEP_TARGET_DIR) -I../ -I../../Headers # Additional LDFLAGS to pass to the linker ADDITIONAL_LDFLAGS = diff --git a/Source/ObjectiveC2/NSBlocks.m b/Source/ObjectiveC2/NSBlocks.m new file mode 100644 index 000000000..3c69373e9 --- /dev/null +++ b/Source/ObjectiveC2/NSBlocks.m @@ -0,0 +1,61 @@ +#import +#import "ObjectiveC2/blocks_runtime.h" +#include + +struct objc_class _NSConcreteGlobalBlock; +struct objc_class _NSConcreteStackBlock; + +static struct objc_class _NSConcreteGlobalBlockMeta; +static struct objc_class _NSConcreteStackBlockMeta; + +static struct objc_class _NSBlock; +static struct objc_class _NSBlockMeta; + +void __objc_update_dispatch_table_for_class(Class); +extern struct sarray *__objc_uninstalled_dtable; +extern objc_mutex_t __objc_runtime_mutex; + +static void createNSBlockSubclass(Class superclass, Class newClass, + Class metaClass, char *name) +{ + // Initialize the metaclass + metaClass->class_pointer = superclass->class_pointer; + metaClass->super_class = superclass->class_pointer; + metaClass->info = _CLS_META; + metaClass->dtable = __objc_uninstalled_dtable; + + // Set up the new class + newClass->class_pointer = metaClass; + newClass->super_class = superclass; + newClass->name = name; + newClass->info = _CLS_CLASS; + newClass->dtable = __objc_uninstalled_dtable; + + // Initialize the dispatch table for the class and metaclass. + __objc_update_dispatch_table_for_class(metaClass); + __objc_update_dispatch_table_for_class(newClass); + CLS_SETINITIALIZED(metaClass); + CLS_SETINITIALIZED(newClass); + CLS_SETRESOLV(metaClass); + CLS_SETRESOLV(newClass); + // Add pointer from super class + objc_mutex_lock(__objc_runtime_mutex); + newClass->sibling_class = newClass->super_class->subclass_list; + newClass->super_class->subclass_list = newClass; + metaClass->sibling_class = metaClass->super_class->subclass_list; + metaClass->super_class->subclass_list = metaClass; + objc_mutex_unlock(__objc_runtime_mutex); +} + +#define NEW_CLASS(super, sub) \ + createNSBlockSubclass(super, &sub, &sub ## Meta, #sub) + +BOOL objc_create_block_classes_as_subclasses_of(Class super) +{ + if (_NSBlock.super_class != NULL) { return NO; } + + NEW_CLASS(super, _NSBlock); + NEW_CLASS(&_NSBlock, _NSConcreteStackBlock); + NEW_CLASS(&_NSBlock, _NSConcreteGlobalBlock); + return YES; +} diff --git a/Source/ObjectiveC2/blocks_runtime.m b/Source/ObjectiveC2/blocks_runtime.m index d152ff4a8..967eb5ccc 100644 --- a/Source/ObjectiveC2/blocks_runtime.m +++ b/Source/ObjectiveC2/blocks_runtime.m @@ -200,16 +200,6 @@ struct StackBlockClass { const char *types; }; -#if defined(__MINGW32__) || defined(__MINGW64__) -/* FIXME ... evil hack ... declare symbol to avoid linker error on windows - * where the compiler/linker doesn't support a weak reference. - * This obviously breaks the code below... - */ -# if (__GNUC__ <= 3) -void *_NSConcreteStackBlock; -# endif -#endif - /* Copy a block to the heap if it's still on the stack or * increments its retain count. @@ -219,8 +209,7 @@ _Block_copy(void *src) { struct StackBlockClass *self = src; struct StackBlockClass *ret = self; - - extern void _NSConcreteStackBlock __attribute__((weak)); + extern void _NSConcreteStackBlock; // If the block is Global, there's no need to copy it on the heap. if (self->isa == &_NSConcreteStackBlock @@ -244,8 +233,7 @@ void _Block_release(void *src) { struct StackBlockClass *self = src; - - extern void _NSConcreteStackBlock __attribute__((weak)); + extern void _NSConcreteStackBlock; if (self->isa == &_NSConcreteStackBlock // A Global block doesn't need to be released diff --git a/Source/ObjectiveC2/caps.c b/Source/ObjectiveC2/caps.c new file mode 100644 index 000000000..868e5b3ca --- /dev/null +++ b/Source/ObjectiveC2/caps.c @@ -0,0 +1,24 @@ +#include "ObjectiveC2/capabilities.h" +#include + +/** + * Bitmask of all of the capabilities compiled into this version of the + * runtime. + */ +static const int32_t caps = 0 + | (1 << OBJC_CAP_EXCEPTIONS) + | (1 << OBJC_CAP_SYNCRONIZE) + | (1 << OBJC_CAP_PROPERTIES); + +int objc_test_capability(int x) +{ + if (x >= 32) + { + return 0; + } + if (caps & (1 << x)) + { + return 1; + } + return 0; +} diff --git a/Source/ObjectiveC2/runtime.c b/Source/ObjectiveC2/runtime.c index 7701607f4..ba11d114c 100644 --- a/Source/ObjectiveC2/runtime.c +++ b/Source/ObjectiveC2/runtime.c @@ -102,21 +102,24 @@ skip_argspec(const char *types) static Method class_getInstanceMethodNonrecursive(Class aClass, SEL aSelector) { - struct objc_method_list *methods; - - for (methods = aClass->methods; - methods != NULL; methods = methods->method_next) + if (Nil != aClass) { - int i; + struct objc_method_list *methods; - for (i = 0; i < methods->method_count; i++) + for (methods = aClass->methods; + methods != NULL; methods = methods->method_next) { - Method_t method = &methods->method_list[i]; + int i; - if (method->method_name->sel_id == aSelector->sel_id) - { - return method; - } + for (i = 0; i < methods->method_count; i++) + { + Method_t method = &methods->method_list[i]; + + if (method->method_name->sel_id == aSelector->sel_id) + { + return method; + } + } } } return NULL; @@ -148,7 +151,7 @@ class_addIvar(Class cls, const char *name, unsigned off; Ivar ivar; - if (CLS_ISRESOLV(cls) || CLS_ISMETA(cls)) + if (Nil == cls || CLS_ISRESOLV(cls) || CLS_ISMETA(cls)) { return NO; } @@ -162,14 +165,14 @@ class_addIvar(Class cls, const char *name, if (NULL == ivarlist) { - cls->ivars = objc_malloc(sizeof(struct objc_ivar_list)); + cls->ivars = malloc(sizeof(struct objc_ivar_list)); cls->ivars->ivar_count = 1; } else { ivarlist->ivar_count++; // objc_ivar_list contains one ivar. Others follow it. - cls->ivars = objc_realloc(ivarlist, sizeof(struct objc_ivar_list) + cls->ivars = realloc(ivarlist, sizeof(struct objc_ivar_list) + (ivarlist->ivar_count - 1) * sizeof(struct objc_ivar)); } @@ -209,7 +212,7 @@ class_addMethod(Class cls, SEL name, IMP imp, const char *types) } } - methods = objc_malloc(sizeof(struct objc_method_list)); + methods = malloc(sizeof(struct objc_method_list)); methods->method_next = cls->methods; cls->methods = methods; @@ -237,7 +240,7 @@ class_addProtocol(Class cls, Protocol * protocol) return NO; } protocols = cls->protocols; - protocols = objc_malloc(sizeof(struct objc_protocol_list)); + protocols = malloc(sizeof(struct objc_protocol_list)); if (protocols == NULL) { return NO; @@ -353,7 +356,7 @@ class_copyProtocolList(Class cls, unsigned int *outCount) id class_createInstance(Class cls, size_t extraBytes) { - id obj = objc_malloc(cls->instance_size + extraBytes); + id obj = malloc(cls->instance_size + extraBytes); obj->isa = cls; return obj; } @@ -380,6 +383,10 @@ class_getInstanceMethod(Class aClass, SEL aSelector) Method class_getClassMethod(Class aClass, SEL aSelector) { + if (Nil == aClass) + { + return NULL; + } return class_getInstanceMethod(aClass->class_pointer, aSelector); } @@ -393,13 +400,17 @@ class_getClassVariable(Class cls, const char *name) size_t class_getInstanceSize(Class cls) { + if (Nil == cls) + { + return 0; + } return cls->instance_size; } Ivar class_getInstanceVariable(Class cls, const char *name) { - if (name != NULL) + if (Nil != cls && NULL != name) { while (cls != Nil) { @@ -430,27 +441,44 @@ class_getInstanceVariable(Class cls, const char *name) const char * class_getIvarLayout(Class cls) { + if (Nil == cls) + { + return 0; + } return (char *) cls->ivars; } +/* For the next two functions ... + * It would be nice to use objc_msg_lookup(), but we can't because that + * requires an instance rather than a class as its argument. Trying to + * pass the address of the class as if it was an instance won't work since + * the instance variables will be missing and any forwarding callback used + * by a proxy may try to use the instance variables and crash/fail in + * interesting ways. + */ IMP class_getMethodImplementation(Class cls, SEL name) { - struct objc_object_gnu obj = { cls }; - return (IMP) objc_msg_lookup((id) & obj, name); + if (Nil == cls || 0 == name) + { + return 0; + } + return (IMP) get_imp(cls, name); } - IMP class_getMethodImplementation_stret(Class cls, SEL name) { - struct objc_object_gnu obj = { cls }; - return (IMP) objc_msg_lookup((id) & obj, name); + if (Nil == cls || 0 == name) + { + return 0; + } + return (IMP) get_imp(cls, name); } const char * class_getName(Class cls) { - if (cls == Nil) + if (Nil == cls) { return "nil"; // This is what OSX does. } @@ -466,6 +494,10 @@ void __objc_resolve_class_links(void); Class class_getSuperclass(Class cls) { + if (Nil == cls) + { + return 0; + } if (!CLS_ISRESOLV(cls)) { /* This class is not yet resolved ... so lookup superclass by name. @@ -480,9 +512,13 @@ class_getSuperclass(Class cls) } int -class_getVersion(Class theClass) +class_getVersion(Class cls) { - return class_get_version(theClass); + if (Nil == cls) + { + return 0; + } + return class_get_version(cls); } const char * @@ -495,7 +531,11 @@ class_getWeakIvarLayout(Class cls) BOOL class_isMetaClass(Class cls) { - return CLS_ISMETA(cls); + if (Nil == cls || !CLS_ISMETA(cls)) + { + return NO; + } + return YES; } IMP @@ -670,61 +710,89 @@ method_getArgumentType(Method method, IMP method_getImplementation(Method method) { - return (IMP) method->method_imp; + return method ? (IMP) method->method_imp : (IMP) 0; } SEL method_getName(Method method) { - return method->method_name; + return method ? method->method_name : (SEL) 0; } unsigned method_getNumberOfArguments(Method method) { - const char *types = method->method_types; - unsigned int count = 0; - - while ('\0' != *types) + if (0 == method) { - types = skip_argspec(types); - count++; + return 0; + } + else + { + unsigned int count = 0; + const char *types = method->method_types; + + while ('\0' != *types) + { + types = skip_argspec(types); + count++; + } + return count - 1; } - return count - 1; } void method_getReturnType(Method method, char *dst, size_t dst_len) { - //TODO: Coped and pasted code. Factor it out. - const char *types = method->method_types; - size_t length = lengthOfTypeEncoding(types); - - if (length < dst_len) + if (0 == method) { - memcpy(dst, types, length); - dst[length] = '\0'; + if (dst_len > 0) + { + dst[0] = '\0'; + } } else { - memcpy(dst, types, dst_len); + //TODO: Coped and pasted code. Factor it out. + const char *types = method->method_types; + size_t length = lengthOfTypeEncoding(types); + + if (length < dst_len) + { + memcpy(dst, types, length); + dst[length] = '\0'; + } + else if (dst_len > 0) + { + memcpy(dst, types, dst_len); + } } } const char * method_getTypeEncoding(Method method) { + if (0 == method) + { + return 0; + } return method->method_types; } IMP method_setImplementation(Method method, IMP imp) { - IMP old = (IMP) method->method_imp; + if (0 == method) + { + return (IMP)0; + } + else + { + IMP old = (IMP) method->method_imp; - method->method_imp = (objc_imp_gnu) old; - objc_updateDtableForClassContainingMethod(method); - return old; + method->method_imp = (objc_imp_gnu) old; + objc_updateDtableForClassContainingMethod(method); + return old; + } } id @@ -1017,11 +1085,12 @@ objc_registerClassPair(Class cls) { return; // Already registered } - if (Nil == existing) + else if (Nil != existing) { fprintf(stderr, "*** ERROR *** function objc_registerClassPair() called " "for class pair with name ('%s') of existing class.\n", class_getName(cls)); + return; } // Initialize the dispatch table for the class and metaclass. @@ -1082,6 +1151,12 @@ objc_getProtocol(const char *name) return p; } +Protocol **objc_copyProtocolList(unsigned int *count) +{ + *count = 0; + return NULL; +} + BOOL protocol_conformsToProtocol(Protocol *p1, Protocol *p2) { struct objc_protocol_list *list = p1->protocol_list; @@ -1134,20 +1209,81 @@ BOOL class_conformsToProtocol(Class cls, Protocol *protocol) return NO; } +struct objc_method_description_list { + int count; + struct objc_method_description list[1]; +}; + struct objc_method_description * protocol_copyMethodDescriptionList(Protocol * p, BOOL isRequiredMethod, BOOL isInstanceMethod, unsigned int *count) { - *count = 0; - return NULL; + struct objc_method_description *output = NULL; + unsigned int outputCount = 0; + struct objc_method_description_list *methods; + + if (isInstanceMethod) + { + methods = p->instance_methods; + } + else + { + methods = p->class_methods; + } + + + if (methods != NULL) + { + int i; + outputCount = methods->count; + output = malloc(outputCount * sizeof(struct objc_method_description)); + + for (i=0 ; icount; i++) + { + output[i] = methods->list[i]; + // HACK: the name field of the objc_method_description struct + // is supposed to be a selector, but testing reveals it is a string + output[i].name = sel_registerName((const char *) output[i].name); + } + } + + *count = outputCount; + return output; } Protocol ** protocol_copyProtocolList(Protocol * p, unsigned int *count) { - *count = 0; - return NULL; + Protocol **output = NULL; + unsigned int outputCount = 0; + struct objc_protocol_list *list; + + for (list = p->protocol_list ; list != NULL ; list = list->next) + { + int i; + for (i=0 ; icount ; i++) + { + outputCount++; + } + } + + if (outputCount > 0) + { + output = malloc(outputCount * sizeof(Protocol *)); + } + + for (list = p->protocol_list ; list != NULL ; list = list->next) + { + int i; + for (i=0 ; icount ; i++) + { + output[i] = (Protocol*)list->list[i]; + } + } + + *count = outputCount; + return output; } const char * @@ -1160,6 +1296,45 @@ protocol_getName(Protocol * p) return NULL; } +struct objc_method_description protocol_getMethodDescription(Protocol *p, + SEL aSel, BOOL isRequiredMethod, BOOL isInstanceMethod) +{ + struct objc_method_description output = {NULL, NULL}; + + if (p != NULL) + { + struct objc_method_description_list *methods; + const char *name = sel_getName(aSel); + int i; + + if (isInstanceMethod) + { + methods = p->instance_methods; + } + else + { + methods = p->class_methods; + } + + if (methods != NULL) + { + for (i = 0; i < methods->count; i++) + { + if (!strcmp((char*)methods->list[i].name, name)) + { + output = methods->list[i]; + // HACK: the name field of the objc_method_description struct + // is supposed to be a selector, but testing reveals it is a string + output.name = sel_registerName((const char *) output.name); + break; + } + } + } + } + return output; +} + + BOOL protocol_isEqual(Protocol * p, Protocol * other) { @@ -1182,20 +1357,10 @@ sel_getName(SEL sel) return sel_get_name(sel); } -const char * -sel_getType_np(SEL sel) -{ - if (sel == 0) - return ""; - return sel_get_type(sel); -} - SEL sel_getUid(const char *selName) { - if (selName == 0) - return 0; - return sel_get_uid(selName); + return sel_registerName(selName); } BOOL @@ -1211,3 +1376,4 @@ sel_registerName(const char *selName) return 0; return sel_register_name(selName); } + diff --git a/Source/ObjectiveC2/sync.m b/Source/ObjectiveC2/sync.m index 697a975ea..9a95b5cc7 100644 --- a/Source/ObjectiveC2/sync.m +++ b/Source/ObjectiveC2/sync.m @@ -2,32 +2,24 @@ The implementation of synchronization primitives for Objective-C. Copyright (C) 2008 Free Software Foundation, Inc. - This file is part of GCC. - Gregory Casamento - - GCC 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 2, or (at your option) any - later version. - - GCC 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 GCC; see the file COPYING. If not, write to - the Free Software Foundation, 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -/* - As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. */ #include diff --git a/Source/callframe.h b/Source/callframe.h index 2da30f617..2876afbb2 100644 --- a/Source/callframe.h +++ b/Source/callframe.h @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,7 +17,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ @@ -36,13 +36,21 @@ typedef struct _callframe_t { void **args; } callframe_t; -extern callframe_t *callframe_from_signature (NSMethodSignature *info, - void **retval); +extern callframe_t *callframe_from_info (NSArgumentInfo *info, int numargs, + void **retval); extern void callframe_set_arg(callframe_t *cframe, int index, void *buffer, int size); extern void callframe_get_arg(callframe_t *cframe, int index, void *buffer, int size); extern void *callframe_arg_addr(callframe_t *cframe, int index); +extern void callframe_do_call (DOContext *ctxt, + void(*decoder)(DOContext*), + void(*encoder)(DOContext*)); +extern void callframe_build_return (NSInvocation *inv, + const char *type, + BOOL out_parameters, + void(*decoder)(DOContext*), + DOContext* ctxt); #endif diff --git a/Source/callframe.m b/Source/callframe.m index 0e37a25ba..6aead1bf2 100644 --- a/Source/callframe.m +++ b/Source/callframe.m @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,25 +17,19 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#ifdef HAVE_MALLOC_H -#include -#endif -#ifdef HAVE_ALLOCA_H -#include -#endif - +#include "config.h" +#include #include "callframe.h" -#import "Foundation/NSException.h" -#import "Foundation/NSData.h" -#import "GSInvocation.h" +#include "Foundation/NSException.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDebug.h" +#include "GSInvocation.h" #if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) typedef long long smallret_t; @@ -44,12 +38,11 @@ typedef int smallret_t; #endif callframe_t * -callframe_from_signature (NSMethodSignature *info, void **retval) +callframe_from_info (NSArgumentInfo *info, int numargs, void **retval) { unsigned size = sizeof(callframe_t); unsigned align = __alignof(double); unsigned offset = 0; - unsigned numargs = [info numberOfArguments]; void *buf; int i; callframe_t *cframe; @@ -68,10 +61,8 @@ callframe_from_signature (NSMethodSignature *info, void **retval) } for (i = 0; i < numargs; i++) { - const char *type = [info getArgumentTypeAtIndex: i]; + size += info[i+1].size; - type = objc_skip_type_qualifiers (type); - size += objc_sizeof_type (type); if (size % align != 0) { size += (align - size % align); @@ -86,33 +77,16 @@ callframe_from_signature (NSMethodSignature *info, void **retval) */ if (retval) { - const char *type; - unsigned full = size; - unsigned pos; - unsigned ret; + unsigned full = size; + unsigned pos; - type = [info methodReturnType]; - type = objc_skip_type_qualifiers (type); if (full % align != 0) { full += (align - full % align); } - if (full % 8 != 0) - { - full += (8 - full % 8); - } pos = full; - ret = MAX(objc_sizeof_type (type), sizeof(double)); - /* The addition of a constant '8' is a fudge applied simply because - * some return values write beynd the end of the memory if the buffer - * is sized exactly ... don't know why. - */ - full += ret + 8; -#if GS_WITH_GC - cframe = buf = NSAllocateCollectable(full, NSScannedOption); -#else + full += MAX(info[0].size, sizeof(smallret_t)); cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), full, 1); -#endif if (cframe) { *retval = buf + pos; @@ -120,11 +94,7 @@ callframe_from_signature (NSMethodSignature *info, void **retval) } else { -#if GS_WITH_GC - cframe = buf = NSAllocateCollectable(size, NSScannedOption); -#else cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), size, 1); -#endif } if (cframe) @@ -138,12 +108,9 @@ callframe_from_signature (NSMethodSignature *info, void **retval) } for (i = 0; i < cframe->nargs; i++) { - const char *type = [info getArgumentTypeAtIndex: i]; - cframe->args[i] = buf + offset; - type = objc_skip_type_qualifiers (type); - offset += objc_sizeof_type (type); + offset += info[i+1].size; if (offset % align != 0) { @@ -179,3 +146,613 @@ callframe_arg_addr(callframe_t *cframe, int index) return cframe->args[index]; } + + +/* Ugly hack to make it easier to invoke a method from outside + an NSInvocation class. Hopefully simplication of NSConnection + could remove this hack */ +typedef struct _NSInvocation_t { + @defs(NSInvocation) +} NSInvocation_t; + +/*-------------------------------------------------------------------------*/ +/* Functions for handling sending and receiving messages accross a + connection +*/ + +/* callframe_do_call() + + This function decodes the arguments of method call, builds a + callframe, and invokes the method using GSFFCallInvokeWithTargetAndImp + then it encodes the return value and any pass-by-reference arguments. + + An entry, ctxt->type should be a string that describes the return value + and arguments. It's argument types and argument type qualifiers + should match exactly those that were used when the arguments were + encoded. callframe_do_call() uses this information to determine + which variable types it should decode. + + The type info is used to get the types and type qualifiers, but not + to get the register and stack locations---we get that information + from the selector type of the SEL that is decoded as the second + argument. In this way, the type info may come from a machine + of a different architecture. Having the original type info is + good, just in case the machine running callframe_do_call() has some + slightly different qualifiers. Using different qualifiers for + encoding and decoding could lead to massive confusion. + + + DECODER should be a pointer to a function that obtains the method's + argument values. For example: + + void my_decoder (DOContext *ctxt) + + CTXT contains the context information for the item to decode. + + callframe_do_call() calls this function once for each of the methods + arguments. The DECODER function should place the ARGNUM'th + argument's value at the memory location ctxt->datum. + callframe_do_call() calls this function once with ctxt->datum 0, + and ctxt->type 0 to denote completion of decoding. + + + If DECODER malloc's new memory in the course of doing its + business, then DECODER is responsible for making sure that the + memory will get free eventually. For example, if DECODER uses + -decodeValueOfCType:at:withName: to decode a char* string, you + should remember that -decodeValueOfCType:at:withName: malloc's + new memory to hold the string, and DECODER should autorelease the + malloc'ed pointer, using the NSData class. + + + ENCODER should be a pointer to a function that records the method's + return value and pass-by-reference values. For example: + + void my_encoder (DOContext *ctxt) + + CTXT contains the context information for the item to encode. + + callframe_do_call() calls this function after the method has been + run---once for the return value, and once for each of the + pass-by-reference parameters. The ENCODER function should place + the value at memory location ctxt->datum wherever the user wants to + record the ARGNUM'th return value. + +*/ + +void +callframe_do_call (DOContext *ctxt, + void(*decoder)(DOContext*), + void(*encoder)(DOContext*)) +{ + /* The method type string obtained from the target's OBJC_METHOD + structure for the selector we're sending. */ + const char *type; + /* A pointer into the local variable TYPE string. */ + const char *tmptype; + /* A pointer into the argument ENCODED_TYPES string. */ + const char *etmptype; + /* The target object that will receive the message. */ + id object; + /* The selector for the message we're sending to the TARGET. */ + SEL selector; + /* The OBJECT's Method(_t) pointer for the SELECTOR. */ + GSMethod meth; + /* The OBJECT's implementation of the SELECTOR. */ + IMP method_implementation; + /* Type qualifier flags; see . */ + unsigned flags; + /* Which argument number are we processing now? */ + int argnum; + /* The cif information for calling the method */ + callframe_t *cframe; + /* Does the method have any arguments that are passed by reference? + If so, we need to encode them, since the method may have changed them. */ + BOOL out_parameters = NO; + /* A dummy invocation to pass to the function that invokes our method */ + NSInvocation_t *inv; + /* Signature information */ + NSMethodSignature *sig; + void *retval; + const char *encoded_types = ctxt->type; + + /* Decode the object, (which is always the first argument to a method), + into the local variable OBJECT. */ + ctxt->type = @encode(id); + ctxt->datum = &object; + (*decoder) (ctxt); + NSCParameterAssert (object); + + /* Decode the selector, (which is always the second argument to a + method), into the local variable SELECTOR. */ + /* xxx @encode(SEL) produces "^v" in gcc 2.5.8. It should be ":" */ + ctxt->type = @encode(SEL); + ctxt->datum = &selector; + (*decoder) (ctxt); + NSCParameterAssert (selector); + + /* Get the "selector type" for this method. The "selector type" is + a string that lists the return and argument types, and also + indicates in which registers and where on the stack the arguments + should be placed before the method call. The selector type + string we get here should have the same argument and return types + as the ENCODED_TYPES string, but it will have different register + and stack locations if the ENCODED_TYPES came from a machine of a + different architecture. */ + if (GSObjCIsClass(object)) + { + meth = GSGetMethod(object, selector, NO, YES); + } + else if (GSObjCIsInstance(object)) + { + meth = GSGetMethod(GSObjCClass(object), selector, YES, YES); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"decoded object %p is invalid", object]; + } + + if (meth != 0) + { + type = meth->method_types; + } + else + { + NSDebugLog(@"Local object <%p %s> doesn't implement: %s directly. " + @"Will search for arbitrary signature.", + object, + GSNameFromClass(GSObjCIsClass(object) + ? object : GSObjCClass(object)), + GSNameFromSelector(selector)); + type = GSTypesFromSelector(selector); + } + + /* Make sure we successfully got the method type, and that its + types match the ENCODED_TYPES. */ + NSCParameterAssert (type); + NSCParameterAssert (GSSelectorTypesMatch(encoded_types, type)); + + /* Build the cif frame */ + sig = [NSMethodSignature signatureWithObjCTypes: type]; + cframe = callframe_from_info([sig methodInfo], [sig numberOfArguments], + &retval); + ctxt->datToFree = cframe; + + /* Put OBJECT and SELECTOR into the ARGFRAME. */ + + /* Initialize our temporary pointers into the method type strings. */ + tmptype = objc_skip_argspec (type); + etmptype = objc_skip_argspec (encoded_types); + NSCParameterAssert (*tmptype == _C_ID); + /* Put the target object there. */ + callframe_set_arg(cframe, 0, &object, sizeof(id)); + /* Get a pointer into ARGFRAME, pointing to the location where the + second argument is to be stored. */ + tmptype = objc_skip_argspec (tmptype); + etmptype = objc_skip_argspec(etmptype); + NSCParameterAssert (*tmptype == _C_SEL); + /* Put the selector there. */ + callframe_set_arg(cframe, 1, &selector, sizeof(SEL)); + + + /* Decode arguments after OBJECT and SELECTOR, and put them into the + ARGFRAME. Step TMPTYPE and ETMPTYPE in lock-step through their + method type strings. */ + + for (tmptype = objc_skip_argspec (tmptype), + etmptype = objc_skip_argspec (etmptype), argnum = 2; + *tmptype != '\0'; + tmptype = objc_skip_argspec (tmptype), + etmptype = objc_skip_argspec (etmptype), argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers (etmptype); + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + tmptype = objc_skip_type_qualifiers(tmptype); + + /* + * Setup information in context. + */ + ctxt->datum = callframe_arg_addr(cframe, argnum); + ctxt->type = tmptype; + ctxt->flags = flags; + + /* Decide how, (or whether or not), to decode the argument + depending on its FLAGS and TMPTYPE. Only the first two cases + involve parameters that may potentially be passed by + reference, and thus only the first two may change the value + of OUT_PARAMETERS. *** Note: This logic must match exactly + the code in callframe_dissect_call(); that function should + encode exactly what we decode here. *** */ + + switch (*tmptype) + { + + case _C_CHARPTR: + /* Handle a (char*) argument. */ + /* If the char* is qualified as an OUT parameter, or if it + not explicitly qualified as an IN parameter, then we will + have to get this char* again after the method is run, + because the method may have changed it. Set + OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + /* If the char* is qualified as an IN parameter, or not + explicity qualified as an OUT parameter, then decode it. + Note: the decoder allocates memory for holding the + string, and it is also responsible for making sure that + the memory gets freed eventually, (usually through the + autorelease of NSData object). */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*decoder) (ctxt); + + break; + + case _C_PTR: + /* If the pointer's value is qualified as an OUT parameter, + or if it not explicitly qualified as an IN parameter, + then we will have to get the value pointed to again after + the method is run, because the method may have changed + it. Set OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + + /* Handle an argument that is a pointer to a non-char. But + (void*) and (anything**) is not allowed. */ + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + ctxt->type = tmptype; + /* Allocate some memory to be pointed to, and to hold the + value. Note that it is allocated on the stack, and + methods that want to keep the data pointed to, will have + to make their own copies. */ + *(void**)ctxt->datum = alloca (objc_sizeof_type (tmptype)); + ctxt->datum = *(void**)ctxt->datum; + /* If the pointer's value is qualified as an IN parameter, + or not explicity qualified as an OUT parameter, then + decode it. */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*decoder) (ctxt); + break; + + default: + /* Handle arguments of all other types. */ + /* NOTE FOR OBJECTS: Unlike [Decoder decodeObjectAt:..], + this function does not generate a reference to the + object; the object may be autoreleased; if the method + wants to keep a reference to the object, it will have to + -retain it. */ + (*decoder) (ctxt); + } + } + /* End of the for () loop that enumerates the method's arguments. */ + ctxt->type = 0; + ctxt->datum = 0; + (*decoder) (ctxt); + + + /* Invoke the method! */ + + /* Find the target object's implementation of this selector. */ + method_implementation = objc_msg_lookup (object, selector); + NSCParameterAssert (method_implementation); + /* Do it! Send the message to the target, and get the return value + in retval. We need to encode any pass-by-reference info */ + inv = (NSInvocation_t *)NSAllocateObject([NSInvocation class], 0, + NSDefaultMallocZone()); + inv->_retval = retval; + inv->_selector = selector; + inv->_cframe = cframe; + inv->_info = [sig methodInfo]; + inv->_numArgs = [sig numberOfArguments]; + ctxt->objToFree = (id)inv; + GSFFCallInvokeWithTargetAndImp((NSInvocation *)inv, object, + method_implementation); + ctxt->objToFree = nil; + NSDeallocateObject((NSInvocation *)inv); + + /* Encode the return value and pass-by-reference values, if there + are any. This logic must match exactly that in + callframe_build_return(). */ + /* OUT_PARAMETERS should be true here in exactly the same + situations as it was true in callframe_dissect_call(). */ + + /* Get the qualifier type of the return value. */ + flags = objc_get_type_qualifiers (encoded_types); + /* Get the return type; store it our two temporary char*'s. */ + etmptype = objc_skip_type_qualifiers (encoded_types); + tmptype = objc_skip_type_qualifiers (type); + + /* Only encode return values if there is a non-void return value, + a non-oneway void return value, or if there are values that were + passed by reference. */ + + ctxt->flags = flags; + + /* If there is a return value, encode it. */ + if (*tmptype == _C_VOID) + { + if ((flags & _F_ONEWAY) == 0) + { + int dummy = 0; + + ctxt->type = @encode(int); + ctxt->datum = (void*)&dummy; + (*encoder) (ctxt); + } + /* No return value to encode; do nothing. */ + } + else + { + if (*tmptype == _C_PTR) + { + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + ctxt->type = tmptype; + ctxt->datum = *(void**)retval; + } + else + { + ctxt->type = tmptype; + ctxt->datum = retval; + } + /* Encode the value that was pointed to. */ + (*encoder) (ctxt); + } + + + /* Encode the values returned by reference. Note: this logic + must match exactly the code in callframe_build_return(); that + function should decode exactly what we encode here. */ + + if (out_parameters) + { + /* Step through all the arguments, finding the ones that were + passed by reference. */ + for (tmptype = objc_skip_argspec (tmptype), + argnum = 0, + etmptype = objc_skip_argspec (etmptype); + *tmptype != '\0'; + tmptype = objc_skip_argspec (tmptype), + argnum++, + etmptype = objc_skip_argspec (etmptype)) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(etmptype); + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + tmptype = objc_skip_type_qualifiers (tmptype); + + /* Decide how, (or whether or not), to encode the argument + depending on its FLAGS and TMPTYPE. */ + if (((flags & _F_OUT) || !(flags & _F_IN)) + && (*tmptype == _C_PTR || *tmptype == _C_CHARPTR)) + { + ctxt->flags = flags; + ctxt->datum = callframe_arg_addr(cframe, argnum); + + if (*tmptype == _C_PTR) + { + /* The argument is a pointer (to a non-char), and the + pointer's value is qualified as an OUT parameter, or + it not explicitly qualified as an IN parameter, then + it is a pass-by-reference argument.*/ + ctxt->type = ++tmptype; + ctxt->datum = *(void**)ctxt->datum; + } + else if (*tmptype == _C_CHARPTR) + { + ctxt->type = tmptype; + /* The argument is a pointer char string, and the + pointer's value is qualified as an OUT parameter, or + it not explicitly qualified as an IN parameter, then + it is a pass-by-reference argument. */ + } + (*encoder) (ctxt); + } + } + } + + NSZoneFree(NSDefaultMallocZone(), ctxt->datToFree); + ctxt->datToFree = 0; + + return; +} + +/* callframe_build_return() + + This function decodes the values returned from a method call, + sets up the invocation with the return value, and updates the + pass-by-reference arguments. + + The callback function is finally called with the 'type' set to a null pointer + to tell it that the return value and all return parameters have been + dealt with. This permits the function to do any tidying up necessary. */ + +void +callframe_build_return (NSInvocation *inv, + const char *type, + BOOL out_parameters, + void(*decoder)(DOContext *ctxt), + DOContext *ctxt) +{ + /* Which argument number are we processing now? */ + int argnum; + /* Type qualifier flags; see . */ + int flags; + /* A pointer into the TYPE string. */ + const char *tmptype; + /* Points at individual arguments. */ + void *datum; + const char *rettype; + /* A pointer to the memory holding the return value of the method. */ + void *retval; + /* Storage for the argument information */ + callframe_t *cframe; + /* Signature information */ + NSMethodSignature *sig; + + /* Build the call frame */ + sig = [NSMethodSignature signatureWithObjCTypes: type]; + cframe = callframe_from_info([sig methodInfo], [sig numberOfArguments], + &retval); + ctxt->datToFree = cframe; + + /* Get the return type qualifier flags, and the return type. */ + flags = objc_get_type_qualifiers(type); + tmptype = objc_skip_type_qualifiers(type); + rettype = tmptype; + + /* Decode the return value and pass-by-reference values, if there + are any. OUT_PARAMETERS should be the value returned by + callframe_dissect_call(). */ + if (out_parameters || *tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) + /* xxx What happens with method declared "- (oneway) foo: (out int*)ip;" */ + /* xxx What happens with method declared "- (in char *) bar;" */ + /* xxx Is this right? Do we also have to check _F_ONEWAY? */ + { + /* ARGNUM == -1 signifies to DECODER() that this is the return + value, not an argument. */ + + /* If there is a return value, decode it, and put it in retval. */ + if (*tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) + { + ctxt->type = tmptype; + ctxt->datum = retval; + ctxt->flags = flags; + + switch (*tmptype) + { + case _C_PTR: + { + unsigned retLength; + + /* We are returning a pointer to something. */ + /* Increment TYPE so we can see what it is a pointer to. */ + tmptype++; + retLength = objc_sizeof_type(tmptype); + /* Allocate memory to hold the value we're pointing to. */ + *(void**)retval = + NSZoneCalloc(NSDefaultMallocZone(), retLength, 1); + /* We are responsible for making sure this memory gets free'd + eventually. Ask NSData class to autorelease it. */ + [NSData dataWithBytesNoCopy: *(void**)retval + length: retLength]; + ctxt->type = tmptype; + ctxt->datum = *(void**)retval; + /* Decode the return value into the memory we allocated. */ + (*decoder) (ctxt); + } + break; + + case _C_STRUCT_B: + case _C_UNION_B: + case _C_ARY_B: + /* Decode the return value into the memory we allocated. */ + (*decoder) (ctxt); + break; + + case _C_FLT: + case _C_DBL: + (*decoder) (ctxt); + break; + + case _C_VOID: + { + ctxt->type = @encode(int); + ctxt->flags = 0; + (*decoder) (ctxt); + } + break; + + default: + (*decoder) (ctxt); + } + } + [inv setReturnValue: retval]; + + /* Decode the values returned by reference. Note: this logic + must match exactly the code in callframe_do_call(); that + function should decode exactly what we encode here. */ + + if (out_parameters) + { + /* Step through all the arguments, finding the ones that were + passed by reference. */ + for (tmptype = objc_skip_argspec (tmptype), argnum = 0; + *tmptype != '\0'; + tmptype = objc_skip_argspec (tmptype), argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(tmptype); + /* Skip over the type qualifiers, so now TYPE is + pointing directly at the char corresponding to the + argument's type, as defined in */ + tmptype = objc_skip_type_qualifiers(tmptype); + + /* Decide how, (or whether or not), to encode the + argument depending on its FLAGS and TMPTYPE. */ + datum = callframe_arg_addr(cframe, argnum); + + ctxt->type = tmptype; + ctxt->datum = datum; + ctxt->flags = flags; + + if (*tmptype == _C_PTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + void *ptr; + + /* The argument is a pointer (to a non-char), and + the pointer's value is qualified as an OUT + parameter, or it not explicitly qualified as an + IN parameter, then it is a pass-by-reference + argument.*/ + tmptype++; + ctxt->type = tmptype; + + /* Use the original pointer to find the buffer + * to store the returned data */ + [inv getArgument: &ptr atIndex: argnum]; + ctxt->datum = ptr; + + (*decoder) (ctxt); + } + else if (*tmptype == _C_CHARPTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + /* The argument is a pointer char string, and the + pointer's value is qualified as an OUT parameter, + or it not explicitly qualified as an IN + parameter, then it is a pass-by-reference + argument. Encode it.*/ + /* xxx Perhaps we could save time and space by + saving a copy of the string before the method + call, and then comparing it to this string; if it + didn't change, don't bother to send it back + again. */ + (*decoder) (ctxt); + [inv setArgument: datum atIndex: argnum]; + } + } + } + ctxt->type = 0; + ctxt->datum = 0; + (*decoder) (ctxt); /* Tell it we have finished. */ + } + + if (ctxt->datToFree != 0) + { + NSZoneFree(NSDefaultMallocZone(), ctxt->datToFree); + ctxt->datToFree = 0; + } + + return; +} + diff --git a/Source/cifframe.h b/Source/cifframe.h index edc88ed38..309b678a3 100644 --- a/Source/cifframe.h +++ b/Source/cifframe.h @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,7 +17,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -28,7 +28,7 @@ #include -#if defined(__MINGW__) +#if defined(__MINGW32__) /* * Avoid conflicts when other headers try to define UINT32 and UINT64 */ @@ -50,10 +50,8 @@ typedef struct _cifframe_t { void **values; } cifframe_t; -@class NSMutableData; - -extern NSMutableData *cifframe_from_signature (NSMethodSignature *info); - +extern cifframe_t *cifframe_from_info (NSArgumentInfo *info, int numargs, + void **retval); extern void cifframe_set_arg(cifframe_t *cframe, int index, void *buffer, int size); extern void cifframe_get_arg(cifframe_t *cframe, int index, void *buffer, @@ -62,4 +60,12 @@ extern void *cifframe_arg_addr(cifframe_t *cframe, int index); extern BOOL cifframe_decode_arg (const char *type, void* buffer); extern BOOL cifframe_encode_arg (const char *type, void* buffer); +extern void cifframe_do_call (DOContext *ctxt, + void(*decoder)(DOContext*), + void(*encoder)(DOContext*)); +extern void cifframe_build_return (NSInvocation *inv, + const char *type, + BOOL out_parameters, + void(*decoder)(DOContext*), + DOContext* ctxt); #endif diff --git a/Source/cifframe.m b/Source/cifframe.m index 8b380cf31..35679105a 100644 --- a/Source/cifframe.m +++ b/Source/cifframe.m @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -17,25 +17,19 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" - -#ifdef HAVE_MALLOC_H -#include -#endif -#ifdef HAVE_ALLOCA_H -#include -#endif - +#include "config.h" +#include #include "cifframe.h" -#import "Foundation/NSException.h" -#import "Foundation/NSData.h" -#import "GSInvocation.h" +#include "Foundation/NSException.h" +#include "Foundation/NSData.h" +#include "Foundation/NSDebug.h" +#include "GSInvocation.h" #if defined(ALPHA) || (defined(MIPS) && (_MIPS_SIM == _ABIN32)) typedef long long smallret_t; @@ -122,17 +116,15 @@ cifframe_guess_struct_size(ffi_type *stype) } -NSMutableData * -cifframe_from_signature (NSMethodSignature *info) +cifframe_t * +cifframe_from_info (NSArgumentInfo *info, int numargs, void **retval) { unsigned size = sizeof(cifframe_t); unsigned align = __alignof(double); unsigned type_offset = 0; unsigned offset = 0; - NSMutableData *result; void *buf; int i; - int numargs = [info numberOfArguments]; ffi_type *rtype; ffi_type *arg_types[numargs]; cifframe_t *cframe; @@ -141,10 +133,10 @@ cifframe_from_signature (NSMethodSignature *info) have custom ffi_types with are allocated separately. We should allocate them in our cifframe so we don't leak memory. Or maybe we could cache structure types? */ - rtype = cifframe_type([info methodReturnType], NULL); + rtype = cifframe_type(info[0].type, NULL); for (i = 0; i < numargs; i++) { - arg_types[i] = cifframe_type([info getArgumentTypeAtIndex: i], NULL); + arg_types[i] = cifframe_type(info[i+1].type, NULL); } if (numargs > 0) @@ -180,9 +172,35 @@ cifframe_from_signature (NSMethodSignature *info) } } - result = [NSMutableData dataWithCapacity: size]; - [result setLength: size]; - cframe = buf = [result mutableBytes]; + /* + * If we need space allocated to store a return value, + * make room for it at the end of the cifframe so we + * only need to do a single malloc. + */ + if (rtype && (rtype->size > 0 || rtype->elements != NULL)) + { + unsigned full = size; + unsigned pos; + + if (full % align != 0) + { + full += (align - full % align); + } + pos = full; + if (rtype->elements) + full += cifframe_guess_struct_size(rtype); + else + full += MAX(rtype->size, sizeof(smallret_t)); + cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), full, 1); + if (cframe && retval) + { + *retval = buf + pos; + } + } + else + { + cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), size, 1); + } if (cframe) { @@ -195,8 +213,8 @@ cifframe_from_signature (NSMethodSignature *info) if (ffi_prep_cif (&cframe->cif, FFI_DEFAULT_ABI, cframe->nargs, rtype, cframe->arg_types) != FFI_OK) { + objc_free(cframe); cframe = NULL; - result = NULL; } if (cframe) @@ -221,7 +239,7 @@ cifframe_from_signature (NSMethodSignature *info) } } - return result; + return cframe; } void @@ -254,10 +272,39 @@ cifframe_arg_addr(cifframe_t *cframe, int index) ffi_type * cifframe_type(const char *typePtr, const char **advance) { + BOOL flag; const char *type; ffi_type *ftype; - typePtr = objc_skip_type_qualifiers (typePtr); + /* + * Skip past any type qualifiers + */ + flag = YES; + while (flag) + { + switch (*typePtr) + { + case _C_CONST: + case _C_IN: + case _C_INOUT: + case _C_OUT: + case _C_BYCOPY: +#ifdef _C_BYREF + case _C_BYREF: +#endif + case _C_ONEWAY: +#ifdef _C_GCINVISIBLE + case _C_GCINVISIBLE: +#endif + break; + default: flag = NO; + } + if (flag) + { + typePtr++; + } + } + type = typePtr; /* @@ -338,90 +385,18 @@ cifframe_type(const char *typePtr, const char **advance) const char *adv; unsigned align = __alignof(double); - /* Standard structures can be handled using cached type information. - Since the switch statement has already skipped the _C_STRUCT_B - character, we must use typePtr-1 below to successfully match the - type encoding with one of the standard type encodings. The same - holds for skipping past the whole structure type's encoding with - objc_skip_typespec. - */ - if (GSSelectorTypesMatch(typePtr - 1, @encode(NSRange))) + types = 0; + maxtypes = 4; + size = sizeof(ffi_type); + if (size % align != 0) { - static ffi_type *elems[3]; - static ffi_type stype = { 0 }; - - if (stype.type == 0) - { - const char *t = @encode(NSUInteger); - - if (*t == _C_ULNG) - { - elems[0] = &gsffi_type_ulong; - } -#ifdef _C_LNG_LNG - else if (*t == _C_ULNG_LNG) - { - elems[0] = &gsffi_type_ulong_long; - } -#endif - else - { - elems[0] = &gsffi_type_uint; - } - elems[1] = elems[0]; - elems[2] = 0; - stype.elements = elems; - stype.type = FFI_TYPE_STRUCT; - } - ftype = &stype; - typePtr = objc_skip_typespec (typePtr - 1); - break; + size += (align - (size % align)); } - else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSSize))) - { - static ffi_type *elems[3]; - static ffi_type stype = { 0 }; - - if (stype.type == 0) - { - if (*@encode(CGFloat) == _C_DBL) - { - elems[0] = &ffi_type_double; - } - else - { - elems[0] = &ffi_type_float; - } - elems[1] = elems[0]; - elems[2] = 0; - stype.elements = elems; - stype.type = FFI_TYPE_STRUCT; - } - ftype = &stype; - typePtr = objc_skip_typespec (typePtr - 1); - break; - } - else if (GSSelectorTypesMatch(typePtr - 1, @encode(NSRect))) - { - static ffi_type *elems[3]; - static ffi_type stype = { 0 }; - - if (stype.type == 0) - { - /* An NSRect is an NSPoint and an NSSize, but those - * two structures are actually identical. - */ - elems[0] = cifframe_type(@encode(NSSize), NULL); - elems[1] = elems[0]; - elems[2] = 0; - stype.elements = elems; - stype.type = FFI_TYPE_STRUCT; - } - ftype = &stype; - typePtr = objc_skip_typespec (typePtr - 1); - break; - } - + ftype = objc_malloc(size + maxtypes*sizeof(ffi_type)); + ftype->size = 0; + ftype->alignment = 0; + ftype->type = FFI_TYPE_STRUCT; + ftype->elements = (void*)ftype + size; /* * Skip "=" stuff. */ @@ -432,19 +407,6 @@ cifframe_type(const char *typePtr, const char **advance) break; } } - - types = 0; - maxtypes = 4; - size = sizeof(ffi_type); - if (size % align != 0) - { - size += (align - (size % align)); - } - ftype = objc_malloc(size + (maxtypes+1)*sizeof(ffi_type)); - ftype->size = 0; - ftype->alignment = 0; - ftype->type = FFI_TYPE_STRUCT; - ftype->elements = (void*)ftype + size; /* * Continue accumulating structure size. */ @@ -457,9 +419,7 @@ cifframe_type(const char *typePtr, const char **advance) if (types >= maxtypes) { maxtypes *=2; - ftype = objc_realloc(ftype, - size + (maxtypes+1)*sizeof(ffi_type)); - ftype->elements = (void*)ftype + size; + ftype = objc_realloc(ftype, size + maxtypes*sizeof(ffi_type)); } } ftype->elements[types] = NULL; @@ -505,7 +465,6 @@ cifframe_type(const char *typePtr, const char **advance) case _C_VOID: ftype = &ffi_type_void; break; default: - ftype = &ffi_type_void; NSCAssert(0, @"Unknown type in sig"); } @@ -525,6 +484,14 @@ cifframe_type(const char *typePtr, const char **advance) return ftype; } + +/* Ugly hack to make it easier to invoke a method from outside + an NSInvocation class. Hopefully simplication of NSConnection + could remove this hack */ +typedef struct _NSInvocation_t { + @defs(NSInvocation) +} NSInvocation_t; + /*-------------------------------------------------------------------------*/ /* Functions for handling sending and receiving messages accross a connection @@ -535,7 +502,6 @@ cifframe_type(const char *typePtr, const char **advance) BOOL cifframe_decode_arg (const char *type, void* buffer) { - type = objc_skip_type_qualifiers (type); switch (*type) { case _C_CHR: @@ -565,7 +531,6 @@ cifframe_decode_arg (const char *type, void* buffer) BOOL cifframe_encode_arg (const char *type, void* buffer) { - type = objc_skip_type_qualifiers (type); switch (*type) { case _C_CHR: @@ -592,3 +557,599 @@ cifframe_encode_arg (const char *type, void* buffer) return YES; } +/* cifframe_do_call() + + This function decodes the arguments of method call, builds a + cifframe, and invokes the method using GSFFIInvokeWithTargetAndImp + then it encodes the return value and any pass-by-reference arguments. + + An entry, ctxt->type should be a string that describes the return value + and arguments. It's argument types and argument type qualifiers + should match exactly those that were used when the arguments were + encoded. cifframe_do_call() uses this information to determine + which variable types it should decode. + + The type info is used to get the types and type qualifiers, but not + to get the register and stack locations---we get that information + from the selector type of the SEL that is decoded as the second + argument. In this way, the type info may come from a machine + of a different architecture. Having the original type info is + good, just in case the machine running cifframe_do_call() has some + slightly different qualifiers. Using different qualifiers for + encoding and decoding could lead to massive confusion. + + + DECODER should be a pointer to a function that obtains the method's + argument values. For example: + + void my_decoder (DOContext *ctxt) + + CTXT contains the context information for the item to decode. + + cifframe_do_call() calls this function once for each of the methods + arguments. The DECODER function should place the ARGNUM'th + argument's value at the memory location ctxt->datum. + cifframe_do_call() calls this function once with ctxt->datum 0, + and ctxt->type 0 to denote completion of decoding. + + + If DECODER malloc's new memory in the course of doing its + business, then DECODER is responsible for making sure that the + memory will get free eventually. For example, if DECODER uses + -decodeValueOfCType:at:withName: to decode a char* string, you + should remember that -decodeValueOfCType:at:withName: malloc's + new memory to hold the string, and DECODER should autorelease the + malloc'ed pointer, using the NSData class. + + + ENCODER should be a pointer to a function that records the method's + return value and pass-by-reference values. For example: + + void my_encoder (DOContext *ctxt) + + CTXT contains the context information for the item to encode. + + cifframe_do_call() calls this function after the method has been + run---once for the return value, and once for each of the + pass-by-reference parameters. The ENCODER function should place + the value at memory location ctxt->datum wherever the user wants to + record the ARGNUM'th return value. + +*/ + +void +cifframe_do_call (DOContext *ctxt, + void(*decoder)(DOContext*), + void(*encoder)(DOContext*)) +{ + /* The method type string obtained from the target's OBJC_METHOD + structure for the selector we're sending. */ + const char *type; + /* A pointer into the local variable TYPE string. */ + const char *tmptype; + /* A pointer into the argument ENCODED_TYPES string. */ + const char *etmptype; + /* The target object that will receive the message. */ + id object; + /* The selector for the message we're sending to the TARGET. */ + SEL selector; + /* The OBJECT's Method(_t) pointer for the SELECTOR. */ + GSMethod meth; + /* The OBJECT's implementation of the SELECTOR. */ + IMP method_implementation; + /* Type qualifier flags; see . */ + unsigned flags; + /* Which argument number are we processing now? */ + int argnum; + /* The cif information for calling the method */ + cifframe_t *cframe; + /* Does the method have any arguments that are passed by reference? + If so, we need to encode them, since the method may have changed them. */ + BOOL out_parameters = NO; + /* A dummy invocation to pass to the function that invokes our method */ + NSInvocation_t *inv; + /* Signature information */ + NSMethodSignature *sig; + void *retval; + const char *encoded_types = ctxt->type; + + /* Decode the object, (which is always the first argument to a method), + into the local variable OBJECT. */ + ctxt->type = @encode(id); + ctxt->datum = &object; + (*decoder) (ctxt); + NSCParameterAssert (object); + + /* Decode the selector, (which is always the second argument to a + method), into the local variable SELECTOR. */ + /* xxx @encode(SEL) produces "^v" in gcc 2.5.8. It should be ":" */ + ctxt->type = @encode(SEL); + ctxt->datum = &selector; + (*decoder) (ctxt); + NSCParameterAssert (selector); + + /* Get the "selector type" for this method. The "selector type" is + a string that lists the return and argument types, and also + indicates in which registers and where on the stack the arguments + should be placed before the method call. The selector type + string we get here should have the same argument and return types + as the ENCODED_TYPES string, but it will have different register + and stack locations if the ENCODED_TYPES came from a machine of a + different architecture. */ + if (GSObjCIsClass(object)) + { + meth = GSGetMethod(object, selector, NO, YES); + } + else if (GSObjCIsInstance(object)) + { + meth = GSGetMethod(GSObjCClass(object), selector, YES, YES); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"decoded object %p is invalid", object]; + } + + if (meth != 0) + { + type = meth->method_types; + } + else + { + NSDebugLog(@"Local object <%p %s> doesn't implement: %s directly. " + @"Will search for arbitrary signature.", + object, + GSNameFromClass(GSObjCIsClass(object) + ? object : GSObjCClass(object)), + GSNameFromSelector(selector)); + type = GSTypesFromSelector(selector); + } + + /* Make sure we successfully got the method type, and that its + types match the ENCODED_TYPES. */ + NSCParameterAssert (type); + NSCParameterAssert (GSSelectorTypesMatch(encoded_types, type)); + + /* Build the cif frame */ + sig = [NSMethodSignature signatureWithObjCTypes: type]; + cframe = cifframe_from_info([sig methodInfo], [sig numberOfArguments], + &retval); + ctxt->datToFree = cframe; + + /* Put OBJECT and SELECTOR into the ARGFRAME. */ + + /* Initialize our temporary pointers into the method type strings. */ + tmptype = objc_skip_argspec (type); + etmptype = objc_skip_argspec (encoded_types); + NSCParameterAssert (*tmptype == _C_ID); + /* Put the target object there. */ + cifframe_set_arg(cframe, 0, &object, sizeof(id)); + /* Get a pointer into ARGFRAME, pointing to the location where the + second argument is to be stored. */ + tmptype = objc_skip_argspec (tmptype); + etmptype = objc_skip_argspec(etmptype); + NSCParameterAssert (*tmptype == _C_SEL); + /* Put the selector there. */ + cifframe_set_arg(cframe, 1, &selector, sizeof(SEL)); + + + /* Decode arguments after OBJECT and SELECTOR, and put them into the + ARGFRAME. Step TMPTYPE and ETMPTYPE in lock-step through their + method type strings. */ + + for (tmptype = objc_skip_argspec (tmptype), + etmptype = objc_skip_argspec (etmptype), argnum = 2; + *tmptype != '\0'; + tmptype = objc_skip_argspec (tmptype), + etmptype = objc_skip_argspec (etmptype), argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers (etmptype); + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + tmptype = objc_skip_type_qualifiers(tmptype); + + /* + * Setup information in context. + */ + ctxt->datum = cifframe_arg_addr(cframe, argnum); + ctxt->type = tmptype; + ctxt->flags = flags; + + /* Decide how, (or whether or not), to decode the argument + depending on its FLAGS and TMPTYPE. Only the first two cases + involve parameters that may potentially be passed by + reference, and thus only the first two may change the value + of OUT_PARAMETERS. *** Note: This logic must match exactly + the code in cifframe_dissect_call(); that function should + encode exactly what we decode here. *** */ + + switch (*tmptype) + { + + case _C_CHARPTR: + /* Handle a (char*) argument. */ + /* If the char* is qualified as an OUT parameter, or if it + not explicitly qualified as an IN parameter, then we will + have to get this char* again after the method is run, + because the method may have changed it. Set + OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + /* If the char* is qualified as an IN parameter, or not + explicity qualified as an OUT parameter, then decode it. + Note: the decoder allocates memory for holding the + string, and it is also responsible for making sure that + the memory gets freed eventually, (usually through the + autorelease of NSData object). */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*decoder) (ctxt); + + break; + + case _C_PTR: + /* If the pointer's value is qualified as an OUT parameter, + or if it not explicitly qualified as an IN parameter, + then we will have to get the value pointed to again after + the method is run, because the method may have changed + it. Set OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + + /* Handle an argument that is a pointer to a non-char. But + (void*) and (anything**) is not allowed. */ + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + ctxt->type = tmptype; + /* Allocate some memory to be pointed to, and to hold the + value. Note that it is allocated on the stack, and + methods that want to keep the data pointed to, will have + to make their own copies. */ + *(void**)ctxt->datum = alloca (objc_sizeof_type (tmptype)); + ctxt->datum = *(void**)ctxt->datum; + /* If the pointer's value is qualified as an IN parameter, + or not explicity qualified as an OUT parameter, then + decode it. */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*decoder) (ctxt); + break; + + default: + /* Handle arguments of all other types. */ + /* NOTE FOR OBJECTS: Unlike [Decoder decodeObjectAt:..], + this function does not generate a reference to the + object; the object may be autoreleased; if the method + wants to keep a reference to the object, it will have to + -retain it. */ + (*decoder) (ctxt); + } + } + /* End of the for () loop that enumerates the method's arguments. */ + ctxt->type = 0; + ctxt->datum = 0; + (*decoder) (ctxt); + + + /* Invoke the method! */ + + /* Find the target object's implementation of this selector. */ + method_implementation = objc_msg_lookup (object, selector); + NSCParameterAssert (method_implementation); + /* Do it! Send the message to the target, and get the return value + in retval. We need to encode any pass-by-reference info */ + inv = (NSInvocation_t *)NSAllocateObject([NSInvocation class], 0, + NSDefaultMallocZone()); + inv->_retval = retval; + inv->_selector = selector; + inv->_cframe = cframe; + inv->_info = [sig methodInfo]; + inv->_numArgs = [sig numberOfArguments]; + ctxt->objToFree = (id)inv; + GSFFIInvokeWithTargetAndImp((NSInvocation *)inv, object, + method_implementation); + ctxt->objToFree = nil; + NSDeallocateObject((NSInvocation *)inv); + + /* Encode the return value and pass-by-reference values, if there + are any. This logic must match exactly that in + cifframe_build_return(). */ + /* OUT_PARAMETERS should be true here in exactly the same + situations as it was true in cifframe_dissect_call(). */ + + /* Get the qualifier type of the return value. */ + flags = objc_get_type_qualifiers (encoded_types); + /* Get the return type; store it our two temporary char*'s. */ + etmptype = objc_skip_type_qualifiers (encoded_types); + tmptype = objc_skip_type_qualifiers (type); + + /* Only encode return values if there is a non-void return value, + a non-oneway void return value, or if there are values that were + passed by reference. */ + + ctxt->flags = flags; + + /* If there is a return value, encode it. */ + if (*tmptype == _C_VOID) + { + if ((flags & _F_ONEWAY) == 0) + { + int dummy = 0; + + ctxt->type = @encode(int); + ctxt->datum = (void*)&dummy; + (*encoder) (ctxt); + } + /* No return value to encode; do nothing. */ + } + else + { + if (*tmptype == _C_PTR) + { + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + ctxt->type = tmptype; + ctxt->datum = *(void**)retval; + } + else + { + cifframe_decode_arg(tmptype, retval); + ctxt->type = tmptype; + ctxt->datum = retval; + } + /* Encode the value that was pointed to. */ + (*encoder) (ctxt); + } + + + /* Encode the values returned by reference. Note: this logic + must match exactly the code in cifframe_build_return(); that + function should decode exactly what we encode here. */ + + if (out_parameters) + { + /* Step through all the arguments, finding the ones that were + passed by reference. */ + for (tmptype = objc_skip_argspec (tmptype), + argnum = 0, + etmptype = objc_skip_argspec (etmptype); + *tmptype != '\0'; + tmptype = objc_skip_argspec (tmptype), + argnum++, + etmptype = objc_skip_argspec (etmptype)) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(etmptype); + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + tmptype = objc_skip_type_qualifiers (tmptype); + + /* Decide how, (or whether or not), to encode the argument + depending on its FLAGS and TMPTYPE. */ + if (((flags & _F_OUT) || !(flags & _F_IN)) + && (*tmptype == _C_PTR || *tmptype == _C_CHARPTR)) + { + ctxt->flags = flags; + ctxt->datum = cifframe_arg_addr(cframe, argnum); + + if (*tmptype == _C_PTR) + { + /* The argument is a pointer (to a non-char), and the + pointer's value is qualified as an OUT parameter, or + it not explicitly qualified as an IN parameter, then + it is a pass-by-reference argument.*/ + ctxt->type = ++tmptype; + ctxt->datum = *(void**)ctxt->datum; + } + else if (*tmptype == _C_CHARPTR) + { + ctxt->type = tmptype; + /* The argument is a pointer char string, and the + pointer's value is qualified as an OUT parameter, or + it not explicitly qualified as an IN parameter, then + it is a pass-by-reference argument. */ + } + (*encoder) (ctxt); + } + } + } + + NSZoneFree(NSDefaultMallocZone(), ctxt->datToFree); + ctxt->datToFree = 0; + + return; +} + +/* cifframe_build_return() + + This function decodes the values returned from a method call, + sets up the invocation with the return value, and updates the + pass-by-reference arguments. + + The callback function is finally called with the 'type' set to a null pointer + to tell it that the return value and all return parameters have been + dealt with. This permits the function to do any tidying up necessary. */ + +void +cifframe_build_return (NSInvocation *inv, + const char *type, + BOOL out_parameters, + void(*decoder)(DOContext *ctxt), + DOContext *ctxt) +{ + /* Which argument number are we processing now? */ + int argnum; + /* Type qualifier flags; see . */ + int flags; + /* A pointer into the TYPE string. */ + const char *tmptype; + /* Points at individual arguments. */ + void *datum; + const char *rettype; + /* A pointer to the memory holding the return value of the method. */ + void *retval; + /* Storage for the argument information */ + cifframe_t *cframe; + /* Signature information */ + NSMethodSignature *sig; + + /* Build the cif frame */ + sig = [NSMethodSignature signatureWithObjCTypes: type]; + cframe = cifframe_from_info([sig methodInfo], [sig numberOfArguments], + &retval); + ctxt->datToFree = cframe; + + /* Get the return type qualifier flags, and the return type. */ + flags = objc_get_type_qualifiers(type); + tmptype = objc_skip_type_qualifiers(type); + rettype = tmptype; + + /* Decode the return value and pass-by-reference values, if there + are any. OUT_PARAMETERS should be the value returned by + cifframe_dissect_call(). */ + if (out_parameters || *tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) + /* xxx What happens with method declared "- (oneway) foo: (out int*)ip;" */ + /* xxx What happens with method declared "- (in char *) bar;" */ + /* xxx Is this right? Do we also have to check _F_ONEWAY? */ + { + /* ARGNUM == -1 signifies to DECODER() that this is the return + value, not an argument. */ + + /* If there is a return value, decode it, and put it in retval. */ + if (*tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) + { + ctxt->type = tmptype; + ctxt->datum = retval; + ctxt->flags = flags; + + switch (*tmptype) + { + case _C_PTR: + { + unsigned retLength; + + /* We are returning a pointer to something. */ + /* Increment TYPE so we can see what it is a pointer to. */ + tmptype++; + retLength = objc_sizeof_type(tmptype); + /* Allocate memory to hold the value we're pointing to. */ + *(void**)retval = + NSZoneCalloc(NSDefaultMallocZone(), retLength, 1); + /* We are responsible for making sure this memory gets free'd + eventually. Ask NSData class to autorelease it. */ + [NSData dataWithBytesNoCopy: *(void**)retval + length: retLength]; + ctxt->type = tmptype; + ctxt->datum = *(void**)retval; + /* Decode the return value into the memory we allocated. */ + (*decoder) (ctxt); + } + break; + + case _C_STRUCT_B: + case _C_UNION_B: + case _C_ARY_B: + /* Decode the return value into the memory we allocated. */ + (*decoder) (ctxt); + break; + + case _C_FLT: + case _C_DBL: + (*decoder) (ctxt); + break; + + case _C_VOID: + { + ctxt->type = @encode(int); + ctxt->flags = 0; + (*decoder) (ctxt); + } + break; + + default: + (*decoder) (ctxt); + } + } + [inv setReturnValue: retval]; + + /* Decode the values returned by reference. Note: this logic + must match exactly the code in cifframe_do_call(); that + function should decode exactly what we encode here. */ + + if (out_parameters) + { + /* Step through all the arguments, finding the ones that were + passed by reference. */ + for (tmptype = objc_skip_argspec (tmptype), argnum = 0; + *tmptype != '\0'; + tmptype = objc_skip_argspec (tmptype), argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(tmptype); + /* Skip over the type qualifiers, so now TYPE is + pointing directly at the char corresponding to the + argument's type, as defined in */ + tmptype = objc_skip_type_qualifiers(tmptype); + + /* Decide how, (or whether or not), to encode the + argument depending on its FLAGS and TMPTYPE. */ + datum = cifframe_arg_addr(cframe, argnum); + + ctxt->type = tmptype; + ctxt->datum = datum; + ctxt->flags = flags; + + if (*tmptype == _C_PTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + void *ptr; + /* The argument is a pointer (to a non-char), and + the pointer's value is qualified as an OUT + parameter, or it not explicitly qualified as an + IN parameter, then it is a pass-by-reference + argument.*/ + tmptype++; + ctxt->type = tmptype; + + /* Use the original pointer to find the buffer + * to store the returned data */ + [inv getArgument: &ptr atIndex: argnum]; + ctxt->datum = ptr; + + (*decoder) (ctxt); + } + else if (*tmptype == _C_CHARPTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + /* The argument is a pointer char string, and the + pointer's value is qualified as an OUT parameter, + or it not explicitly qualified as an IN + parameter, then it is a pass-by-reference + argument. Encode it.*/ + /* xxx Perhaps we could save time and space by + saving a copy of the string before the method + call, and then comparing it to this string; if it + didn't change, don't bother to send it back + again. */ + (*decoder) (ctxt); + [inv setArgument: datum atIndex: argnum]; + } + } + } + ctxt->type = 0; + ctxt->datum = 0; + (*decoder) (ctxt); /* Tell it we have finished. */ + } + + if (ctxt->datToFree != 0) + { + NSZoneFree(NSDefaultMallocZone(), ctxt->datToFree); + ctxt->datToFree = 0; + } + + return; +} + diff --git a/Source/common.h b/Source/common.h deleted file mode 100644 index 63f6d02d1..000000000 --- a/Source/common.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Header file for all objective-c code in the base library. - * This imports all the common headers in a consistent order such that - * we can be sure only local headers are used rather than any which - * might be from an earlier build. - */ - -#import "config.h" - -/* If this is included in a file in the Additions subdirectory, and we are - * building for use with the NeXT/Apple Foundation, then we need to import - * the native headers in preference to any of our own. - */ -#if defined(NeXT_Foundation_LIBRARY) -#import -#endif - -/* GNUstepBase/GSConfig.h includes so - * we import local versions first. - */ -#import "GNUstepBase/preface.h" -#import "GNUstepBase/GSConfig.h" - -#import "GNUstepBase/GNUstep.h" - -/* Foundation/NSObject.h imports and - * so we import local versions first. - */ -#import "Foundation/NSZone.h" -#import "Foundation/NSObjCRuntime.h" - -/* Almost all headers import so we import - * "Foundation/NSObject.h" first, to ensure we have a local copy. - */ -#import "Foundation/NSObject.h" - -/* These headers are used in almost every file. - */ -#import "Foundation/NSString.h" -#import "Foundation/NSDebug.h" - diff --git a/Source/dld-load.h b/Source/dld-load.h index b02d51102..20e45c63b 100644 --- a/Source/dld-load.h +++ b/Source/dld-load.h @@ -4,15 +4,14 @@ Copyright (C) 1995, Free Software Foundation. This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. -This program is distributed in the +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 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 Lesser General Public License for more details. +PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Lesser General Public License +You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. @@ -49,33 +48,37 @@ static void **dld_ctor_list = 0; static void** __dld_construct_ctor_list(dl_handle_t module) { - int i, ctors, length; + int i, ctors, length; - length = 100; - ctors = 1; - if (dld_ctor_list) - free(dld_ctor_list); - dld_ctor_list = (void **) __objc_xmalloc(length * sizeof(void *)); - /* Find all symbols with the GLOBAL_PREFIX prefix */ - for (i=0; i < TABSIZE; i++) { - struct glosym *sym_entry = _dld_symtab[i]; - for (; sym_entry; sym_entry = sym_entry->link) { - if (strstr(sym_entry->name, GLOBAL_PREFIX) - && strstr(sym_entry->defined_by->filename, module)) { - dld_ctor_list[ctors] = (void **)sym_entry->value; - ctors++; - if (ctors > length) { - length *= 2; - dld_ctor_list = (void **) __objc_xrealloc(dld_ctor_list, - length * sizeof(void *)); + length = 100; + ctors = 1; + if (dld_ctor_list) + free(dld_ctor_list); + dld_ctor_list = (void **) __objc_xmalloc(length * sizeof(void *)); + /* Find all symbols with the GLOBAL_PREFIX prefix */ + for (i=0; i < TABSIZE; i++) + { + struct glosym *sym_entry = _dld_symtab[i]; + for (; sym_entry; sym_entry = sym_entry->link) + { + if (strstr(sym_entry->name, GLOBAL_PREFIX) + && strstr(sym_entry->defined_by->filename, module)) + { + dld_ctor_list[ctors] = (void **)sym_entry->value; + ctors++; + if (ctors > length) + { + length *= 2; + dld_ctor_list = (void **) __objc_xrealloc(dld_ctor_list, + length * sizeof(void *)); } } } } - dld_ctor_list[ctors] = (void **)0; - dld_ctor_list[0] = (void **)(ctors - 1); + dld_ctor_list[ctors] = (void **)0; + dld_ctor_list[0] = (void **)(ctors - 1); - return dld_ctor_list; + return dld_ctor_list; } /* Do any initialization necessary. Return 0 on success (or @@ -84,7 +87,7 @@ __dld_construct_ctor_list(dl_handle_t module) static int __objc_dynamic_init(const char* exec_path) { - return dld_init(exec_path); + return dld_init(exec_path); } /* Link in the module given by the name 'module'. Return a handle which can @@ -93,15 +96,17 @@ __objc_dynamic_init(const char* exec_path) static dl_handle_t __objc_dynamic_link(const char* module, int mode, const char* debug_file) { - int error; - dl_handle_t handle; + int error; + int length = strlen(module); + dl_handle_t handle; - error = dld_link(module); - if (error) - return NULL; - handle = (dl_handle_t)__objc_xmalloc (strlen(module) + 1); - strcpy(handle, module); - return handle; + error = dld_link(module); + if (error) + return NULL; + handle = (dl_handle_t)__objc_xmalloc (length + 1); + strncpy(handle, module, length); + handle[length] = '\0'; + return handle; } /* Return the address of a symbol given by the name 'symbol' from the module @@ -115,20 +120,21 @@ __objc_dynamic_find_symbol(dl_handle_t handle, const char* symbol) static dl_symbol_t __objc_dynamic_find_symbol(dl_handle_t handle, const char* symbol) { - if (strcmp(symbol, DLD_CTOR_LIST) == 0) { - return (dl_symbol_t)__dld_construct_ctor_list(handle); + if (strcmp(symbol, DLD_CTOR_LIST) == 0) + { + return (dl_symbol_t)__dld_construct_ctor_list(handle); } - return dld_get_bare_symbol(symbol); + return dld_get_bare_symbol(symbol); } /* remove the code from memory associated with the module 'handle' */ static int __objc_dynamic_unlink(dl_handle_t handle) { - int error; - error = dld_unlink_by_file(handle, 0); - free(handle); - return error; + int error; + error = dld_unlink_by_file(handle, 0); + free(handle); + return error; } /* Print an error message (prefaced by 'error_string') relevant to the @@ -137,21 +143,21 @@ __objc_dynamic_unlink(dl_handle_t handle) static void __objc_dynamic_error(FILE *error_stream, const char *error_string) { - /* dld won't print to error stream, sorry */ - dld_perror(error_string); + /* dld won't print to error stream, sorry */ + dld_perror(error_string); } /* Debugging: define these if they are available */ static int __objc_dynamic_undefined_symbol_count(void) { - return dld_undefined_sym_count; + return dld_undefined_sym_count; } static char** __objc_dynamic_list_undefined_symbols(void) { - return dld_list_undefined_sym(); + return dld_list_undefined_sym(); } /* current dld version does not support an equivalent of dladdr() */ diff --git a/Source/externs.m b/Source/externs.m index d7ddac7a7..9f5174993 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,18 +16,19 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include "config.h" +#include "Foundation/NSString.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSException.h" +#include "Foundation/NSArray.h" +#include "Foundation/NSException.h" -#import "GSPrivate.h" +#include "GSPrivate.h" /* PENDING some string constants are scattered about in the class impl @@ -37,6 +38,12 @@ */ +/* Global lock to be used by classes when operating on any global + data that invoke other methods which also access global; thus, + creating the potential for deadlock. */ +@class NSRecursiveLock; +NSRecursiveLock *gnustep_global_lock = nil; + /* * NSConnection Notification Strings. */ @@ -93,15 +100,13 @@ NSString *NSURLFileScheme = @"file"; /* RunLoop modes */ NSString *NSConnectionReplyMode = @"NSConnectionReplyMode"; -/* NSValueTransformer constants */ -NSString *const NSNegateBooleanTransformerName - = @"NSNegateBoolean"; -NSString *const NSIsNilTransformerName - = @"NSIsNil"; -NSString *const NSIsNotNilTransformerName - = @"NSIsNotNil"; -NSString *const NSUnarchiveFromDataTransformerName - = @"NSUnarchiveFromData"; + + +/** + * Last-resort exception handler, a function taking an NSException and + * returning void. Set with NSSetUncaughtExceptionHandler(). + */ +NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler; /* NSBundle */ NSString *NSBundleDidLoadNotification = @"NSBundleDidLoadNotification"; @@ -190,7 +195,7 @@ NSString *NSLanguageName = @"NSLanguageName"; NSString *NSFormalName = @"NSFormalName"; /* For GNUstep */ -NSString *GSLocale = @"GSLocale"; +NSString *NSLocale = @"NSLocale"; /* @@ -271,7 +276,7 @@ GSPrivateBuildStrings() GS_REPLACE_CONSTANT_STRING(NSLanguageName); GS_REPLACE_CONSTANT_STRING(NSLaterTimeDesignations); GS_REPLACE_CONSTANT_STRING(NSLoadedClasses); - GS_REPLACE_CONSTANT_STRING(GSLocale); + GS_REPLACE_CONSTANT_STRING(NSLocale); GS_REPLACE_CONSTANT_STRING(NSLocalNotificationCenterType); GS_REPLACE_CONSTANT_STRING(NSMonthNameArray); GS_REPLACE_CONSTANT_STRING(NSNegativeCurrencyFormatString); diff --git a/Source/hpux-load.h b/Source/hpux-load.h index d9800ca84..22cd419c7 100644 --- a/Source/hpux-load.h +++ b/Source/hpux-load.h @@ -4,15 +4,14 @@ Copyright (C) 1995, Free Software Foundation This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. -This program is distributed in the +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 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 Lesser General Public License for more details. +PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Lesser General Public License +You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/Source/inet_ntop.c b/Source/inet_ntop.c deleted file mode 100644 index 9e46bcecb..000000000 --- a/Source/inet_ntop.c +++ /dev/null @@ -1,223 +0,0 @@ -/* from NetBSD: inet_pton.c,v 1.16 2000/02/07 18:51:02 itojun Exp */ - -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "GSNetwork.h" - -#if HAVE_SYS_SOCKET_H -#include -#endif - -#if HAVE_ARPA_NAMESER_H -#include -#endif - - -#ifndef INT16SZ -#define INT16SZ 2 /* for systems without 16-bit ints */ -#endif - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4(const u_char *src, char *dst, size_t size); -static __attribute__((unused)) const char *inet_ntop6(const u_char *src, char *dst, size_t size); - -/* char * - * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -inet_ntop(af, src, dst, size) - int af; - const void *src; - char *dst; - size_t size; -{ - switch (af) { - case AF_INET: - return (inet_ntop4(src, dst, size)); -#ifdef INET6 - case AF_INET6: - return (inet_ntop6(src, dst, size)); -#endif - default: - errno = EAFNOSUPPORT; - return (NULL); - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address, more or less like inet_ntoa() - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(src, dst, size) - const u_char *src; - char *dst; - size_t size; -{ - static const char fmt[] = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; - int l; - - l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]); - if (l <= 0 || l >= size) { - errno = ENOSPC; - return (NULL); - } - strncpy(dst, tmp, size); - dst[size-1] = '\0'; - return (dst); -} - -/* const char * - * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -static __attribute__((unused)) -const char * -inet_ntop6(src, dst, size) - const u_char *src; - char *dst; - size_t size; -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; - char *tp, *ep; - struct { int base, len; } best, cur; - u_int words[IN6ADDRSZ / INT16SZ]; - int i; - int advance; - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - cur.base = -1; - for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - ep = tmp + sizeof(tmp); - for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) { - if (tp + 1 >= ep) - return (NULL); - *tp++ = ':'; - } - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) { - if (tp + 1 >= ep) - return (NULL); - *tp++ = ':'; - } - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, (size_t)(ep - tp))) - return (NULL); - tp += strlen(tp); - break; - } - advance = snprintf(tp, ep - tp, "%x", words[i]); - if (advance <= 0 || advance >= ep - tp) - return (NULL); - tp += advance; - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) { - if (tp + 1 >= ep) - return (NULL); - *tp++ = ':'; - } - if (tp + 1 >= ep) - return (NULL); - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = ENOSPC; - return (NULL); - } - strncpy(dst, tmp, size); - dst[size-1] = '\0'; - return (dst); -} diff --git a/Source/inet_pton.c b/Source/inet_pton.c index 6805a7691..0312980e9 100644 --- a/Source/inet_pton.c +++ b/Source/inet_pton.c @@ -20,24 +20,35 @@ #include "config.h" #include -#ifdef HAVE_STDINT_H -#include -#endif - #include #include +#ifdef HAVE_STDINT_H +#include +#endif #include -#include "GSNetwork.h" - -#if HAVE_SYS_SOCKET_H -#include +#if defined(__MINGW32__) +#include +#include +#include +#if !defined(EAFNOSUPPORT) +#define EAFNOSUPPORT WSAEAFNOSUPPORT #endif +#else +#include +#include +#include +#endif + #if HAVE_ARPA_NAMESER_H #include #endif +#ifndef INADDRSZ +#define INADDRSZ 4 +#endif + /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. @@ -295,5 +306,3 @@ inet_pton6(const char *src, uint8_t *dst) return (1); } #endif - - diff --git a/Source/libgnustep-base-entry.m b/Source/libgnustep-base-entry.m index 50f985dfc..93b970a19 100644 --- a/Source/libgnustep-base-entry.m +++ b/Source/libgnustep-base-entry.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,13 +16,16 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import "common.h" +#include "config.h" +#include "GNUstepBase/preface.h" +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSString.h" /* Only if using Microsoft's tools and libraries */ #ifdef __MS_WIN32__ diff --git a/Source/mframe.m b/Source/mframe.m new file mode 100644 index 000000000..108ec4054 --- /dev/null +++ b/Source/mframe.m @@ -0,0 +1,1797 @@ +/** Implementation of functions for dissecting/making method calls + Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Created: Oct 1994 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. + */ + +/* These functions can be used for dissecting and making method calls + for many different situations. They are used for distributed + objects; they could also be used to make interfaces between + Objective C and Scheme, Perl, Tcl, or other languages. + +*/ + +/* Remove `inline' nested functions if they crash your compiler */ +//#define inline + +#include "config.h" +#include "GNUstepBase/preface.h" +#include +#include "Foundation/NSObjCRuntime.h" +#include "Foundation/NSData.h" +#include "Foundation/NSException.h" +#include "Foundation/NSDebug.h" +#include +#include +#include + +/* Deal with strrchr: */ +#if STDC_HEADERS || defined(HAVE_STRING_H) +#include +/* An ANSI string.h and pre-ANSI memory.h might conflict. */ +#if !STDC_HEADERS && defined(HAVE_MEMORY_H) +#include +#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ +#define index strchr +#define rindex strrchr +#define bcopy(s, d, n) memcpy ((d), (s), (n)) +#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) +#define bzero(s, n) memset ((s), 0, (n)) +#else /* not STDC_HEADERS and not HAVE_STRING_H */ +#include +/* memory.h and strings.h conflict on some systems. */ +#endif /* not STDC_HEADERS and not HAVE_STRING_H */ + + + +/* For encoding and decoding the method arguments, we have to know where + to find things in the "argframe" as returned by __builtin_apply_args. + + For some situations this is obvious just from the selector type + encoding, but structures passed by value cause a problem because some + architectures actually pass these by reference, i.e. use the + structure-value-address mentioned in the gcc/config/_/_.h files. + + These differences are not encoded in the selector types. + + Below is my current guess for which architectures do this. + xxx I really should do this properly by looking at the gcc config values. + + I've also been told that some architectures may pass structures with + sizef(structure) > sizeof(void*) by reference, but pass smaller ones by + value. The code doesn't currently handle that case. + */ + + +char* +mframe_build_signature(const char *typePtr, int *size, int *narg, char *buf) +{ + MFRAME_ARGS cum; + BOOL doMalloc = NO; + const char *types; + char *start; + char *dest; + int total = 0; + int count = 0; + + /* + * If we have not been given a buffer - allocate space on the stack for + * the largest concievable type encoding. + */ + if (buf == 0) + { + doMalloc = YES; + buf = alloca((strlen(typePtr)+1)*16); + } + + /* + * Copy the return type info (including qualifiers) into the buffer. + */ + types = objc_skip_typespec(typePtr); + strncpy(buf, typePtr, types - typePtr); + buf[types-typePtr] = '\0'; + + /* + * Point to the return type, initialise size of stack args, and skip + * to the first argument. + */ + types = objc_skip_type_qualifiers(typePtr); + MFRAME_INIT_ARGS(cum, types); + types = objc_skip_typespec(types); + if (*types == '+') + { + types++; + } + if (*types == '-') + { + types++; + } + while (isdigit(*types)) + { + types++; + } + + /* + * Where to start putting encoding information - leave enough room for + * the size of the stack args to be stored after the return type. + */ + start = &buf[strlen(buf)+10]; + dest = start; + + /* + * Now step through all the arguments - copy any type qualifiers, but + * let the macro write all the other info into the buffer. + */ + while (types && *types) + { + const char *qual = types; + + /* + * If there are any type qualifiers - copy the through to the + * destination. + */ + types = objc_skip_type_qualifiers(types); + while (qual < types) + { + *dest++ = *qual++; + } + MFRAME_ARG_ENCODING(cum, types, total, dest); + count++; + } + *dest = '\0'; + + /* + * Write the total size of the stack arguments after the return type, + * then copy the remaining type information to fill the gap. + */ + sprintf(&buf[strlen(buf)], "%d", total); + dest = &buf[strlen(buf)]; + while (*start) + { + *dest++ = *start++; + } + *dest = '\0'; + + /* + * If we have written into a local buffer - we need to allocate memory + * in which to return our result. + */ + if (doMalloc) + { + char *tmp = NSZoneMalloc(NSDefaultMallocZone(), dest - buf + 1); + + strcpy(tmp, buf); + buf = tmp; + } + + /* + * If the caller wants to know the total size of the stack and/or the + * number of arguments, return them in the appropriate variables. + */ + if (size) + { + *size = total; + } + if (narg) + { + *narg = count; + } + return buf; +} + + +/* + * Step through method encoding information extracting details. + */ +const char * +mframe_next_arg(const char *typePtr, NSArgumentInfo *info) +{ + NSArgumentInfo local; + BOOL flag; + BOOL negative = NO; + + if (info == 0) + { + info = &local; + } + /* + * Skip past any type qualifiers - if the caller wants them, return them. + */ + flag = YES; + info->qual = 0; + while (flag) + { + switch (*typePtr) + { + case _C_CONST: info->qual |= _F_CONST; break; + case _C_IN: info->qual |= _F_IN; break; + case _C_INOUT: info->qual |= _F_INOUT; break; + case _C_OUT: info->qual |= _F_OUT; break; + case _C_BYCOPY: info->qual |= _F_BYCOPY; break; +#ifdef _C_BYREF + case _C_BYREF: info->qual |= _F_BYREF; break; +#endif + case _C_ONEWAY: info->qual |= _F_ONEWAY; break; +#ifdef _C_GCINVISIBLE + case _C_GCINVISIBLE: info->qual |= _F_GCINVISIBLE; break; +#endif + default: flag = NO; + } + if (flag) + { + typePtr++; + } + } + + info->type = typePtr; + + /* + * Scan for size and alignment information. + */ + switch (*typePtr++) + { + case _C_ID: + info->size = sizeof(id); + info->align = __alignof__(id); + break; + + case _C_CLASS: + info->size = sizeof(Class); + info->align = __alignof__(Class); + break; + + case _C_SEL: + info->size = sizeof(SEL); + info->align = __alignof__(SEL); + break; + + case _C_CHR: + info->size = sizeof(char); + info->align = __alignof__(char); + break; + + case _C_UCHR: + info->size = sizeof(unsigned char); + info->align = __alignof__(unsigned char); + break; + + case _C_SHT: + info->size = sizeof(short); + info->align = __alignof__(short); + break; + + case _C_USHT: + info->size = sizeof(unsigned short); + info->align = __alignof__(unsigned short); + break; + + case _C_INT: + info->size = sizeof(int); + info->align = __alignof__(int); + break; + + case _C_UINT: + info->size = sizeof(unsigned int); + info->align = __alignof__(unsigned int); + break; + + case _C_LNG: + info->size = sizeof(long); + info->align = __alignof__(long); + break; + + case _C_ULNG: + info->size = sizeof(unsigned long); + info->align = __alignof__(unsigned long); + break; + + case _C_LNG_LNG: + info->size = sizeof(long long); + info->align = __alignof__(long long); + break; + + case _C_ULNG_LNG: + info->size = sizeof(unsigned long long); + info->align = __alignof__(unsigned long long); + break; + + case _C_FLT: + info->size = sizeof(float); + info->align = __alignof__(float); + break; + + case _C_DBL: + info->size = sizeof(double); + info->align = __alignof__(double); + break; + + case _C_PTR: + info->size = sizeof(char*); + info->align = __alignof__(char*); + if (*typePtr == '?') + { + typePtr++; + } + else + { + typePtr = objc_skip_typespec(typePtr); + } + break; + + case _C_ATOM: + case _C_CHARPTR: + info->size = sizeof(char*); + info->align = __alignof__(char*); + break; + + case _C_ARY_B: + { + int length = atoi(typePtr); + + while (isdigit(*typePtr)) + { + typePtr++; + } + typePtr = mframe_next_arg(typePtr, &local); + info->size = length * ROUND(local.size, local.align); + info->align = local.align; + typePtr++; /* Skip end-of-array */ + } + break; + + case _C_STRUCT_B: + { + unsigned int acc_size = 0; + unsigned int def_align = objc_alignof_type(typePtr-1); + unsigned int acc_align = def_align; + const char *ptr = typePtr; + + /* + * Skip "=" stuff. + */ + while (*ptr != _C_STRUCT_E && *ptr != '=') ptr++; + if (*ptr == '=') typePtr = ptr; + typePtr++; + + /* + * Base structure alignment on first element. + */ + if (*typePtr != _C_STRUCT_E) + { + typePtr = mframe_next_arg(typePtr, &local); + if (typePtr == 0) + { + return 0; /* error */ + } + acc_size = ROUND(acc_size, local.align); + acc_size += local.size; + acc_align = MAX(local.align, def_align); + } + /* + * Continue accumulating structure size + * and adjust alignment if necessary + */ + while (*typePtr != _C_STRUCT_E) + { + typePtr = mframe_next_arg(typePtr, &local); + if (typePtr == 0) + { + return 0; /* error */ + } + acc_size = ROUND(acc_size, local.align); + acc_size += local.size; + acc_align = MAX(local.align, acc_align); + } + /* + * Size must be a multiple of alignment + */ + if (acc_size % acc_align != 0) + { + acc_size += acc_align - acc_size % acc_align; + } + info->size = acc_size; + info->align = acc_align; + typePtr++; /* Skip end-of-struct */ + } + break; + + case _C_UNION_B: + { + unsigned int max_size = 0; + unsigned int max_align = 0; + + /* + * Skip "=" stuff. + */ + while (*typePtr != _C_UNION_E) + { + if (*typePtr++ == '=') + { + break; + } + } + while (*typePtr != _C_UNION_E) + { + typePtr = mframe_next_arg(typePtr, &local); + if (typePtr == 0) + { + return 0; /* error */ + } + max_size = MAX(max_size, local.size); + max_align = MAX(max_align, local.align); + } + info->size = max_size; + info->align = max_align; + typePtr++; /* Skip end-of-union */ + } + break; + + case _C_VOID: + info->size = 0; + info->align = __alignof__(char*); + break; + + default: + return 0; + } + + if (typePtr == 0) + { /* Error condition. */ + return 0; + } + + /* + * May tell the caller if the item is stored in a register. + */ + if (*typePtr == '+') + { + typePtr++; + info->isReg = YES; + } + else + { + info->isReg = NO; + } + /* + * Cope with negative offsets. + */ + if (*typePtr == '-') + { + typePtr++; + negative = YES; + } + /* + * May tell the caller what the stack/register offset is for + * this argument. + */ + info->offset = 0; + while (isdigit(*typePtr)) + { + info->offset = info->offset * 10 + (*typePtr++ - '0'); + } + if (negative == YES) + { + info->offset = -info->offset; + } + + return typePtr; +} + + + +/* Return the number of arguments that the method MTH expects. Note + that all methods need two implicit arguments `self' and `_cmd'. */ + +int +method_types_get_number_of_arguments (const char *type) +{ + int i = 0; + + while (*type) + { + type = objc_skip_argspec (type); + i += 1; + } + return i - 1; +} + + +/* Return the size of the argument block needed on the stack to invoke + the method MTH. This may be zero, if all arguments are passed in + registers. */ + +int +method_types_get_size_of_stack_arguments (const char *type) +{ + type = objc_skip_typespec (type); + return atoi (type); +} + +int +method_types_get_size_of_register_arguments(const char *types) +{ + const char* type = strrchr(types, '+'); + + if (type) + { + return atoi(++type) + sizeof(void*); + } + else + { + return 0; + } +} + + +/* To fix temporary bug in method_get_next_argument() on NeXT boxes */ +/* xxx Perhaps this isn't working with the NeXT runtime? */ + +char* +method_types_get_next_argument (arglist_t argf, const char **type) +{ + const char *t = objc_skip_argspec (*type); + arglist_t argframe; + + argframe = (void*)argf; + + if (*t == '\0') + { + return 0; + } + *type = t; + t = objc_skip_typespec (t); + + if (*t == '+') + { + return argframe->arg_regs + atoi(++t); + } + else + { + /* xxx What's going on here? This -8 needed on my 68k NeXT box. */ +#if NeXT + return argframe->arg_ptr + (atoi(t) - 8); +#else + return argframe->arg_ptr + atoi(t); +#endif + } +} + +char* +method_types_get_first_argument (struct objc_method* m, + arglist_t argframe, + const char** type) +{ + *type = m->method_types; + return method_types_get_next_argument (argframe, type); +} + +int +method_types_get_sizeof_arguments (struct objc_method* mth) +{ + const char* type = objc_skip_typespec (mth->method_types); + return atoi (type); +} + + +/* mframe_dissect_call() + + This function encodes the arguments of a method call. + + Call it with an ARGFRAME that was returned by __builtin_args(), and + a TYPE string that describes the input and return locations, + i.e. from sel_get_types() or Method->method_types. + + The function ENCODER will be called once with each input argument. + + Returns YES iff there are any outparameters---parameters that for + which we will have to get new values after the method is run, + e.g. an argument declared (out char*). */ + +BOOL +mframe_dissect_call (arglist_t argframe, const char *type, + void (*encoder)(DOContext *), DOContext *ctxt) +{ + unsigned flags; + char *datum; + int argnum; + BOOL out_parameters = NO; + + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) { + datum = alloca((strlen(type)+1)*10); + type = mframe_build_signature(type, 0, 0, datum); + } + /* Enumerate all the arguments in ARGFRAME, and call ENCODER for + each one. METHOD_TYPES_GET_NEXT_ARGUEMENT() returns 0 when + there are no more arguments, otherwise it returns a pointer to the + argument in the ARGFRAME. */ + + for (datum = method_types_get_next_argument(argframe, &type), argnum=0; + datum; + datum = method_types_get_next_argument(argframe, &type), argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(type); + + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + type = objc_skip_type_qualifiers(type); + + /* Decide how, (or whether or not), to encode the argument + depending on its FLAGS and TYPE. Only the first two cases + involve parameters that may potentially be passed by + reference, and thus only the first two may change the value + of OUT_PARAMETERS. */ + + ctxt->type = type; + ctxt->flags = flags; + ctxt->datum = datum; + + switch (*type) + { + + case _C_CHARPTR: + /* Handle a (char*) argument. */ + /* If the char* is qualified as an OUT parameter, or if it + not explicitly qualified as an IN parameter, then we will + have to get this char* again after the method is run, + because the method may have changed it. Set + OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + /* If the char* is qualified as an IN parameter, or not + explicity qualified as an OUT parameter, then encode + it. */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*encoder) (ctxt); + break; + + case _C_PTR: + /* If the pointer's value is qualified as an OUT parameter, + or if it not explicitly qualified as an IN parameter, + then we will have to get the value pointed to again after + the method is run, because the method may have changed + it. Set OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + /* Handle an argument that is a pointer to a non-char. But + (void*) and (anything**) is not allowed. */ + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + type++; + ctxt->type = type; + ctxt->datum = *(void**)datum; + /* If the pointer's value is qualified as an IN parameter, + or not explicity qualified as an OUT parameter, then + encode it. */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*encoder) (ctxt); + break; + + case _C_STRUCT_B: + case _C_UNION_B: + case _C_ARY_B: + /* Handle struct and array arguments. */ + /* Whether DATUM points to the data, or points to a pointer + that points to the data, depends on the value of + MFRAME_STRUCT_BYREF. Do the right thing + so that ENCODER gets a pointer to directly to the data. */ +#if MFRAME_STRUCT_BYREF + ctxt->datum = *(void**)datum; +#endif + (*encoder) (ctxt); + break; + + default: + /* Handle arguments of all other types. */ + (*encoder) (ctxt); + } + } + + /* Return a BOOL indicating whether or not there are parameters that + were passed by reference; we will need to get those values again + after the method has finished executing because the execution of + the method may have changed them.*/ + return out_parameters; +} + + +/* mframe_do_call() + + This function decodes the arguments of method call, builds an + argframe of type arglist_t, and invokes the method using + __builtin_apply; then it encodes the return value and any + pass-by-reference arguments. + + ENCODED_TYPES should be a string that describes the return value + and arguments. It's argument types and argument type qualifiers + should match exactly those that were used when the arguments were + encoded with mframe_dissect_call()---mframe_do_call() uses + ENCODED_TYPES to determine which variable types it should decode. + + ENCODED_TYPES is used to get the types and type qualifiers, but not + to get the register and stack locations---we get that information + from the selector type of the SEL that is decoded as the second + argument. In this way, the ENCODED_TYPES may come from a machine + of a different architecture. Having the original ENCODED_TYPES is + good, just in case the machine running mframe_do_call() has some + slightly different qualifiers. Using different qualifiers for + encoding and decoding could lead to massive confusion. + + + DECODER should be a pointer to a function that obtains the method's + argument values. For example: + + void my_decoder (int argnum, void *data, const char *type) + + ARGNUM is the number of the argument, beginning at 0. + DATA is a pointer to the memory where the value should be placed. + TYPE is a pointer to the type string of this value. + + mframe_do_call() calls this function once for each of the methods + arguments. The DECODER function should place the ARGNUM'th + argument's value at the memory location DATA. + mframe_do_call() calls this function once with ARGNUM -1, DATA 0, + and TYPE 0 to denote completion of decoding. + + + If DECODER malloc's new memory in the course of doing its + business, then DECODER is responsible for making sure that the + memory will get free eventually. For example, if DECODER uses + -decodeValueOfCType:at:withName: to decode a char* string, you + should remember that -decodeValueOfCType:at:withName: malloc's + new memory to hold the string, and DECODER should autorelease the + malloc'ed pointer, using the NSData class. + + + ENCODER should be a pointer to a function that records the method's + return value and pass-by-reference values. For example: + + void my_encoder (int argnum, void *data, const char *type, int flags) + + ARGNUM is the number of the argument; this will be -1 for the + return value, and the argument index for the pass-by-reference + values; the indices start at 0. + DATA is a pointer to the memory where the value can be found. + TYPE is a pointer to the type string of this value. + FLAGS is a copy of the type qualifier flags for this argument; + (see ). + + mframe_do_call() calls this function after the method has been + run---once for the return value, and once for each of the + pass-by-reference parameters. The ENCODER function should place + the value at memory location DATA wherever the user wants to + record the ARGNUM'th return value. + + PASS_POINTERS is a flag saying whether pointers should be passed + as pointers (for local stuff) or should be assumed to point to a + single data item (for distributed objects). +*/ + +void +mframe_do_call (DOContext *ctxt, + void(*decoder)(DOContext*), + void(*encoder)(DOContext*)) +{ + /* The method type string obtained from the target's OBJC_METHOD + structure for the selector we're sending. */ + const char *type; + /* A pointer into the local variable TYPE string. */ + const char *tmptype; + /* A pointer into the argument ENCODED_TYPES string. */ + const char *etmptype; + /* The target object that will receive the message. */ + id object; + /* The selector for the message we're sending to the TARGET. */ + SEL selector; + /* The OBJECT's Method(_t) pointer for the SELECTOR. */ + GSMethod meth; + /* The OBJECT's implementation of the SELECTOR. */ + IMP method_implementation; + /* The number bytes for holding arguments passed on the stack. */ + int stack_argsize; + /* The number bytes for holding arguments passed in registers. */ + int reg_argsize; + /* The structure for holding the arguments to the method. */ + arglist_t argframe; + /* A pointer into the ARGFRAME; points at individual arguments. */ + char *datum; + /* Type qualifier flags; see . */ + unsigned flags; + /* Which argument number are we processing now? */ + int argnum; + /* A pointer to the memory holding the return value of the method. */ + void *retframe; + /* Does the method have any arguments that are passed by reference? + If so, we need to encode them, since the method may have changed them. */ + BOOL out_parameters = NO; + const char *encoded_types = ctxt->type; + /* For extracting a return value of type `float' from RETFRAME. */ + float retframe_float (void *rframe) + { + __builtin_return (rframe); + } + /* For extracting a return value of type `double' from RETFRAME. */ + double retframe_double (void *rframe) + { + __builtin_return (rframe); + } + /* For extracting a return value of type `char' from RETFRAME */ + char retframe_char (void *rframe) + { + __builtin_return (rframe); + } + /* For extracting a return value of type `short' from RETFRAME */ + short retframe_short (void *rframe) + { + __builtin_return (rframe); + } + + /* Decode the object, (which is always the first argument to a method), + into the local variable OBJECT. */ + ctxt->datum = &object; + ctxt->type = @encode(id); + (*decoder) (ctxt); + NSCParameterAssert (object); + + /* Decode the selector, (which is always the second argument to a + method), into the local variable SELECTOR. */ + /* xxx @encode(SEL) produces "^v" in gcc 2.5.8. It should be ":" */ + ctxt->datum = &selector; + ctxt->type = @encode(SEL); + (*decoder) (ctxt); + NSCParameterAssert (selector); + + /* Get the "selector type" for this method. The "selector type" is + a string that lists the return and argument types, and also + indicates in which registers and where on the stack the arguments + should be placed before the method call. The selector type + string we get here should have the same argument and return types + as the ENCODED_TYPES string, but it will have different register + and stack locations if the ENCODED_TYPES came from a machine of a + different architecture. */ + if (GSObjCIsClass(object)) + { + meth = GSGetMethod(object, selector, NO, YES); + } + else if (GSObjCIsInstance(object)) + { + meth = GSGetMethod(GSObjCClass(object), selector, YES, YES); + } + else + { + [NSException raise: NSInvalidArgumentException + format: @"decoded object %p is invalid", object]; + } + + if (meth != 0) + { + type = meth->method_types; + } + else + { + NSDebugLog(@"Local object <%p %s> doesn't implement: %s directly. " + @"Will search for arbitrary signature.", + object, + GSNameFromClass(GSObjCIsClass(object) + ? object : GSObjCClass(object)), + GSNameFromSelector(selector)); + type = GSTypesFromSelector(selector); + } + + /* Make sure we successfully got the method type, and that its + types match the ENCODED_TYPES. */ + NSCParameterAssert (type); + NSCParameterAssert (GSSelectorTypesMatch(encoded_types, type)); + + /* + * The compiler/runtime doesn't always seem to get the encoding right + * for our purposes - so we generate our own encoding as required by + * __builtin_apply(). + */ + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) { + tmptype = alloca((strlen(type)+1)*10); + type = mframe_build_signature(type, 0, 0, (char*)tmptype); + } + + /* Allocate an argframe, using memory on the stack */ + + /* Calculate the amount of memory needed for storing variables that + are passed in registers, and the amount of memory for storing + variables that are passed on the stack. */ + stack_argsize = method_types_get_size_of_stack_arguments (type); + reg_argsize = method_types_get_size_of_register_arguments (type); + /* Allocate the space for variables passed in registers. */ + argframe = (arglist_t) alloca(sizeof(char*) + reg_argsize); + /* Allocate the space for variables passed on the stack. */ + if (stack_argsize) + argframe->arg_ptr = alloca (stack_argsize); + else + argframe->arg_ptr = 0; + + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) + { + void *buf; + + /* If we are passing a pointer to return a structure in, we must allocate + the memory for it and put it in the correct place in the argframe. */ + buf = alloca(objc_sizeof_type(type)); + MFRAME_SET_STRUCT_ADDR(argframe, type, buf); + } + + /* Put OBJECT and SELECTOR into the ARGFRAME. */ + + /* Initialize our temporary pointers into the method type strings. */ + tmptype = type; + etmptype = objc_skip_argspec (encoded_types); + /* Get a pointer into ARGFRAME, pointing to the location where the + first argument is to be stored. */ + datum = method_types_get_next_argument (argframe, &tmptype); + NSCParameterAssert (datum); + NSCParameterAssert (*tmptype == _C_ID); + /* Put the target object there. */ + *(id*)datum = object; + /* Get a pointer into ARGFRAME, pointing to the location where the + second argument is to be stored. */ + etmptype = objc_skip_argspec(etmptype); + datum = method_types_get_next_argument(argframe, &tmptype); + NSCParameterAssert (datum); + NSCParameterAssert (*tmptype == _C_SEL); + /* Put the selector there. */ + *(SEL*)datum = selector; + + + /* Decode arguments after OBJECT and SELECTOR, and put them into the + ARGFRAME. Step TMPTYPE and ETMPTYPE in lock-step through their + method type strings. */ + + for (datum = method_types_get_next_argument (argframe, &tmptype), + etmptype = objc_skip_argspec (etmptype), argnum = 2; + datum; + datum = method_types_get_next_argument (argframe, &tmptype), + etmptype = objc_skip_argspec (etmptype), argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers (etmptype); + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + tmptype = objc_skip_type_qualifiers(tmptype); + + /* Decide how, (or whether or not), to decode the argument + depending on its FLAGS and TMPTYPE. Only the first two cases + involve parameters that may potentially be passed by + reference, and thus only the first two may change the value + of OUT_PARAMETERS. *** Note: This logic must match exactly + the code in mframe_dissect_call(); that function should + encode exactly what we decode here. *** */ + + ctxt->type = tmptype; + ctxt->datum = datum; + + switch (*tmptype) + { + + case _C_CHARPTR: + /* Handle a (char*) argument. */ + /* If the char* is qualified as an OUT parameter, or if it + not explicitly qualified as an IN parameter, then we will + have to get this char* again after the method is run, + because the method may have changed it. Set + OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + /* If the char* is qualified as an IN parameter, or not + explicity qualified as an OUT parameter, then decode it. + Note: the decoder allocates memory for holding the + string, and it is also responsible for making sure that + the memory gets freed eventually, (usually through the + autorelease of NSData object). */ + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*decoder) (ctxt); + + break; + + case _C_PTR: + /* If the pointer's value is qualified as an OUT parameter, + or if it not explicitly qualified as an IN parameter, + then we will have to get the value pointed to again after + the method is run, because the method may have changed + it. Set OUT_PARAMETERS accordingly. */ + if ((flags & _F_OUT) || !(flags & _F_IN)) + out_parameters = YES; + /* Handle an argument that is a pointer to a non-char. But + (void*) and (anything**) is not allowed. */ + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + /* Allocate some memory to be pointed to, and to hold the + value. Note that it is allocated on the stack, and + methods that want to keep the data pointed to, will have + to make their own copies. */ + *(void**)datum = alloca (objc_sizeof_type (tmptype)); + /* If the pointer's value is qualified as an IN parameter, + or not explicity qualified as an OUT parameter, then + decode it. */ + ctxt->type = tmptype; + ctxt->datum = *(void**)datum; + if ((flags & _F_IN) || !(flags & _F_OUT)) + (*decoder) (ctxt); + break; + + case _C_STRUCT_B: + case _C_UNION_B: + case _C_ARY_B: + /* Handle struct and array arguments. */ + /* Whether DATUM points to the data, or points to a pointer + that points to the data, depends on the value of + MFRAME_STRUCT_BYREF. Do the right thing + so that ENCODER gets a pointer to directly to the data. */ +#if MFRAME_STRUCT_BYREF + /* Allocate some memory to be pointed to, and to hold the + data. Note that it is allocated on the stack, and + methods that want to keep the data pointed to, will have + to make their own copies. */ + *(void**)datum = alloca (objc_sizeof_type(tmptype)); + ctxt->datum = datum; +#endif + (*decoder) (ctxt); + break; + + default: + /* Handle arguments of all other types. */ + /* NOTE FOR OBJECTS: Unlike [Decoder decodeObjectAt:..], + this function does not generate a reference to the + object; the object may be autoreleased; if the method + wants to keep a reference to the object, it will have to + -retain it. */ + (*decoder) (ctxt); + } + } + /* End of the for () loop that enumerates the method's arguments. */ + ctxt->type = 0; + ctxt->datum = 0; + (*decoder) (ctxt); + + + /* Invoke the method! */ + + /* Find the target object's implementation of this selector. */ + method_implementation = objc_msg_lookup (object, selector); + NSCParameterAssert (method_implementation); + /* Do it! Send the message to the target, and get the return value + in RETFRAME. The arguments will still be in ARGFRAME, so we can + get the pass-by-reference info from there. */ + retframe = __builtin_apply((void(*)(void))method_implementation, + argframe, + stack_argsize); + + + /* Encode the return value and pass-by-reference values, if there + are any. This logic must match exactly that in + mframe_build_return(). */ + /* OUT_PARAMETERS should be true here in exactly the same + situations as it was true in mframe_dissect_call(). */ + + /* Get the qualifier type of the return value. */ + flags = objc_get_type_qualifiers (encoded_types); + /* Get the return type; store it our two temporary char*'s. */ + etmptype = objc_skip_type_qualifiers (encoded_types); + tmptype = objc_skip_type_qualifiers (type); + + /* Only encode return values if there is a non-void return value, + a non-oneway void return value, or if there are values that were + passed by reference. */ + + ctxt->type = tmptype; + ctxt->datum = retframe; + ctxt->flags = flags; + /* If there is a return value, encode it. */ + switch (*tmptype) + { + case _C_VOID: + if ((flags & _F_ONEWAY) == 0) + { + int dummy = 0; + + ctxt->datum = &dummy; + ctxt->type = @encode(int); + (*encoder) (ctxt); + } + /* No return value to encode; do nothing. */ + break; + + case _C_PTR: + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + ctxt->type = tmptype; + ctxt->datum = *(void**)retframe; + /* Encode the value that was pointed to. */ + (*encoder) (ctxt); + break; + + case _C_STRUCT_B: + case _C_UNION_B: + case _C_ARY_B: + /* The argument is a structure or array returned by value. + (In C, are array's allowed to be returned by value?) */ + ctxt->datum = MFRAME_GET_STRUCT_ADDR(argframe, tmptype); + (*encoder)(ctxt); + break; + + case _C_FLT: + { + float ret = retframe_float (retframe); + ctxt->datum = &ret; + (*encoder) (ctxt); + break; + } + + case _C_DBL: + { + double ret = retframe_double (retframe); + ctxt->datum = &ret; + (*encoder) (ctxt); + break; + } + + case _C_SHT: + case _C_USHT: + /* On some (but not all) architectures, for C variable types + smaller than int, like short, the RETFRAME doesn't actually + point to the beginning of the short, it points to the + beginning of an int. So we let RETFRAME_SHORT() take care of + it. */ + { + short ret = retframe_short (retframe); + ctxt->datum = &ret; + (*encoder) (ctxt); + break; + } + + case _C_CHR: + case _C_UCHR: + /* On some (but not all) architectures, for C variable types + smaller than int, like char, the RETFRAME doesn't actually + point to the beginning of the char, it points to the + beginning of an int. So we let RETFRAME_SHORT() take care of + it. */ + { + char ret = retframe_char (retframe); + ctxt->datum = &ret; + (*encoder) (ctxt); + break; + } + + default: + /* case _C_INT: case _C_UINT: case _C_LNG: case _C_ULNG: + case _C_CHARPTR: case: _C_ID: */ + /* xxx I think this assumes that sizeof(int)==sizeof(void*) */ + (*encoder) (ctxt); + } + + + /* Encode the values returned by reference. Note: this logic + must match exactly the code in mframe_build_return(); that + function should decode exactly what we encode here. */ + + if (out_parameters) + { + /* Step through all the arguments, finding the ones that were + passed by reference. */ + for (datum = method_types_get_next_argument (argframe, &tmptype), + argnum = 1, + etmptype = objc_skip_argspec (etmptype); + datum; + datum = method_types_get_next_argument (argframe, &tmptype), + argnum++, + etmptype = objc_skip_argspec (etmptype)) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(etmptype); + /* Skip over the type qualifiers, so now TYPE is pointing directly + at the char corresponding to the argument's type, as defined + in */ + tmptype = objc_skip_type_qualifiers (tmptype); + + ctxt->type = tmptype; + ctxt->datum = datum; + + /* Decide how, (or whether or not), to encode the argument + depending on its FLAGS and TMPTYPE. */ + + if ((*tmptype == _C_PTR) + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + /* The argument is a pointer (to a non-char), and the + pointer's value is qualified as an OUT parameter, or + it not explicitly qualified as an IN parameter, then + it is a pass-by-reference argument.*/ + /* The argument is a pointer to something; increment TYPE + so we can see what it is a pointer to. */ + tmptype++; + ctxt->type = tmptype; + ctxt->datum = *(void**)datum; + /* Encode it. */ + (*encoder) (ctxt); + } + else if (*tmptype == _C_CHARPTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + /* The argument is a pointer char string, and the + pointer's value is qualified as an OUT parameter, or + it not explicitly qualified as an IN parameter, then + it is a pass-by-reference argument. Encode it.*/ + /* xxx Perhaps we could save time and space by saving + a copy of the string before the method call, and then + comparing it to this string; if it didn't change, don't + bother to send it back again. */ + (*encoder) (ctxt); + } + } + } + + return; +} + +#if 0 + /* For returning structures etc */ + typedef struct { id many[8];} __big; +static __big return_block (void* data) + { + return *(__big*)data; + } +#endif + /* For returning a char (or unsigned char) */ +static char return_char (char data) + { + return data; + } + /* For returning a double */ +static double return_double (double data) + { + return data; + } + /* For returning a float */ +static float return_float (float data) + { + return data; + } + /* For returning a short (or unsigned short) */ +static short return_short (short data) + { + return data; + } +#if 0 +static retval_t apply_block(void* data) + { + void* args = __builtin_apply_args(); + return __builtin_apply((apply_t)return_block, args, sizeof(void*)); + } +#endif +static retval_t apply_char(char data) + { + void* args = __builtin_apply_args(); + return __builtin_apply((apply_t)return_char, args, sizeof(void*)); + } +static retval_t apply_float(float data) + { + void* args = __builtin_apply_args(); + return __builtin_apply((apply_t)return_float, args, sizeof(float)); + } +static retval_t apply_double(double data) + { + void* args = __builtin_apply_args(); + return __builtin_apply((apply_t)return_double, args, sizeof(double)); + } +static retval_t apply_short(short data) + { + void* args = __builtin_apply_args(); + return __builtin_apply((apply_t)return_short, args, sizeof(void*)); + } + +/* mframe_build_return() + + This function decodes the values returned from a method call, + builds a retframe of type retval_t that can be passed to GCC's + __builtin_return(), and updates the pass-by-reference arguments in + ARGFRAME. This function returns a retframe pointer. + + In the function that calls this one, be careful about calling more + functions after this one. The memory for the retframe is alloca()'ed, + and therefore is on the stack and can be tromped-on by future function calls. + + The callback function is finally called with the 'type' set to a null pointer + to tell it that the return value and all return parameters have been + dealt with. This permits the function to do any tidying up necessary. +*/ + +retval_t +mframe_build_return (arglist_t argframe, + const char *type, + BOOL out_parameters, + void(*decoder)(DOContext*), + DOContext *ctxt) +{ + /* A pointer to the memory that will hold the return value. */ + retval_t retframe = NULL; + /* The size, in bytes, of memory pointed to by RETFRAME. */ + unsigned int retsize; + /* Which argument number are we processing now? */ + int argnum; + /* Type qualifier flags; see . */ + int flags; + /* A pointer into the TYPE string. */ + const char *tmptype; + /* A pointer into the ARGFRAME; points at individual arguments. */ + void *datum; + const char *rettype; + + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) + { + tmptype = alloca((strlen(type)+1)*10); + type = mframe_build_signature(type, 0, 0, (char*)tmptype); + } + /* Get the return type qualifier flags, and the return type. */ + flags = objc_get_type_qualifiers(type); + tmptype = objc_skip_type_qualifiers(type); + rettype = tmptype; + + /* Decode the return value and pass-by-reference values, if there + are any. OUT_PARAMETERS should be the value returned by + mframe_dissect_call(). */ + if (out_parameters || *tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) + /* xxx What happens with method declared "- (oneway) foo: (out int*)ip;" */ + /* xxx What happens with method declared "- (in char *) bar;" */ + /* xxx Is this right? Do we also have to check _F_ONEWAY? */ + { + /* If there is a return value, decode it, and put it in retframe. */ + if (*tmptype != _C_VOID || (flags & _F_ONEWAY) == 0) + { + /* Get the size of the returned value. */ + if (*tmptype == _C_VOID) + retsize = sizeof(void*); + else + retsize = objc_sizeof_type (tmptype); + /* Allocate memory on the stack to hold the return value. + It should be at least 4 * sizeof(void*). */ + /* xxx We need to test retsize's less than 4. Also note that + if we return structures using a structure-value-address, we + are potentially alloca'ing much more than we need here. */ + /* xxx Find out about returning structures by reference + on non--structure-value-address machines, and potentially + just always alloca(RETFRAME_SIZE == sizeof(void*)*4) */ + retframe = alloca (MAX(retsize, sizeof(void*)*4)); + + ctxt->type = tmptype; + ctxt->datum = retframe; + ctxt->flags = flags; + + switch (*tmptype) + { + case _C_PTR: + { + unsigned retLength; + + /* We are returning a pointer to something. */ + /* Increment TYPE so we can see what it is a pointer to. */ + tmptype++; + retLength = (unsigned int)objc_sizeof_type(tmptype); + /* Allocate memory to hold the value we're pointing to. */ + *(void**)retframe = + NSZoneMalloc(NSDefaultMallocZone(), retLength); + /* We are responsible for making sure this memory gets free'd + eventually. Ask NSData class to autorelease it. */ + [NSData dataWithBytesNoCopy: *(void**)retframe + length: retLength]; + ctxt->type = tmptype; + ctxt->datum = *(void**)retframe; + /* Decode the return value into the memory we allocated. */ + (*decoder) (ctxt); + } + break; + + case _C_STRUCT_B: + case _C_UNION_B: + case _C_ARY_B: + /* The argument is a structure or array returned by value. + (In C, are array's allowed to be returned by value?) */ + *(void**)retframe = MFRAME_GET_STRUCT_ADDR(argframe, tmptype); + /* Decode the return value into the memory we allocated. */ + ctxt->datum = *(void**)retframe; + (*decoder) (ctxt); + break; + + case _C_FLT: + case _C_DBL: + (*decoder) (ctxt); + break; + + case _C_VOID: + { + ctxt->type = @encode(int); + (*decoder) (ctxt); + } + break; + + default: + (*decoder) (ctxt); + } + } + + /* Decode the values returned by reference. Note: this logic + must match exactly the code in mframe_do_call(); that + function should decode exactly what we encode here. */ + + if (out_parameters) + { + /* Step through all the arguments, finding the ones that were + passed by reference. */ + for (datum = method_types_get_next_argument(argframe, &tmptype), + argnum=0; + datum; + (datum = method_types_get_next_argument(argframe, &tmptype)), + argnum++) + { + /* Get the type qualifiers, like IN, OUT, INOUT, ONEWAY. */ + flags = objc_get_type_qualifiers(tmptype); + /* Skip over the type qualifiers, so now TYPE is + pointing directly at the char corresponding to the + argument's type, as defined in */ + tmptype = objc_skip_type_qualifiers(tmptype); + + /* Decide how, (or whether or not), to encode the + argument depending on its FLAGS and TMPTYPE. */ + + if (*tmptype == _C_PTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + /* The argument is a pointer (to a non-char), and + the pointer's value is qualified as an OUT + parameter, or it not explicitly qualified as an + IN parameter, then it is a pass-by-reference + argument.*/ + /* The argument is a pointer to something; increment + TYPE so we can see what it is a pointer to. */ + tmptype++; + ctxt->flags = flags; + ctxt->type = tmptype; + ctxt->datum = *(void**)datum; + /* xxx Note that a (char**) is malloc'ed anew here. + Yucky, or worse than yucky. If the returned string + is smaller than the original, we should just put it + there; if the returned string is bigger, I don't know + what to do. */ + /* xxx __builtin_return can't return structures by value? */ + (*decoder) (ctxt); + } + else if (*tmptype == _C_CHARPTR + && ((flags & _F_OUT) || !(flags & _F_IN))) + { + /* The argument is a pointer char string, and the + pointer's value is qualified as an OUT parameter, + or it not explicitly qualified as an IN + parameter, then it is a pass-by-reference + argument. Encode it.*/ + /* xxx Perhaps we could save time and space by + saving a copy of the string before the method + call, and then comparing it to this string; if it + didn't change, don't bother to send it back + again. */ + ctxt->flags = flags; + ctxt->type = tmptype; + ctxt->datum = datum; + (*decoder) (ctxt); + } + } + } + ctxt->type = 0; + ctxt->datum = 0; + (*decoder) (ctxt); /* Tell it we have finished. */ + } + else /* matches `if (out_parameters)' */ + { + /* We are just returning void, but retframe needs to point to + something or else we can crash. */ + retframe = alloca (sizeof(void*)); + } + + switch (*rettype) { + case _C_CHR: + case _C_UCHR: + return apply_char(*(char*)retframe); + case _C_DBL: + return apply_double(*(double*)retframe); + case _C_FLT: + return apply_float(*(float*)retframe); + case _C_SHT: + case _C_USHT: + return apply_short(*(short*)retframe); +#if 0 + case _C_ARY_B: + case _C_UNION_B: + case _C_STRUCT_B: + if (objc_sizeof_type(rettype) > 8) { + return apply_block(*(void**)retframe); + } +#endif + } + + /* Return the retval_t pointer to the return value. */ + return retframe; +} + + + +arglist_t +mframe_create_argframe(const char *types, void** retbuf) +{ + arglist_t argframe = objc_calloc(MFRAME_ARGS_SIZE, 1); + const char* rtype = objc_skip_type_qualifiers(types); + int stack_argsize = atoi(objc_skip_typespec(rtype)); + + /* + * Allocate the space for variables passed on the stack. + */ + if (stack_argsize) + { + argframe->arg_ptr = objc_calloc(stack_argsize, 1); + } + else + { + argframe->arg_ptr = 0; + } + if (*rtype == _C_STRUCT_B || *rtype == _C_UNION_B || *rtype == _C_ARY_B) + { + /* + * If we haven't been passed a pointer to the location in which + * to store a returned structure - allocate space and return + * the address of the allocated space. + */ + if (*retbuf == 0) + { + *retbuf = objc_calloc(objc_sizeof_type(rtype), 1); + } + MFRAME_SET_STRUCT_ADDR(argframe, rtype, *retbuf); + } + return argframe; +} + +void +mframe_destroy_argframe(const char *types, arglist_t argframe) +{ + const char* rtype = objc_skip_type_qualifiers(types); + int stack_argsize = atoi(objc_skip_typespec(rtype)); + + if (stack_argsize) + { + NSZoneFree(NSDefaultMallocZone(), argframe->arg_ptr); + } + NSZoneFree(NSDefaultMallocZone(), argframe); +} + + + +BOOL +mframe_decode_return (const char *type, void* buffer, void* retframe) +{ + unsigned int size = 0; + + type = objc_skip_type_qualifiers(type); + NSGetSizeAndAlignment(type, &size, 0); + + switch (*type) + { + case _C_ID: + { + inline id retframe_id(void *rframe) + { + __builtin_return (rframe); + } + *(id*)buffer = retframe_id(retframe); + break; + } + + case _C_CLASS: + { + inline Class retframe_Class(void *rframe) + { + __builtin_return (rframe); + } + *(Class*)buffer = retframe_Class(retframe); + break; + } + + case _C_SEL: + { + inline SEL retframe_SEL(void *rframe) + { + __builtin_return (rframe); + } + *(SEL*)buffer = retframe_SEL(retframe); + break; + } + + case _C_CHR: + case _C_UCHR: + { + inline unsigned char retframe_char(void *rframe) + { + __builtin_return (rframe); + } + *(unsigned char*)buffer = retframe_char(retframe); + break; + } + + case _C_SHT: + case _C_USHT: + { + inline unsigned short retframe_short(void *rframe) + { + __builtin_return (rframe); + } + *(unsigned short*)buffer = retframe_short(retframe); + break; + } + + case _C_INT: + case _C_UINT: + { + inline unsigned int retframe_int(void *rframe) + { + __builtin_return (rframe); + } + *(unsigned int*)buffer = retframe_int(retframe); + break; + } + + case _C_LNG: + case _C_ULNG: + { + inline unsigned long retframe_long(void *rframe) + { + __builtin_return (rframe); + } + *(unsigned long*)buffer = retframe_long(retframe); + break; + } + + case _C_LNG_LNG: + case _C_ULNG_LNG: + { + inline unsigned long long retframe_longlong(void *rframe) + { + __builtin_return (rframe); + } + *(unsigned long long*)buffer = retframe_longlong(retframe); + break; + } + + case _C_FLT: + { + inline float retframe_float(void *rframe) + { + __builtin_return (rframe); + } + *(float*)buffer = retframe_float(retframe); + break; + } + + case _C_DBL: + { + inline double retframe_double(void *rframe) + { + __builtin_return (rframe); + } + *(double*)buffer = retframe_double(retframe); + break; + } + + case _C_PTR: + case _C_ATOM: + case _C_CHARPTR: + { + inline char* retframe_pointer(void *rframe) + { + __builtin_return (rframe); + } + *(char**)buffer = retframe_pointer(retframe); + break; + } + + case _C_ARY_B: + case _C_STRUCT_B: + case _C_UNION_B: + { + typedef struct { + char val[4]; + } block; + inline block retframe_block(void *rframe) + { + __builtin_return (rframe); + } + *(block*)buffer = retframe_block(retframe); + break; + } + + case _C_VOID: + break; + + default: + return NO; /* Unknown type. */ + } + return YES; +} + + + +void* +mframe_handle_return(const char* type, void* retval, arglist_t argframe) +{ + retval_t retframe; + + retframe = alloca(MFRAME_RESULT_SIZE); + + switch (*type) + { + case _C_VOID: + break; + case _C_CHR: + case _C_UCHR: + return apply_char(*(char*)retval); + case _C_DBL: + return apply_double(*(double*)retval); + case _C_FLT: + return apply_float(*(float*)retval); + case _C_SHT: + case _C_USHT: + return apply_short(*(short*)retval); + case _C_ARY_B: + case _C_UNION_B: + case _C_STRUCT_B: + { + int size = objc_sizeof_type(type); +#if 1 + void *dest; + + dest = MFRAME_GET_STRUCT_ADDR(argframe, type); + memcpy(dest, retval, size); +#else + if (size > 8) + { + return apply_block(*(void**)retval); + } + else + { + memcpy(retframe, retval, size); + } +#endif + break; + } + default: + memcpy(retframe, retval, objc_sizeof_type(type)); + break; + } + + return retframe; +} + diff --git a/Source/mframe/.cvsignore b/Source/mframe/.cvsignore new file mode 100644 index 000000000..8ad26a03d --- /dev/null +++ b/Source/mframe/.cvsignore @@ -0,0 +1,2 @@ +config.log +config.status diff --git a/Source/mframe/README b/Source/mframe/README new file mode 100644 index 000000000..2ebdb6800 --- /dev/null +++ b/Source/mframe/README @@ -0,0 +1,155 @@ + + This directory contains files used for the 'mframe' software in gstep-base. + + These files are part of the GNUstep Base Library. + + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + + The code in this directory was written by + Richard Frith-Macdonald . + Inspiration for (and some of the code of) this software came from the + original mframe.m by Andrew McCallum, the gcc compiler, and the + libFoundation software by Ovidiu Predescu and Mircea Oancea. + The algorithms used are copied from gcc and are copyright the Free + Software Foundation. Many code fragments are derived from gcc either + directly or by way of libFoundation. + + The sections of code (and comments) to do with the MFRAME_ARG_ENCODING() + macro for sparc, hppa and powerpc were derived in part from libFoundation + (for which, much thanks) avoiding the need to extract the relevent details + directly from the gcc source in these cases. The originals from which + these fragments came the additional credit/copyright - + + Copyright (C) 1995, 1996, 1998 Ovidiu Predescu and Mircea Oancea. + All rights reserved. + + Author: Ovidiu Predescu + + This file is part of libFoundation. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, provided + that the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. + + We disclaim all warranties with regard to this software, including all + implied warranties of merchantability and fitness, in no event shall + we be liable for any special, indirect or consequential damages or any + damages whatsoever resulting from loss of use, data or profits, whether in + an action of contract, negligence or other tortious action, arising out of + or in connection with the use or performance of this software. + + +Purpose - + + The files in these directories are used by the configuration script to build + a machine/operating-system specific 'mframe.h' file containing macros used + to access stack frames. + The 'mframe.h' file is simply built by wrapping a system dependent file + between mframe.head and mframe.foot + +Advice on porting - + + See unknown/generic for an example of the following macros + +MFRAME_STACK_STRUCT + This should be defined to 1 if functions return structures by value + using the method where the caller places a pointer on the stack. + Define this to 0 otherwise (eg. when the pointer to the structure is + passed in a register). + +MFRAME_SMALL_STRUCT + This is the size of the largest structure returned by value on + the stack. Normally gcc returns structures of up to 8 bytes on + the stack. If your system never returns structures on the stack, + set this to zero rather than 8. + NB. If __builtin_apply_args() always returns an argframe for + structure return via pointer, you should also define this to zero. + +MFRAME_STRUCT_BYREF + This should be defined to 1 if structure arguments are passed in + the stack frame by reference, 0 otherwise. + +MFRAME_ARGS_SIZE + This must be set to the value computed by the apply_args_size() + function in expr.c in the gcc source. It is the size of the + area of memory allocated in which to pass arguments to a function. + If you can't figure out how to determine this (hack expr.c to print + the result of the function the first time it's called) - try using a + value like 128 - which will probably be far larger than required + (and therefore somewhat inefficient) but will most likely work. + +MFRAME_RESULT_SIZE + This must be set to the value computed by the apply_result_size() + function in expr.c in the gcc source. It is the size of the area + of memory allocated in which to return a value from a function. + If you can't figure out how to determine this (hack expr.c to print + the result of the function the first time it's called) - try using a + value like 128 - which will probably be far larger than required + (and therefore somewhat inefficient) but will most likely work. + +MFRAME_FLT_IN_FRAME_AS_DBL + This should be defined as 1 if float parameters to functions and + objective-c methods are passed on the stack as double values. + Otherwise it should not be defined. + +MFRAME_STRUCT_ADDR(ARGFRAME,TYPES) + If a function returns a structure by copying it into a location + whose address is set by the caller, this macro must return that + address within the argframe. + Otherwise the macro must return zero. + +MFRAME_ARGS + This macro should define a data type to be used for recording + information about the arguments list of a method. + See 'CUMULATIVE_ARGS' in the configuration file for your system + in gcc for a parallel example. + +MFRAME_INIT_ARGS(CUM, RTYPE) + This macro is used to initialise a variable (CUM) of the type + defined by MFRAME_ARGS. The RTYPE value is the type encoding for the + method return type, it is needed so that CUM can take int account any + invisible first argument used for returning structures by value. + See 'INIT_CUMULATIVE_ARGS' in the configuration file for your system + in gcc for a parallel example. + +MFRAME_ARG_ENCODING(CUM,TYPES,STACK,DEST) + This macro is used to to determine the encoding of arguments. + You will have to write this macro for your system by examining the + gcc source code to determine how the compiler does this on your + system - look for the usage of CUMULATIVE_ARGS an INIT_CUMULATIVE_ARGS + in the configuration files for your hardware and operating system in + the gcc (or egcs) source, and make your macro mirror it's operation. + + Before initial entry, + CUM should have been initialised using the MFRAME_INIT_ARGS() macro, + TYPES should be a (const char*) variable initialised to a + type-encoding string listing the arguments of a function/method, + STACK should be an integer variable of value 0 in which the size of + the stack arguments will be accumulated, + DEST should be a (char*) variable initialised to a pointer to a + buffer into which the full type encoding will be written. + After each use of the macro, TYPES is advanced to point to the next + argument, and DEST is advanced to point after the encoding of the + previous argument. + Of course, you must ensure that the buffer pointed to by DEST is + large enough so that it does not overflow! + You will be safe if your buffer is at least ten times as big as + the type-encoding string you start from. + + diff --git a/Source/mframe/alpha/generic b/Source/mframe/alpha/generic new file mode 100644 index 000000000..9ce0ba1cb --- /dev/null +++ b/Source/mframe/alpha/generic @@ -0,0 +1,91 @@ +/* See ../README for copyright */ + +/* + * First six arguments are passed in registers with small (< sizeof(void*)) + * values occupying the space of a pointer. + * If the method returns a structure, it's address is passed as an invisible + * first argument. + */ + +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 104 +#define MFRAME_RESULT_SIZE 16 +#define MFRAME_FLT_IN_FRAME_AS_DBL 0 + +/* + * Structures are passed by reference as an invisible first argument, so + * they go in the first space on the stack. + */ +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + ((void**)(ARGS))[1] : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + ((void**)(ARGS))[1] = (ADDR);}) + +/* + * Declare a type for keeping track of the arguments processed. + */ +typedef struct alpha_args { + int reg_pos; + int stk_pos; +} MFRAME_ARGS; + + +/* + * Initialize a variable to keep track of argument info while processing a + * method. Keeps count of the offset of arguments on the stack. + * This offset is adjusted to take account of an invisible first argument + * used to return structures. + */ + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).reg_pos = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? 16 : 8; \ + (CUM).stk_pos = 0; \ +}) + +/* + * Define maximum register offset - after this, stuff goes on the stack. + */ +#define ALPHAMAXR 56 + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align, size; \ +\ + (TYPE) = objc_skip_typespec(type); \ + align = objc_alignof_type (type); \ + size = objc_sizeof_type (type); \ + size = ROUND(size, sizeof(void*)); \ +\ + if ((CUM).reg_pos + size > ALPHAMAXR) (CUM).reg_pos = ALPHAMAXR; \ + if ((CUM).reg_pos == ALPHAMAXR) \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stk_pos); \ + (CUM).stk_pos += size; \ + (STACK) = (CUM).stk_pos; \ + } \ + else \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).reg_pos); \ + (CUM).reg_pos += size; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + if (*(TYPE) == '-') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ +}) diff --git a/Source/mframe/alpha/linux-gnu b/Source/mframe/alpha/linux-gnu new file mode 100644 index 000000000..352c81617 --- /dev/null +++ b/Source/mframe/alpha/linux-gnu @@ -0,0 +1,87 @@ +/* See ../README for copyright */ + +/* + * First six arguments are passed in registers with small (< sizeof(void*)) + * values occupying the space of a pointer. + * If the method returns a structure, it's address is passed as an invisible + * first argument. + */ + +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 104 +#define MFRAME_RESULT_SIZE 16 +#define MFRAME_FLT_IN_FRAME_AS_DBL 0 + +/* + * Structures are passed by reference as an invisible first argument, so + * they go in the first space on the stack. + */ +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + ((void**)(ARGS))[1] : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + ((void**)(ARGS))[1] = (ADDR);}) + +/* + * Declare a type for keeping track of the arguments processed. + */ +typedef struct alpha_args { + int reg_pos; + int stk_pos; +} MFRAME_ARGS; + + +/* + * Initialize a variable to keep track of argument info while processing a + * method. Keeps count of the offset of arguments on the stack. + * This offset is adjusted to take account of an invisible first argument + * used to return structures. + */ + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).reg_pos = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? 16 : 8; \ + (CUM).stk_pos = 0; \ +}) + +/* + * Define maximum register offset - after this, stuff goes on the stack. + */ +#define ALPHAMAXR 56 + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align, size; \ +\ + (TYPE) = objc_skip_typespec(type); \ + align = objc_alignof_type (type); \ + size = objc_sizeof_type (type); \ + size = ROUND(size, sizeof(void*)); \ +\ + if ((CUM).reg_pos + size > ALPHAMAXR) (CUM).reg_pos = ALPHAMAXR; \ + if ((CUM).reg_pos == ALPHAMAXR) \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stk_pos); \ + (CUM).stk_pos += size; \ + (STACK) = (CUM).stk_pos; \ + } \ + else \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).reg_pos); \ + (CUM).reg_pos += size; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ +}) diff --git a/Source/mframe/configure b/Source/mframe/configure new file mode 100755 index 000000000..a961c3e78 --- /dev/null +++ b/Source/mframe/configure @@ -0,0 +1,1790 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.53. +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + + +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# NLS nuisances. +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +(set +x; test -n "`(LANG=C; export LANG) 2>&1`") && + { $as_unset LANG || test "${LANG+set}" != set; } || + { LANG=C; export LANG; } +(set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && + { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || + { LC_ALL=C; export LC_ALL; } +(set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && + { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || + { LC_TIME=C; export LC_TIME; } +(set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && + { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || + { LC_CTYPE=C; export LC_CTYPE; } +(set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && + { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || + { LANGUAGE=C; export LANGUAGE; } +(set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && + { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || + { LC_COLLATE=C; export LC_COLLATE; } +(set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && + { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || + { LC_NUMERIC=C; export LC_NUMERIC; } +(set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && + { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || + { LC_MESSAGES=C; export LC_MESSAGES; } + + +# Name of the executable. +as_me=`(basename "$0") 2>/dev/null || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conftest.sh + echo "exit 0" >>conftest.sh + chmod +x conftest.sh + if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conftest.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="mframe.head" + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# 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. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +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 + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -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 | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$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 ;; + + -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 ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + 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 ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=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 ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +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 + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + 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 + + +# 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 its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + 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 + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias + +# +# 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 this package 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 \`..'] + +_ACEOF + + cat <<_ACEOF +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] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --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] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style 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 + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.53. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +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` +hostinfo = `(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=. + echo "PATH: $as_dir" +done + +} >&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. +# Also quote any args containing shell meta-characters. +ac_configure_args= +ac_sep= +for ac_arg +do + case $ac_arg in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n ) continue ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + ac_sep=" " ;; + esac + # Get rid of the leading space. +done + +# 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: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >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 + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + 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. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +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 `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; 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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`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. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +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 + + + + + + + + + + + + + + + + + + + + +#-------------------------------------------------------------------- +# Use config.guess, config.sub and install-sh provided by gnustep-make +#-------------------------------------------------------------------- +ac_aux_dir= +for ac_dir in $GNUSTEP_MAKEFILES $srcdir/$GNUSTEP_MAKEFILES; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $GNUSTEP_MAKEFILES $srcdir/$GNUSTEP_MAKEFILES" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $GNUSTEP_MAKEFILES $srcdir/$GNUSTEP_MAKEFILES" >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + + +#-------------------------------------------------------------------- +# Determine the host, build, and target systems +#-------------------------------------------------------------------- +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6 +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_target_alias=$target_alias +test "x$ac_cv_target_alias" = "x" && + ac_cv_target_alias=$ac_cv_host_alias +ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6 +target=$ac_cv_target +target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + +case "$target_cpu" in + alpha*) target_cpu=alpha;; + hppa*) target_cpu=hppa;; + i[3456]86*) target_cpu=i386;; + sparc*) target_cpu=sparc;; +esac + +case "$target_os" in + freebsd*) target_os=freebsd;; + openbsd*) target_os=openbsd;; + darwin*) target_os=darwin;; +esac + + +if test -d $target_cpu -a "`echo $target_cpu/*`" != "$target_cpu/*" +then + my_dir=$target_cpu +else + echo '*************** Warning ****************' + echo The 'mframe' software has not been ported to $target_cpu. + echo Using information from unknown. + echo '****************************************' + my_dir=unknown +fi + +if test -f $my_dir/$target_os +then + my_path=$my_dir/$target_os + echo Using information from $my_path. +else + echo '*************** Warning ****************' + echo The 'mframe' software has not been ported to $target_cpu-$target_os. + echo Using information from $my_dir/generic. + echo '****************************************' + my_path=$my_dir/generic +fi + +rm -f mframe.h +echo "/***************** WARNING ****************" > mframe.h +echo "* DO NOT EDIT THIS FILE DIRECTLY - IT IS *" >> mframe.h +echo "* GENERATED AUTOMATICALLY BY THE CONFIG *" >> mframe.h +echo "* PROCESS IN THE 'mframe' SUBDIRECTORY. *" >> mframe.h +echo "****************** WARNING ***************/" >> mframe.h +cat mframe.head $my_path mframe.foot >> mframe.h + +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 overriden 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, don't put newlines in cache variables' values. +# 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. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *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 \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if cmp -s $cache_file confcache; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + 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}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ 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[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +# 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 we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $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 +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# NLS nuisances. +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +(set +x; test -n "`(LANG=C; export LANG) 2>&1`") && + { $as_unset LANG || test "${LANG+set}" != set; } || + { LANG=C; export LANG; } +(set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && + { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || + { LC_ALL=C; export LC_ALL; } +(set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && + { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || + { LC_TIME=C; export LC_TIME; } +(set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && + { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || + { LC_CTYPE=C; export LC_CTYPE; } +(set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && + { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || + { LANGUAGE=C; export LANGUAGE; } +(set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && + { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || + { LC_COLLATE=C; export LC_COLLATE; } +(set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && + { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || + { LC_NUMERIC=C; export LC_NUMERIC; } +(set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && + { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || + { LC_MESSAGES=C; export LC_MESSAGES; } + + +# Name of the executable. +as_me=`(basename "$0") 2>/dev/null || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + +# PATH needs CR, and LINENO needs CR and PATH. +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conftest.sh + echo "exit 0" >>conftest.sh + chmod +x conftest.sh + if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conftest.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + 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 + + ;; + 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 + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # 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 sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.53. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.53, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + shift + set dummy "$ac_option" "$ac_optarg" ${1+"$@"} + shift + ;; + -*);; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_need_defaults=false;; + esac + + case $1 in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" + exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + shift + CONFIG_FILES="$CONFIG_FILES $1" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + shift + CONFIG_HEADERS="$CONFIG_HEADERS $1" + ac_need_defaults=false;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +_ACEOF + + + + + + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# 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=: + exec 5>/dev/null + $SHELL $CONFIG_STATUS || 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 || { (exit 1); exit 1; } +fi + diff --git a/Source/mframe/configure.ac b/Source/mframe/configure.ac new file mode 100644 index 000000000..6b03f3325 --- /dev/null +++ b/Source/mframe/configure.ac @@ -0,0 +1,83 @@ +# configure.in for mframe software +# Process this file with autoconf to produce a configure script. +# +# Copyright (C) 1998 Free Software Foundation, Inc. +# +# Written by: Richard Frith-Macdonald +# +# This file is part of the GNUstep project +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library 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 +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +AC_INIT +AC_CONFIG_SRCDIR([mframe.head]) + +#-------------------------------------------------------------------- +# Use config.guess, config.sub and install-sh provided by gnustep-make +#-------------------------------------------------------------------- +AC_CONFIG_AUX_DIR($GNUSTEP_MAKEFILES) + +#-------------------------------------------------------------------- +# Determine the host, build, and target systems +#-------------------------------------------------------------------- +AC_CANONICAL_TARGET([]) + +dnl Checking CPU and Operating-System information for mframe.h + +case "$target_cpu" in + alpha*) target_cpu=alpha;; + hppa*) target_cpu=hppa;; + i[[3456]]86*) target_cpu=i386;; + sparc*) target_cpu=sparc;; +esac + +case "$target_os" in + freebsd*) target_os=freebsd;; + openbsd*) target_os=openbsd;; + darwin*) target_os=darwin;; +esac + + +if test -d $target_cpu -a "`echo $target_cpu/*`" != "$target_cpu/*" +then + my_dir=$target_cpu +else + echo '*************** Warning ****************' + echo The 'mframe' software has not been ported to $target_cpu. + echo Using information from unknown. + echo '****************************************' + my_dir=unknown +fi + +if test -f $my_dir/$target_os +then + my_path=$my_dir/$target_os + echo Using information from $my_path. +else + echo '*************** Warning ****************' + echo The 'mframe' software has not been ported to $target_cpu-$target_os. + echo Using information from $my_dir/generic. + echo '****************************************' + my_path=$my_dir/generic +fi + +rm -f mframe.h +echo "/***************** WARNING ****************" > mframe.h +echo "* DO NOT EDIT THIS FILE DIRECTLY - IT IS *" >> mframe.h +echo "* GENERATED AUTOMATICALLY BY THE CONFIG *" >> mframe.h +echo "* PROCESS IN THE 'mframe' SUBDIRECTORY. *" >> mframe.h +echo "****************** WARNING ***************/" >> mframe.h +cat mframe.head $my_path mframe.foot >> mframe.h + +AC_OUTPUT diff --git a/Source/mframe/hppa/generic b/Source/mframe/hppa/generic new file mode 100644 index 000000000..32a98bbc9 --- /dev/null +++ b/Source/mframe/hppa/generic @@ -0,0 +1,56 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 1 +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 8 +#define MFRAME_ARGS_SIZE 56 +#define MFRAME_RESULT_SIZE 16 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + **(void***)(ARGS) : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + **(void***)(ARGS) = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + if (*(TYPE) == '-') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + ((((CUM) & 01) && ((size+3)/4) > 1) && (CUM)++); \ + (CUM) += ((size+3)/4); \ +}) + diff --git a/Source/mframe/i386/freebsd b/Source/mframe/i386/freebsd new file mode 100644 index 000000000..727429198 --- /dev/null +++ b/Source/mframe/i386/freebsd @@ -0,0 +1,48 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') (TYPE)++; \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/i386/generic b/Source/mframe/i386/generic new file mode 100644 index 000000000..df30c136c --- /dev/null +++ b/Source/mframe/i386/generic @@ -0,0 +1,49 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') (TYPE)++; \ + if (*(TYPE) == '-') (TYPE)++; \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/i386/linux b/Source/mframe/i386/linux new file mode 100644 index 000000000..3eef54dc7 --- /dev/null +++ b/Source/mframe/i386/linux @@ -0,0 +1,51 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 1 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/i386/linux-gnu b/Source/mframe/i386/linux-gnu new file mode 100644 index 000000000..3eef54dc7 --- /dev/null +++ b/Source/mframe/i386/linux-gnu @@ -0,0 +1,51 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 1 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/i386/openbsd b/Source/mframe/i386/openbsd new file mode 100644 index 000000000..727429198 --- /dev/null +++ b/Source/mframe/i386/openbsd @@ -0,0 +1,48 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') (TYPE)++; \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/i386/sysv4.2MP b/Source/mframe/i386/sysv4.2MP new file mode 100644 index 000000000..9d28d1512 --- /dev/null +++ b/Source/mframe/i386/sysv4.2MP @@ -0,0 +1,51 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/i386/sysv4.2uw2.1.3 b/Source/mframe/i386/sysv4.2uw2.1.3 new file mode 100644 index 000000000..9d28d1512 --- /dev/null +++ b/Source/mframe/i386/sysv4.2uw2.1.3 @@ -0,0 +1,51 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 8 +#define MFRAME_RESULT_SIZE 116 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(ARGS)->arg_ptr : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(ARGS)->arg_ptr = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/mframe.foot b/Source/mframe/mframe.foot new file mode 100644 index 000000000..ba8f5d49c --- /dev/null +++ b/Source/mframe/mframe.foot @@ -0,0 +1,101 @@ + +inline static void* +mframe_arg_addr(arglist_t argf, NSArgumentInfo *info) +{ + int offset = info->offset; +#if WORDS_BIGENDIAN + if (info->size < sizeof(int)) + { + offset += sizeof(int) - info->size; + } +#endif +#if NeXT_RUNTIME + return marg_getRef(argf, offset, void); +#else + if (info->isReg) + { + return(argf->arg_regs + offset); + } + else + { + return(argf->arg_ptr + offset); + } +#endif +} + +inline static void +mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer) +{ +#if MFRAME_STRUCT_BYREF || MFRAME_FLT_IN_FRAME_AS_DBL + const char *typ = info->type; +#endif +#if MFRAME_STRUCT_BYREF + + /* + * If structures are passed in the stack frame by reference - we need + * to copy the actual structure, rather than it's pointer. + */ + if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) + { + memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size); + } + else +#endif +#if MFRAME_FLT_IN_FRAME_AS_DBL + if (*typ == _C_FLT) + { + *(float*)buffer = (float)*(double*)mframe_arg_addr(argf, info); + } + else +#endif + memcpy(buffer, mframe_arg_addr(argf, info), info->size); +} + +inline static void +mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer) +{ +#if MFRAME_STRUCT_BYREF || MFRAME_FLT_IN_FRAME_AS_DBL + const char *typ = info->type; +#endif +#if MFRAME_STRUCT_BYREF + + /* + * If structures are passed in the stack frame by reference - we need + * to copy a pointer onto the stack rather than the actual structure. + */ + if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) + { + memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*)); + } + else +#endif +#if MFRAME_FLT_IN_FRAME_AS_DBL + if (*typ == _C_FLT) + { + *(double*)mframe_arg_addr(argf, info) = *(float*)buffer; + } + else +#endif + memcpy(mframe_arg_addr(argf, info), buffer, info->size); +} + +inline static void +mframe_cpy_arg(arglist_t dst, arglist_t src, NSArgumentInfo *info) +{ +#if MFRAME_STRUCT_BYREF + const char *typ = info->type; + + /* + * If structures are passed in the stack frame by reference - we need + * to copy a pointer onto the stack rather than the actual structure. + */ + if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) + { + memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*)); + } + else +#endif + memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), info->size); +} + +#endif /* __mframe_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Source/mframe/mframe.head b/Source/mframe/mframe.head new file mode 100644 index 000000000..797c65bd6 --- /dev/null +++ b/Source/mframe/mframe.head @@ -0,0 +1,127 @@ +/* Interface for functions that dissect/make method calls + Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. + + Written by: Andrew Kachites McCallum + Created: Oct 1994 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#ifndef __mframe_h_GNUSTEP_BASE_INCLUDE +#define __mframe_h_GNUSTEP_BASE_INCLUDE + +#include "GNUstepBase/preface.h" + +#ifdef HAVE_MALLOC_H +#include +#endif + +#include "GNUstepBase/DistributedObjects.h" + +/* For NSArgumentInfo we include NSMethodSignature.h */ +#include "Foundation/NSMethodSignature.h" + +#if NeXT_runtime +typedef union { + char *arg_ptr; + char arg_regs[sizeof (char*)]; +} *arglist_t; +#endif + +/* These functions are used to pull apart method calls, and put them + back together again. They are useful for things like distributed + objects, and cross-language communication glue between Objective C + and other languages. */ + +/* xxx Currently these function only work with the GNU Objective C + runtime, not the NeXT runtime. */ + + +/* Extract the arguments to a method call, as found in ARGFRAME, + according to type string TYPES, and encode them by calling ENCODER. + Return YES if and only if the method has some pass-by-reference + arguments. */ + +BOOL +mframe_dissect_call (arglist_t argframe, const char *types, + void (*encoder)(DOContext*), DOContext *ctxt); + +/* Decode the arguments to a method call by calling DECODER, knowing + what to decode by looking at type string ENCODED_TYPES. Build an + argframe of type arglist_t, and invoke the method. Then encode the + return value and the pass-by-reference values using ENCODER. */ + +void +mframe_do_call (DOContext *ctxt, + void(*decoder)(DOContext*), + void(*encoder)(DOContext*)); + +/* Decode the return value and pass-by-reference arguments using + DECODER, knowning what to decode by looking at type string TYPES + and OUT_PARAMETERS, and put then into ARGFRAME. Return the + retval_t structure that can be passed to __builtin_return(). */ + +retval_t +mframe_build_return (arglist_t argframe, const char *types, + BOOL out_parameters, + void(*decoder)(DOContext*), DOContext *ctxt); + +/* + * Copy the return value from retframe into the specified buffer. + */ +BOOL +mframe_decode_return(const char *type, void* buffer, void* retframe); + +/* + * Return the value of the specified type in 'retval' using argFrame. + */ +void* +mframe_handle_return(const char* type, void* retval, arglist_t argFrame); + +/* + * Step through method encoding information extracting details. + */ +const char * +mframe_next_arg(const char *typePtr, NSArgumentInfo *info); + +/* + * Generate method encoding with stack/register offsets from a simple + * type encoding string. Store results in 'buf' or allocate memory + * using objc_malloc() if 'buf' is a nul pointer. + */ +char* +mframe_build_signature(const char *typePtr, int *size, int *narg, char *buf); + + +arglist_t +mframe_create_argframe(const char *types, void** retbuf); + +void +mframe_destroy_argframe(const char *types, arglist_t argframe); + +#define ROUND(V, A) \ + ({ typeof(V) __v=(V); typeof(A) __a=(A); \ + __a*((__v+__a-1)/__a); }) + + +int method_types_get_sizeof_arguments (struct objc_method* mth); +char* method_types_get_next_argument (arglist_t argf, const char **type); +char* method_types_get_first_argument (struct objc_method* m, + arglist_t argframe, + const char** type); + + diff --git a/Source/mframe/powerpc/darwin b/Source/mframe/powerpc/darwin new file mode 100644 index 000000000..e4aa6ee43 --- /dev/null +++ b/Source/mframe/powerpc/darwin @@ -0,0 +1,121 @@ +/* See ../README for copyright */ + +/* + * The first eight words of non-FP are in registers (offset 4 in frame). + * The first 13 FP args are in registers (offset 40 in frame). + * If the method returns a structure, it's address is passed as an invisible + * first argument, so only seven words of non-FP are passed in the registers. + * Structures are always passed by reference. + * Floats are placed in the frame as doubles. + */ + +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 144 +#define MFRAME_RESULT_SIZE 16 +#define MFRAME_FLT_IN_FRAME_AS_DBL 1 + +/* + * Structures are passed by reference as an invisible first argument, so + * they go in the first register space for non-FP arguments - at offset 4. + */ +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(((char*)(ARGS))+4): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(((char*)(ARGS))+4) = (ADDR);}) + +/* + * Typedef for structure to keep track of argument info while processing + * a method. + */ +typedef struct rs6000_args +{ + int int_args; /* Number of integer arguments so far. */ + int float_args; /* Number of FP arguments so far. */ + int regs_position; /* The current position for non-FP args. */ + int stack_position; /* The current position in the stack frame. */ +} MFRAME_ARGS; + + +/* + * Initialize a variable to keep track of argument info while processing a + * method. Keeps count of the number of arguments of each type seen and + * the current offset in the non-FP registers. This offset is adjusted + * to take account of an invisible first argument used to return structures. + */ + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).int_args = 0; \ + (CUM).float_args = 0; \ + (CUM).stack_position = 0; \ + (CUM).regs_position = \ + ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || *(RTYPE)==_C_ARY_B) ? \ + sizeof(void*) : 4); \ +}) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ +\ + (TYPE) = objc_skip_typespec(type); \ + if (*type == _C_FLT || *type == _C_DBL) \ + { \ + if (++(CUM).float_args > 13) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, \ + __alignof__(double)); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, sizeof(double)); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, \ + 40 + sizeof (double) * ((CUM).float_args - 1)); \ + } \ + } \ + else \ + { \ + int align, size; \ +\ + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) \ + { \ + align = __alignof__(void*); \ + size = sizeof (void*); \ + } \ + else \ + { \ + align = __alignof__(int); \ + size = objc_sizeof_type (type); \ + } \ +\ + if (++(CUM).int_args > 8) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, align); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, size); \ + } \ + else \ + { \ + (CUM).regs_position = ROUND((CUM).regs_position, align); \ + sprintf(dest, "%.*s+%d", (TYPE)-type, type, (CUM).regs_position); \ + (CUM).regs_position += ROUND (size, align); \ + } \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + if (*(TYPE) == '-') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ +}) diff --git a/Source/mframe/powerpc/generic b/Source/mframe/powerpc/generic new file mode 100644 index 000000000..6465860a9 --- /dev/null +++ b/Source/mframe/powerpc/generic @@ -0,0 +1,121 @@ +/* See ../README for copyright */ + +/* + * The first eight words of non-FP are in registers (offset 4 in frame). + * The first 13 FP args are in registers (offset 40 in frame). + * If the method returns a structure, it's address is passed as an invisible + * first argument, so only seven words of non-FP are passed in the registers. + * Structures are always passed by reference. + * Floats are placed in the frame as doubles. + */ + +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 144 +#define MFRAME_RESULT_SIZE 16 +#define MFRAME_FLT_IN_FRAME_AS_DBL 1 + +/* + * Structures are passed by reference as an invisible first argument, so + * they go in the first register space for non-FP arguments - at offset 4. + */ +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(((char*)(ARGS))+4): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(((char*)(ARGS))+4) = (ADDR);}) + +/* + * Typedef for structure to keep track of argument info while processing + * a method. + */ +typedef struct rs6000_args +{ + int int_args; /* Number of integer arguments so far. */ + int float_args; /* Number of FP arguments so far. */ + int regs_position; /* The current position for non-FP args. */ + int stack_position; /* The current position in the stack frame. */ +} MFRAME_ARGS; + + +/* + * Initialize a variable to keep track of argument info while processing a + * method. Keeps count of the number of arguments of each type seen and + * the current offset in the non-FP registers. This offset is adjusted + * to take account of an invisible first argument used to return structures. + */ + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).int_args = 0; \ + (CUM).float_args = 0; \ + (CUM).stack_position = 0; \ + (CUM).regs_position = \ + ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || *(RTYPE)==_C_ARY_B) ? \ + sizeof(void*) : 4); \ +}) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ +\ + (TYPE) = objc_skip_typespec(type); \ + if (*type == _C_FLT || *type == _C_DBL) \ + { \ + if (++(CUM).float_args > 13) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, \ + __alignof__(double)); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, sizeof(double)); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, \ + 40 + sizeof (double) * ((CUM).float_args - 1)); \ + } \ + } \ + else \ + { \ + int align, size; \ +\ + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) \ + { \ + align = __alignof__(void*); \ + size = sizeof (void*); \ + } \ + else \ + { \ + align = __alignof__(int); \ + size = objc_sizeof_type (type); \ + } \ +\ + if (++(CUM).int_args > 8) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, align); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, size); \ + } \ + else \ + { \ + (CUM).regs_position = ROUND((CUM).regs_position, align); \ + sprintf(dest, "%.*s+%d", (TYPE)-type, type, (CUM).regs_position); \ + (CUM).regs_position += ROUND (size, align); \ + } \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + if (*(TYPE) == '-') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ +}) diff --git a/Source/mframe/powerpc/linux-gnu b/Source/mframe/powerpc/linux-gnu new file mode 100644 index 000000000..1e796a1de --- /dev/null +++ b/Source/mframe/powerpc/linux-gnu @@ -0,0 +1,123 @@ +/* See ../README for copyright */ + +/* + * The first eight words of non-FP are in registers (offset 4 in frame). + * The first 13 FP args are in registers (offset 40 in frame). + * If the method returns a structure, it's address is passed as an invisible + * first argument, so only seven words of non-FP are passed in the registers. + * Structures are always passed by reference. + * Floats are placed in the frame as doubles. + */ + +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 144 +#define MFRAME_RESULT_SIZE 16 +#define MFRAME_FLT_IN_FRAME_AS_DBL 1 + +/* + * Structures are passed by reference as an invisible first argument, so + * they go in the first register space for non-FP arguments - at offset 4. + */ +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(((char*)(ARGS))+4): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(((char*)(ARGS))+4) = (ADDR);}) + +/* + * Typedef for structure to keep track of argument info while processing + * a method. + */ +typedef struct rs6000_args +{ + int int_args; /* Number of integer arguments so far. */ + int float_args; /* Number of FP arguments so far. */ + int regs_position; /* The current position for non-FP args. */ + int stack_position; /* The current position in the stack frame. */ +} MFRAME_ARGS; + + +/* + * Initialize a variable to keep track of argument info while processing a + * method. Keeps count of the number of arguments of each type seen and + * the current offset in the non-FP registers. This offset is adjusted + * to take account of an invisible first argument used to return structures. + */ + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).int_args = 0; \ + (CUM).float_args = 0; \ + (CUM).stack_position = 0; \ + (CUM).regs_position = \ + ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || *(RTYPE)==_C_ARY_B) ? \ + sizeof(void*) : 4); \ +}) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ +\ + (TYPE) = objc_skip_typespec(type); \ + if (*type == _C_FLT || *type == _C_DBL) \ + { \ + if (++(CUM).float_args > 13) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, \ + __alignof__(double)); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, sizeof(double)); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, \ + 40 + sizeof (double) * ((CUM).float_args - 1)); \ + } \ + } \ + else \ + { \ + int align, size; \ +\ + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) \ + { \ + align = __alignof__(void*); \ + size = sizeof (void*); \ + } \ + else \ + { \ + align = __alignof__(int); \ + size = objc_sizeof_type (type); \ + } \ +\ + if (++(CUM).int_args > 8) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, align); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, size); \ + } \ + else \ + { \ + (CUM).regs_position = ROUND((CUM).regs_position, align); \ + /* FIXME: This mostly accounts for the addition in mframe_arg_addr \ + due to WORDS_BIGENDIAN */ \ + if (*type == _C_STRUCT_B && objc_sizeof_type(type) < sizeof(int)) \ + (CUM).regs_position -= sizeof(int) - objc_sizeof_type(type); \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).regs_position); \ + if (*type == _C_STRUCT_B && objc_sizeof_type(type) < sizeof(int)) \ + (CUM).regs_position += sizeof(int) - objc_sizeof_type(type); \ + (CUM).regs_position += ROUND (size, align); \ + } \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ +}) diff --git a/Source/mframe/powerpc/linux-gnulibc1 b/Source/mframe/powerpc/linux-gnulibc1 new file mode 100644 index 000000000..8c94391e3 --- /dev/null +++ b/Source/mframe/powerpc/linux-gnulibc1 @@ -0,0 +1,123 @@ +/* See ../README for copyright */ + +/* + * The first eight words of non-FP are in registers (offset 4 in frame). + * The first 13 FP args are in registers (offset 40 in frame). + * If the method returns a structure, it's address is passed as an invisible + * first argument, so only seven words of non-FP are passed in the registers. + * Structures are always passed by reference. + * Floats are placed in the frame as doubles. + */ + +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 144 +#define MFRAME_RESULT_SIZE 16 +#define MFRAME_FLT_IN_FRAME_AS_DBL 1 + +/* + * Structures are passed by reference as an invisible first argument, so + * they go in the first register space for non-FP arguments - at offset 4. + */ +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)(((char*)(ARGS))+4): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)(((char*)(ARGS))+4) = (ADDR);}) + +/* + * Typedef for structure to keep track of argument info while processing + * a method. + */ +typedef struct rs6000_args +{ + int int_args; /* Number of integer arguments so far. */ + int float_args; /* Number of FP arguments so far. */ + int regs_position; /* The current position for non-FP args. */ + int stack_position; /* The current position in the stack frame. */ +} MFRAME_ARGS; + + +/* + * Initialize a variable to keep track of argument info while processing a + * method. Keeps count of the number of arguments of each type seen and + * the current offset in the non-FP registers. This offset is adjusted + * to take account of an invisible first argument used to return structures. + */ + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).int_args = 0; \ + (CUM).float_args = 0; \ + (CUM).stack_position = 0; \ + (CUM).regs_position = \ + ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || *(RTYPE)==_C_ARY_B) ? \ + 4 + sizeof(void*) : 4); \ +}) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ +\ + (TYPE) = objc_skip_typespec(type); \ + if (*type == _C_FLT || *type == _C_DBL) \ + { \ + if (++(CUM).float_args > 13) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, \ + __alignof__(double)); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, sizeof(double)); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, \ + 40 + sizeof (double) * ((CUM).float_args - 1)); \ + } \ + } \ + else \ + { \ + int align, size; \ +\ + if (*type == _C_STRUCT_B || *type == _C_UNION_B || *type == _C_ARY_B) \ + { \ + align = __alignof__(void*); \ + size = sizeof (void*); \ + } \ + else \ + { \ + align = __alignof__(int); \ + size = objc_sizeof_type (type); \ + } \ +\ + if (++(CUM).int_args > 8) \ + { \ + (CUM).stack_position += ROUND ((CUM).stack_position, align); \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).stack_position); \ + (STACK) = ROUND ((CUM).stack_position, size); \ + } \ + else \ + { \ + (CUM).regs_position = ROUND((CUM).regs_position, align); \ + /* FIXME: This mostly accounts for the addition in mframe_arg_addr \ + due to WORDS_BIGENDIAN */ \ + if (*type == _C_STRUCT_B && objc_sizeof_type(type) < sizeof(int)) \ + (CUM).regs_position -= sizeof(int) - objc_sizeof_type(type); \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).regs_position); \ + if (*type == _C_STRUCT_B && objc_sizeof_type(type) < sizeof(int)) \ + (CUM).regs_position += sizeof(int) - objc_sizeof_type(type); \ + (CUM).regs_position += ROUND (size, align); \ + } \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ +}) diff --git a/Source/mframe/sparc/generic b/Source/mframe/sparc/generic new file mode 100644 index 000000000..c906b7ad0 --- /dev/null +++ b/Source/mframe/sparc/generic @@ -0,0 +1,93 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 32 +#define MFRAME_RESULT_SIZE 16 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) + +#define IN_REGS 0 +#define ON_STACK 1 + +struct sparc_args { + int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ + int onStack; +}; + +#define MFRAME_ARGS struct sparc_args + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ + (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ + (CUM).onStack = NO; \ +}) + +#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ +((CUM).onStack \ + ? ON_STACK \ + : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ + ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ + ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ + IN_REGS) \ + : ((CUM).onStack = YES, ON_STACK))) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ + int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ +\ + (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ + if (size < sizeof(int)) \ + { \ + (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ + } \ + (TYPE) = objc_skip_typespec(type); \ + if (locn == IN_REGS) \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + if (*(TYPE) == '-') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (locn == ON_STACK) \ + { \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + size; \ + } \ + } \ + (CUM).offsets[locn] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/sparc/solaris2.6 b/Source/mframe/sparc/solaris2.6 new file mode 100644 index 000000000..140836848 --- /dev/null +++ b/Source/mframe/sparc/solaris2.6 @@ -0,0 +1,87 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 32 +#define MFRAME_RESULT_SIZE 16 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) + +#define IN_REGS 0 +#define ON_STACK 1 + +struct sparc_args { + int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ + int onStack; +}; + +#define MFRAME_ARGS struct sparc_args + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ + (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ + (CUM).onStack = NO; \ +}) + +#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ +((CUM).onStack \ + ? ON_STACK \ + : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ + ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ + ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ + IN_REGS) \ + : ((CUM).onStack = YES, ON_STACK))) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ + int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ +\ + (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ + if (size < sizeof(int)) \ + (CUM).offsets[locn] -= (sizeof(int) - size); \ + (TYPE) = objc_skip_typespec(type); \ + if (locn == IN_REGS) \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (locn == ON_STACK) \ + { \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + size; \ + } \ + } \ + (CUM).offsets[locn] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/sparc/sunos4.1.3 b/Source/mframe/sparc/sunos4.1.3 new file mode 100644 index 000000000..9ff52f41a --- /dev/null +++ b/Source/mframe/sparc/sunos4.1.3 @@ -0,0 +1,89 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 32 +#define MFRAME_RESULT_SIZE 16 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \ + *(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \ + *(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);}) + +#define IN_REGS 0 +#define ON_STACK 1 + +struct sparc_args { + int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */ + int onStack; +}; + +#define MFRAME_ARGS struct sparc_args + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +({ \ + (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \ + (CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \ + (CUM).onStack = NO; \ +}) + +#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \ +((CUM).onStack \ + ? ON_STACK \ + : ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \ + ? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \ + ? 0 : ((CUM).offsets[ON_STACK] += 4)),\ + IN_REGS) \ + : ((CUM).onStack = YES, ON_STACK))) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ + int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \ +\ + (CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \ + if (size < sizeof(int)) \ + { \ + (CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \ + } \ + (TYPE) = objc_skip_typespec(type); \ + if (locn == IN_REGS) \ + { \ + sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + else \ + { \ + sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \ + } \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if (locn == ON_STACK) \ + { \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM).offsets[ON_STACK] + size; \ + } \ + } \ + (CUM).offsets[locn] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/unknown/generic b/Source/mframe/unknown/generic new file mode 100644 index 000000000..1a752dce0 --- /dev/null +++ b/Source/mframe/unknown/generic @@ -0,0 +1,60 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 8 +#define MFRAME_ARGS_SIZE 128 +#define MFRAME_RESULT_SIZE 128 + +#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \ +(((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \ + objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \ + *(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0) + +#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \ +({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \ + *(TYPES)==_C_ARY_B) && \ + objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \ + *(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);}) + +#define MFRAME_ARGS int + +#define MFRAME_INIT_ARGS(CUM, RTYPE) \ +((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \ + *(RTYPE)==_C_ARY_B) && \ + objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \ + ? sizeof(void*) : 0) + +#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \ +({ \ + const char* type = (TYPE); \ + int align = objc_alignof_type(type); \ + int size = objc_sizeof_type(type); \ +\ + (CUM) = ROUND((CUM), align); \ + (TYPE) = objc_skip_typespec(type); \ + sprintf((DEST), "%.*s%d", (int)((TYPE)-type), type, (CUM)); \ + if (*(TYPE) == '+') \ + { \ + (TYPE)++; \ + } \ + if (*(TYPE) == '-') \ + { \ + (TYPE)++; \ + } \ + while (isdigit(*(TYPE))) \ + { \ + (TYPE)++; \ + } \ + (DEST)=&(DEST)[strlen(DEST)]; \ + if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \ + { \ + (STACK) = (CUM) + ROUND(size, align); \ + } \ + else \ + { \ + (STACK) = (CUM) + size; \ + } \ + (CUM) += ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/null-load.h b/Source/null-load.h index 721af11d9..f8b23bb1b 100644 --- a/Source/null-load.h +++ b/Source/null-load.h @@ -4,15 +4,14 @@ Copyright (C) 1995, Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. -This program is distributed in the +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 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 Lesser General Public License for more details. +PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Lesser General Public License +You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/Source/objc-gnu2next.m b/Source/objc-gnu2next.m new file mode 100644 index 000000000..501c2f26c --- /dev/null +++ b/Source/objc-gnu2next.m @@ -0,0 +1,57 @@ +/* Implementation to allow compilation of GNU objc code with NeXT runtime + Copyright (C) 1993,1994 Free Software Foundation, Inc. + + Author: Kresten Krab Thorup + Modified by: Andrew Kachites McCallum + Date: Sep 1994 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. +*/ + +#include "config.h" +#include +#include "GNUstepBase/preface.h" +#include "mframe.h" + +id next_objc_msg_sendv(id object, SEL op, void* frame) +{ + arglist_t argFrame = __builtin_apply_args(); + struct objc_method *m = class_get_instance_method(object->class_pointer, op); + const char *type; + void *result; + + argFrame->arg_ptr = frame; + *((id*)method_types_get_first_argument (m, argFrame, &type)) = object; + *((SEL*)method_types_get_next_argument (argFrame, &type)) = op; + result = __builtin_apply((apply_t)m->method_imp, + argFrame, + method_get_sizeof_arguments (m)); + +#if !defined(BROKEN_BUILTIN_APPLY) && defined(i386) + /* Special hack to avoid pushing the poped float value back to the fp + stack on i386 machines. This happens with NeXT runtime and 2.7.2 + compiler. If the result value is floating point don't call + __builtin_return anymore. */ + if (*m->method_types == _C_FLT || *m->method_types == _C_DBL) { + long double value = *(long double*)(((char*)result) + 8); + asm("fld %0" : : "f" (value)); + } + else +#endif + __builtin_return(result); +} diff --git a/Source/objc-load.h b/Source/objc-load.h index fcf27c1d6..ded85d6de 100644 --- a/Source/objc-load.h +++ b/Source/objc-load.h @@ -9,7 +9,7 @@ This file is part of the GNUstep Objective-C Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -21,17 +21,15 @@ If you are interested in a warranty or support for this source code, contact Scott Christley for more information. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ #ifndef __objc_load_h_INCLUDE #define __objc_load_h_INCLUDE #include -#include #include #ifdef HAVE_DLADDR diff --git a/Source/objc-load.m b/Source/objc-load.m index 4db8b8bf3..67bd9e050 100644 --- a/Source/objc-load.m +++ b/Source/objc-load.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -30,9 +30,16 @@ */ -#import "common.h" +#include "config.h" + +#ifdef HAVE_DLADDR +/* Define _GNU_SOURCE because that is required with GNU libc in order + * to have dladdr() available. */ +# define _GNU_SOURCE +#endif #include +#include #include #ifndef NeXT_RUNTIME # include @@ -41,9 +48,11 @@ #endif #include "objc-load.h" -#import "Foundation/NSException.h" +#include "Foundation/NSString.h" +#include "Foundation/NSDebug.h" +#include "Foundation/NSException.h" -#import "GSPrivate.h" +#include "GSPrivate.h" /* include the interface to the dynamic linker */ #include "dynamic-load.h" @@ -93,7 +102,7 @@ static int objc_initialize_loading(FILE *errorStream) { NSString *path; -#ifdef __MINGW__ +#ifdef __MINGW32__ const unichar *fsPath; #else const char *fsPath; @@ -136,7 +145,7 @@ objc_load_callback(Class class, struct objc_category * category) } } -#if defined(__MINGW__) +#if defined(__MINGW32__) #define FSCHAR unichar #else #define FSCHAR char @@ -246,21 +255,20 @@ GSPrivateUnloadModule(FILE *errorStream, } -#ifdef __MINGW__ +#ifdef __MINGW32__ NSString * GSPrivateSymbolPath(Class theClass, Category *theCategory) { unichar buf[MAX_PATH]; - NSString *s = nil; MEMORY_BASIC_INFORMATION memInfo; NSCAssert(!theCategory, @"GSPrivateSymbolPath doesn't support categories"); VirtualQueryEx(GetCurrentProcess(), theClass, &memInfo, sizeof(memInfo)); if (GetModuleFileNameW(memInfo.AllocationBase, buf, sizeof(buf))) { - s = [NSString stringWithCharacters: buf length: wcslen(buf)]; + return [NSString stringWithCharacters: buf length: wcslen(buf)]; } - return s; + return 0; } #else NSString * diff --git a/Source/preface.m b/Source/preface.m index c9c201bb8..c37aedc59 100644 --- a/Source/preface.m +++ b/Source/preface.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,13 +16,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#import +#include +#include "GNUstepBase/preface.h" const char *gnustep_base_version = STRINGIFY (GNUSTEP_BASE_VERSION); diff --git a/Source/simple-load.h b/Source/simple-load.h index b006602d8..179ccd12c 100644 --- a/Source/simple-load.h +++ b/Source/simple-load.h @@ -5,15 +5,14 @@ Copyright (C) 1995, Free Software Foundation This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. -This program is distributed in the +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 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 Lesser General Public License for more details. +PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Lesser General Public License +You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. @@ -107,7 +106,7 @@ __objc_dynamic_list_undefined_symbols(void) return NULL; } -static const char * +static inline const char * __objc_dynamic_get_symbol_path(dl_handle_t handle, dl_symbol_t symbol) { #ifdef HAVE_DLADDR diff --git a/Source/thr-mach.h b/Source/thr-mach.h new file mode 100644 index 000000000..3f0eb8ae3 --- /dev/null +++ b/Source/thr-mach.h @@ -0,0 +1,118 @@ +/* Thread and mutex controls for Objective C. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) + +This file is part of GNU CC. + +GNU CC 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 2, or (at your option) +any later version. + +GNU CC 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. + +GNU CC 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 2, or (at your option) any later version. + +GNU CC 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 +GNU CC; see the file COPYING. If not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +/* As a special exception, if you link this library with files + compiled with GCC to produce an executable, this does not cause + the resulting executable to be covered by the GNU General Public License. + This exception does not however invalidate any other reasons why + the executable file might be covered by the GNU General Public License. */ + + +#ifndef __thread_INCLUDE_GNU +#define __thread_INCLUDE_GNU + +#include +#include + +/************************************************************************* + * Universal static variables: + */ +extern int __objc_thread_exit_status; /* Global exit status. */ + +/******** + * Thread safe implementation types and functions. + */ + +/* Thread priorities */ +#define OBJC_THREAD_INTERACTIVE_PRIORITY 2 +#define OBJC_THREAD_BACKGROUND_PRIORITY 1 +#define OBJC_THREAD_LOW_PRIORITY 0 + +/* A thread */ +typedef void * objc_thread_t; + +/* This structure represents a single mutual exclusion lock. */ +struct objc_mutex +{ + volatile objc_thread_t owner; /* Id of thread that owns. */ + volatile int depth; /* # of acquires. */ + void * backend; /* Specific to backend */ +}; +typedef struct objc_mutex *objc_mutex_t; + +/* This structure represents a single condition mutex */ +struct objc_condition +{ + void * backend; /* Specific to backend */ +}; +typedef struct objc_condition *objc_condition_t; + +/* Frontend mutex functions */ +objc_mutex_t objc_mutex_allocate(void); +int objc_mutex_deallocate(objc_mutex_t mutex); +int objc_mutex_lock(objc_mutex_t mutex); +int objc_mutex_unlock(objc_mutex_t mutex); +int objc_mutex_trylock(objc_mutex_t mutex); + +/* Frontend condition mutex functions */ +objc_condition_t objc_condition_allocate(void); +int objc_condition_deallocate(objc_condition_t condition); +int objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex); +int objc_condition_signal(objc_condition_t condition); +int objc_condition_broadcast(objc_condition_t condition); + +/* Frontend thread functions */ +objc_thread_t objc_thread_detach(SEL selector, id object, id argument); +void objc_thread_yield(void); +int objc_thread_exit(void); +int objc_thread_set_priority(int priority); +int objc_thread_get_priority(void); +void * objc_thread_get_data(void); +int objc_thread_set_data(void *value); +objc_thread_t objc_thread_id(void); +void objc_thread_add(void); +void objc_thread_remove(void); + +/* + Use this to set the hook function that will be called when the + runtime initially becomes multi threaded. + The hook function is only called once, meaning only when the + 2nd thread is spawned, not for each and every thread. + + It returns the previous hook function or NULL if there is none. + + A program outside of the runtime could set this to some function so + it can be informed; for example, the GNUstep Base Library sets it + so it can implement the NSBecomingMultiThreaded notification. + */ +typedef void (*objc_thread_callback)(); +objc_thread_callback objc_set_thread_callback(objc_thread_callback func); + +#endif /* not __thread_INCLUDE_GNU */ diff --git a/Source/thr-mach.m b/Source/thr-mach.m new file mode 100644 index 000000000..94e8ac38c --- /dev/null +++ b/Source/thr-mach.m @@ -0,0 +1,616 @@ +/* GNU Objective C Runtime Thread Implementation + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) + Modified for Mach threads by Bill Bumgarner + Condition functions added by Mircea Oancea + +This file is part of GNU CC. + +GNU CC 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 2, or (at your option) any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +/* As a special exception, if you link this library with files compiled with + GCC to produce an executable, this does not cause the resulting executable + to be covered by the GNU General Public License. This exception does not + however invalidate any other reasons why the executable file might be + covered by the GNU General Public License. */ + +#include +#include +#include "GNUstepBase/objc-gnu2next.h" +#include "thr-mach.h" + +/* Global exit status. */ +int __objc_thread_exit_status = 0; + +/* Flag which lets us know if we ever became multi threaded */ +int __objc_is_multi_threaded = 0; + +/* Number of threads alive */ +int __objc_runtime_threads_alive = 0; + +/* Thread create/exit mutex */ +struct objc_mutex* __objc_runtime_mutex = NULL; + +/* The hook function called when the runtime becomes multi threaded */ +objc_thread_callback _objc_became_multi_threaded = NULL; + +/* + Use this to set the hook function that will be called when the + runtime initially becomes multi threaded. + The hook function is only called once, meaning only when the + 2nd thread is spawned, not for each and every thread. + + It returns the previous hook function or NULL if there is none. + + A program outside of the runtime could set this to some function so + it can be informed; for example, the GNUstep Base Library sets it + so it can implement the NSBecomingMultiThreaded notification. + */ +objc_thread_callback objc_set_thread_callback(objc_thread_callback func) +{ + objc_thread_callback temp = _objc_became_multi_threaded; + _objc_became_multi_threaded = func; + return temp; +} + +/* + Private functions + + These functions are utilized by the frontend, but they are not + considered part of the public interface. + */ + +/* + First function called in a thread, starts everything else. + + This function is passed to the backend by objc_thread_detach + as the starting function for a new thread. + */ +struct __objc_thread_start_state +{ + SEL selector; + id object; + id argument; +}; + +static volatile void +__objc_thread_detach_function(struct __objc_thread_start_state *istate) +{ + /* Valid state? */ + if (istate) { + id (*imp)(id,SEL,id); + SEL selector = istate->selector; + id object = istate->object; + id argument = istate->argument; + + /* Don't need anymore so free it */ + objc_free(istate); + + /* Clear out the thread local storage */ + objc_thread_set_data(NULL); + + /* Check to see if we just became multi threaded */ + if (!__objc_is_multi_threaded) + { + __objc_is_multi_threaded = 1; + + /* Call the hook function */ + if (_objc_became_multi_threaded != NULL) + (*_objc_became_multi_threaded)(); + } + + /* Call the method */ + if ((imp = (id(*)(id, SEL, id))objc_msg_lookup(object, selector))) + (*imp)(object, selector, argument); + else + objc_error(object, OBJC_ERR_UNIMPLEMENTED, + "objc_thread_detach called with bad selector.\n"); + } + else + objc_error(nil, OBJC_ERR_BAD_STATE, + "objc_thread_detach called with NULL state.\n"); + + /* Exit the thread */ + objc_thread_exit(); +} + +/* + Frontend functions + + These functions constitute the public interface to the Objective-C thread + and mutex functionality. + */ + +/* Frontend thread functions */ + +/* + Detach a new thread of execution and return its id. Returns NULL if fails. + Thread is started by sending message with selector to object. Message + takes a single argument. + */ +objc_thread_t +objc_thread_detach(SEL selector, id object, id argument) +{ + struct __objc_thread_start_state *istate; + objc_thread_t thread_id = NULL; + + /* Allocate the state structure */ + if (!(istate = (struct __objc_thread_start_state *) + objc_malloc(sizeof(*istate)))) + return NULL; + + /* Initialize the state structure */ + istate->selector = selector; + istate->object = object; + istate->argument = argument; + + /* lock access */ + objc_mutex_lock(__objc_runtime_mutex); + + /* Call the backend to spawn the thread */ + if ((thread_id = __objc_thread_detach((void *)__objc_thread_detach_function, + istate)) == NULL) + { + /* failed! */ + objc_mutex_unlock(__objc_runtime_mutex); + objc_free(istate); + return NULL; + } + + /* Increment our thread counter */ + __objc_runtime_threads_alive++; + objc_mutex_unlock(__objc_runtime_mutex); + + return thread_id; +} + +/* + Obtain the maximum thread priority that can set for t. Under the + mach threading model, it is possible for the developer to adjust the + maximum priority downward only-- cannot be raised without superuser + privileges. Once lowered, it cannot be raised. + */ +static int __mach_get_max_thread_priority(cthread_t t, int *base) +{ + thread_t threadP; + kern_return_t error; + struct thread_sched_info info; + unsigned int info_count=THREAD_SCHED_INFO_COUNT; + + if (t == NULL) + return -1; + + threadP = cthread_thread(t); /* get thread underlying */ + + error=thread_info(threadP, THREAD_SCHED_INFO, + (thread_info_t)&info, &info_count); + + if (error != KERN_SUCCESS) + return -1; + + if (base != NULL) + *base = info.base_priority; + + return info.max_priority; +} + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +int +__objc_init_thread_system(void) +{ + return 0; +} + +/* Close the threads subsystem. */ +int +__objc_close_thread_system(void) +{ + return 0; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +objc_thread_t +__objc_thread_detach(void (*func)(void *arg), void *arg) +{ + objc_thread_t thread_id; + cthread_t new_thread_handle; + + /* create thread */ + new_thread_handle = cthread_fork((cthread_fn_t)func, arg); + + if (new_thread_handle) + { + /* this is not terribly portable */ + thread_id = *(objc_thread_t *)&new_thread_handle; + cthread_detach(new_thread_handle); + } + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +int +objc_thread_set_priority(int priority) +{ + objc_thread_t *t = objc_thread_id(); + cthread_t cT = (cthread_t) t; + int maxPriority = __mach_get_max_thread_priority(cT, NULL); + int sys_priority = 0; + + if (maxPriority == -1) + return -1; + + switch (priority) + { + case OBJC_THREAD_INTERACTIVE_PRIORITY: + sys_priority = maxPriority; + break; + case OBJC_THREAD_BACKGROUND_PRIORITY: + sys_priority = (maxPriority * 2) / 3; + break; + case OBJC_THREAD_LOW_PRIORITY: + sys_priority = maxPriority / 3; + break; + default: + return -1; + } + + if (sys_priority == 0) + return -1; + + /* Change the priority */ + if (cthread_priority(cT, sys_priority, 0) == KERN_SUCCESS) + return 0; + else + return -1; +} + +/* Return the current thread's priority. */ +int +objc_thread_get_priority(void) +{ + objc_thread_t *t = objc_thread_id(); + cthread_t cT = (cthread_t) t; /* see objc_thread_id() */ + int basePriority; + int maxPriority; + int sys_priority = 0; + + int interactiveT, backgroundT, lowT; /* thresholds */ + + maxPriority = __mach_get_max_thread_priority(cT, &basePriority); + + if (maxPriority == -1) + return -1; + + if (basePriority > ((maxPriority * 2) / 3)) + return OBJC_THREAD_INTERACTIVE_PRIORITY; + + if (basePriority > (maxPriority / 3)) + return OBJC_THREAD_BACKGROUND_PRIORITY; + + return OBJC_THREAD_LOW_PRIORITY; +} + +/* Yield our process time to another thread. */ +void +objc_thread_yield(void) +{ + cthread_yield(); +} + +/* Terminate the current thread. */ +int +objc_thread_exit(void) +{ + /* Decrement our counter of the number of threads alive */ + objc_mutex_lock(__objc_runtime_mutex); + __objc_runtime_threads_alive--; + objc_mutex_unlock(__objc_runtime_mutex); + + /* exit the thread */ + cthread_exit(&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +objc_thread_t +objc_thread_id(void) +{ + cthread_t self = cthread_self(); + + return *(objc_thread_t *)&self; +} + +/* Sets the thread's local storage pointer. */ +int +objc_thread_set_data(void *value) +{ + cthread_set_data(cthread_self(), (any_t) value); + return 0; +} + +/* Returns the thread's local storage pointer. */ +void * +objc_thread_get_data(void) +{ + return (void *) cthread_data(cthread_self()); +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +objc_mutex_t +objc_mutex_allocate(objc_mutex_t mutex) +{ + int err = 0; + objc_mutex_t mutex; + + /* Allocate the mutex structure */ + if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex)))) + return NULL; + + mutex->backend = objc_malloc(sizeof(struct mutex)); + + err = mutex_init((mutex_t)(mutex->backend)); + + if (err != 0) + { + objc_free(mutex->backend); + objc_free(mutex); + return NULL; + } + + /* Initialize mutex */ + mutex->owner = NULL; + mutex->depth = 0; + return mutex; +} + +/* Deallocate a mutex. */ +int +objc_mutex_deallocate(objc_mutex_t mutex) +{ + int depth; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* Acquire lock on mutex */ + depth = objc_mutex_lock(mutex); + + mutex_clear((mutex_t)(mutex->backend)); + + objc_free(mutex->backend); + mutex->backend = NULL; + + /* Free the mutex structure */ + objc_free(mutex); + + /* Return last depth */ + return depth; +} + +/* Grab a lock on a mutex. */ +int +objc_mutex_lock(objc_mutex_t mutex) +{ + objc_thread_t thread_id; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* If we already own the lock then increment depth */ + thread_id = objc_thread_id(); + if (mutex->owner == thread_id) + return ++mutex->depth; + + mutex_lock((mutex_t)(mutex->backend)); + + /* Successfully locked the thread */ + mutex->owner = thread_id; + return mutex->depth = 1; +} + +/* Try to grab a lock on a mutex. */ +int +objc_mutex_trylock(objc_mutex_t mutex) +{ + objc_thread_t thread_id; + int status; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* If we already own the lock then increment depth */ + thread_id = objc_thread_id(); + if (mutex->owner == thread_id) + return ++mutex->depth; + + if (mutex_try_lock((mutex_t)(mutex->backend)) == 0) + status = -1; + else + status = 0; + + /* Failed? */ + if (status) + return status; + + /* Successfully locked the thread */ + mutex->owner = thread_id; + return mutex->depth = 1; +} + +/* Unlock the mutex */ +int +objc_mutex_unlock(objc_mutex_t mutex) +{ + objc_thread_t thread_id; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* If another thread owns the lock then abort */ + thread_id = objc_thread_id(); + if (mutex->owner != thread_id) + return -1; + + /* Decrement depth and return */ + if (mutex->depth > 1) + return --mutex->depth; + + /* Depth down to zero so we are no longer the owner */ + mutex->depth = 0; + mutex->owner = NULL; + + mutex_unlock((mutex_t)(mutex->backend)); + + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +objc_condition_t +objc_condition_allocate(void) +{ + objc_condition_t condition; + + /* Allocate the condition mutex structure */ + if (!(condition = + (objc_condition_t)objc_malloc(sizeof(struct objc_condition)))) + return NULL; + + condition->backend = objc_malloc(sizeof(struct condition)); + condition_init((condition_t)(condition->backend)); + + return condition; +} + +/* Deallocate a condition. */ +int +objc_condition_deallocate(objc_condition_t condition) +{ + /* Broadcast the condition */ + if (objc_condition_broadcast(condition)) + return -1; + + condition_clear((condition_t)(condition->backend)); + objc_free(condition->backend); + condition->backend = NULL; + + /* Free the condition mutex structure */ + objc_free(condition); + return 0; +} + +/* Wait on the condition */ +int +objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex) +{ + objc_thread_t thread_id; + + /* Valid arguments? */ + if (!mutex || !condition) + return -1; + + /* Make sure we are owner of mutex */ + thread_id = objc_thread_id(); + if (mutex->owner != thread_id) + return -1; + + /* Cannot be locked more than once */ + if (mutex->depth > 1) + return -1; + + /* Virtually unlock the mutex */ + mutex->depth = 0; + mutex->owner = (objc_thread_t)NULL; + + condition_wait((condition_t)(condition->backend), + (mutex_t)(mutex->backend)); + + /* Make ourselves owner of the mutex */ + mutex->owner = thread_id; + mutex->depth = 1; + + return 0; +} + +/* Wake up all threads waiting on this condition. */ +int +objc_condition_broadcast(objc_condition_t condition) +{ + /* Valid condition mutex? */ + if (!condition) + return -1; + + condition_broadcast((condition_t)(condition->backend)); + return 0; +} + +/* Wake up one thread waiting on this condition. */ +int +objc_condition_signal(objc_condition_t condition) +{ + /* Valid condition mutex? */ + if (!condition) + return -1; + + condition_signal((condition_t)(condition->backend)); + return 0; +} + +/* Make the objc thread system aware that a thread which is managed + (started, stopped) by external code could access objc facilities + from now on. This is used when you are interfacing with some + external non-objc-based environment/system - you must call + objc_thread_add() before an alien thread makes any calls to + Objective-C. Do not cause the _objc_became_multi_threaded hook to + be executed. */ +void +objc_thread_add(void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_is_multi_threaded = 1; + __objc_runtime_threads_alive++; + objc_mutex_unlock(__objc_runtime_mutex); +} + +/* Make the objc thread system aware that a thread managed (started, + stopped) by some external code will no longer access objc and thus + can be forgotten by the objc thread system. Call + objc_thread_remove() when your alien thread is done with making + calls to Objective-C. */ +void +objc_thread_remove(void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_runtime_threads_alive--; + objc_mutex_unlock(__objc_runtime_mutex); +} + +/* End of File */ diff --git a/Source/thr-pthread.m b/Source/thr-pthread.m new file mode 100644 index 000000000..84c5cfd42 --- /dev/null +++ b/Source/thr-pthread.m @@ -0,0 +1,548 @@ +/* GNU Objective C Runtime Thread Implementation for PCThreads under Darwin. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Contributed by Scott Christley + Condition functions added by: Mircea Oancea + +This file is part of GNU CC. + +GNU CC 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 2, or (at your option) any later version. + +GNU CC 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 GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +/* As a special exception, if you link this library with files compiled with + GCC to produce an executable, this does not cause the resulting executable + to be covered by the GNU General Public License. This exception does not + however invalidate any other reasons why the executable file might be + covered by the GNU General Public License. */ + +#include +#include +#include "GNUstepBase/objc-gnu2next.h" +#include "thr-mach.h" + +/* Key structure for maintaining thread specific storage */ +static pthread_key_t _objc_thread_storage; + +/* Global exit status. */ +int __objc_thread_exit_status = 0; + +/* Number of threads alive */ +int __objc_runtime_threads_alive = 0; + +/* Thread create/exit mutex */ +struct objc_mutex* __objc_runtime_mutex = NULL; + +/* Flag which lets us know if we ever became multi threaded */ +int __objc_is_multi_threaded = 0; + +/* The hook function called when the runtime becomes multi threaded */ +objc_thread_callback _objc_became_multi_threaded = NULL; + +/* + Use this to set the hook function that will be called when the + runtime initially becomes multi threaded. + The hook function is only called once, meaning only when the + 2nd thread is spawned, not for each and every thread. + + It returns the previous hook function or NULL if there is none. + + A program outside of the runtime could set this to some function so + it can be informed; for example, the GNUstep Base Library sets it + so it can implement the NSBecomingMultiThreaded notification. + */ +objc_thread_callback objc_set_thread_callback(objc_thread_callback func) +{ + objc_thread_callback temp = _objc_became_multi_threaded; + _objc_became_multi_threaded = func; + return temp; +} + +/* + Private functions + + These functions are utilized by the frontend, but they are not + considered part of the public interface. + */ + +/* + First function called in a thread, starts everything else. + + This function is passed to the backend by objc_thread_detach + as the starting function for a new thread. + */ +struct __objc_thread_start_state +{ + SEL selector; + id object; + id argument; +}; + +objc_thread_t +__objc_thread_detach(void (*func)(void *arg), void *arg); + +static volatile void +__objc_thread_detach_function(struct __objc_thread_start_state *istate) +{ + /* Valid state? */ + if (istate) { + id (*imp)(id,SEL,id); + SEL selector = istate->selector; + id object = istate->object; + id argument = istate->argument; + + /* Don't need anymore so free it */ + objc_free(istate); + + /* Clear out the thread local storage */ + objc_thread_set_data(NULL); + + /* Check to see if we just became multi threaded */ + if (!__objc_is_multi_threaded) + { + __objc_is_multi_threaded = 1; + + /* Call the hook function */ + if (_objc_became_multi_threaded != NULL) + (*_objc_became_multi_threaded)(); + } + + /* Call the method */ + if ((imp = (id(*)(id, SEL, id))objc_msg_lookup(object, selector))) + (*imp)(object, selector, argument); + else + objc_error(object, OBJC_ERR_UNIMPLEMENTED, + "objc_thread_detach called with bad selector.\n"); + } + else + objc_error(nil, OBJC_ERR_BAD_STATE, + "objc_thread_detach called with NULL state.\n"); + + /* Exit the thread */ + objc_thread_exit(); +} + +/* + Frontend functions + + These functions constitute the public interface to the Objective-C thread + and mutex functionality. + */ + +/* Frontend thread functions */ + +/* + Detach a new thread of execution and return its id. Returns NULL if fails. + Thread is started by sending message with selector to object. Message + takes a single argument. + */ +objc_thread_t +objc_thread_detach(SEL selector, id object, id argument) +{ + struct __objc_thread_start_state *istate; + objc_thread_t thread_id = NULL; + + /* Allocate the state structure */ + if (!(istate = (struct __objc_thread_start_state *) + objc_malloc(sizeof(*istate)))) + return NULL; + + /* Initialize the state structure */ + istate->selector = selector; + istate->object = object; + istate->argument = argument; + + /* lock access */ + objc_mutex_lock(__objc_runtime_mutex); + + /* Call the backend to spawn the thread */ + if ((thread_id = __objc_thread_detach((void *)__objc_thread_detach_function, + istate)) == NULL) + { + /* failed! */ + objc_mutex_unlock(__objc_runtime_mutex); + objc_free(istate); + return NULL; + } + + /* Increment our thread counter */ + __objc_runtime_threads_alive++; + objc_mutex_unlock(__objc_runtime_mutex); + + return thread_id; +} + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +int +__objc_init_thread_system(void) +{ + /* Initialize the thread storage key */ + return pthread_key_create(&_objc_thread_storage, NULL); +} + +/* Close the threads subsystem. */ +int +__objc_close_thread_system(void) +{ + /* Destroy the thread storage key */ + /* Not implemented yet */ + /* return pthread_key_delete(&_objc_thread_storage); */ + return 0; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +objc_thread_t +__objc_thread_detach(void (*func)(void *arg), void *arg) +{ + objc_thread_t thread_id; + pthread_t new_thread_handle; + + if (!(pthread_create(&new_thread_handle, NULL, (void *)func, arg))) + thread_id = *(objc_thread_t *)&new_thread_handle; + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +int +objc_thread_set_priority(int priority) +{ + /* Not implemented yet */ + return -1; +} + +/* Return the current thread's priority. */ +int +objc_thread_get_priority(void) +{ + /* Not implemented yet */ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +void +objc_thread_yield(void) +{ +#if !defined(__APPLE__) + /* Not defined in darwin? */ + pthread_yield(); +#else + sched_yield(); +#endif +} + +/* Terminate the current thread. */ +int +objc_thread_exit(void) +{ + /* Decrement our counter of the number of threads alive */ + objc_mutex_lock(__objc_runtime_mutex); + __objc_runtime_threads_alive--; + objc_mutex_unlock(__objc_runtime_mutex); + + /* exit the thread */ + pthread_exit(&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +objc_thread_t +objc_thread_id(void) +{ + pthread_t self = pthread_self(); + + return *(objc_thread_t *)&self; +} + +/* Sets the thread's local storage pointer. */ +int +objc_thread_set_data(void *value) +{ + return pthread_setspecific(_objc_thread_storage, value); +} + +/* Returns the thread's local storage pointer. */ +void * +objc_thread_get_data(void) +{ + return pthread_getspecific(_objc_thread_storage); +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +objc_mutex_t +objc_mutex_allocate(void) +{ + objc_mutex_t mutex; + + /* Allocate the mutex structure */ + if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex)))) + return NULL; + + /* Call backend to create the mutex */ + if (pthread_mutex_init((pthread_mutex_t *)(&(mutex->backend)), NULL)) + { + /* failed! */ + objc_free(mutex); + return NULL; + } + + /* Initialize mutex */ + mutex->owner = NULL; + mutex->depth = 0; + return mutex; +} + +/* Deallocate a mutex. */ +int +objc_mutex_deallocate(objc_mutex_t mutex) +{ + int depth; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* Acquire lock on mutex */ + depth = objc_mutex_lock(mutex); + + if (pthread_mutex_destroy((pthread_mutex_t *)(&(mutex->backend)))) + return -1; + + /* Free the mutex structure */ + objc_free(mutex); + + /* Return last depth */ + return depth; +} + +/* Grab a lock on a mutex. */ +int +objc_mutex_lock(objc_mutex_t mutex) +{ + objc_thread_t thread_id; + int status; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* If we already own the lock then increment depth */ + thread_id = objc_thread_id(); + if (mutex->owner == thread_id) + return ++mutex->depth; + + /* Call the backend to lock the mutex */ + status = pthread_mutex_lock((pthread_mutex_t *)(&(mutex->backend))); + + /* Failed? */ + if (status) + return status; + + /* Successfully locked the thread */ + mutex->owner = thread_id; + return mutex->depth = 1; +} + +/* Try to grab a lock on a mutex. */ +int +objc_mutex_trylock(objc_mutex_t mutex) +{ + objc_thread_t thread_id; + int status; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* If we already own the lock then increment depth */ + thread_id = objc_thread_id(); + if (mutex->owner == thread_id) + return ++mutex->depth; + + /* Call the backend to try to lock the mutex */ + status = pthread_mutex_trylock((pthread_mutex_t *)(&(mutex->backend))); + + /* Failed? */ + if (status) + return status; + + /* Successfully locked the thread */ + mutex->owner = thread_id; + return mutex->depth = 1; +} + +/* Unlock the mutex */ +int +objc_mutex_unlock(objc_mutex_t mutex) +{ + objc_thread_t thread_id; + + /* Valid mutex? */ + if (!mutex) + return -1; + + /* If another thread owns the lock then abort */ + thread_id = objc_thread_id(); + if (mutex->owner != thread_id) + return -1; + + /* Decrement depth and return */ + if (mutex->depth > 1) + return --mutex->depth; + + /* Depth down to zero so we are no longer the owner */ + mutex->depth = 0; + mutex->owner = NULL; + + /* Have the backend unlock the mutex */ + return pthread_mutex_unlock((pthread_mutex_t *)(&(mutex->backend))); +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +objc_condition_t +objc_condition_allocate(void) +{ + objc_condition_t condition; + + /* Allocate the condition mutex structure */ + if (!(condition = + (objc_condition_t)objc_malloc(sizeof(struct objc_condition)))) + return NULL; + + /* Call the backend to create the condition mutex */ + if (pthread_cond_init((pthread_cond_t *)(&(condition->backend)), NULL)) + { + /* failed! */ + objc_free(condition); + return NULL; + } + + /* Success! */ + return condition; +} + +/* Deallocate a condition. */ +int +objc_condition_deallocate(objc_condition_t condition) +{ + /* Broadcast the condition */ + if (objc_condition_broadcast(condition)) + return -1; + + /* Call the backend to destroy */ + if (pthread_cond_destroy((pthread_cond_t *)(&(condition->backend)))) + return -1; + + /* Free the condition mutex structure */ + objc_free(condition); + + return 0; +} + +/* Wait on the condition */ +int +objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex) +{ + objc_thread_t thread_id; + + /* Valid arguments? */ + if (!mutex || !condition) + return -1; + + /* Make sure we are owner of mutex */ + thread_id = objc_thread_id(); + if (mutex->owner != thread_id) + return -1; + + /* Cannot be locked more than once */ + if (mutex->depth > 1) + return -1; + + /* Virtually unlock the mutex */ + mutex->depth = 0; + mutex->owner = (objc_thread_t)NULL; + + /* Call the backend to wait */ + pthread_cond_wait((pthread_cond_t *)(&(condition->backend)), + (pthread_mutex_t *)(&(mutex->backend))); + + /* Make ourselves owner of the mutex */ + mutex->owner = thread_id; + mutex->depth = 1; + + return 0; +} + +/* Wake up all threads waiting on this condition. */ +int +objc_condition_broadcast(objc_condition_t condition) +{ + /* Valid condition mutex? */ + if (!condition) + return -1; + + return pthread_cond_broadcast((pthread_cond_t *)(&(condition->backend))); +} + +/* Wake up one thread waiting on this condition. */ +int +objc_condition_signal(objc_condition_t condition) +{ + /* Valid condition mutex? */ + if (!condition) + return -1; + + return pthread_cond_signal((pthread_cond_t *)(&(condition->backend))); +} + +/* Make the objc thread system aware that a thread which is managed + (started, stopped) by external code could access objc facilities + from now on. This is used when you are interfacing with some + external non-objc-based environment/system - you must call + objc_thread_add() before an alien thread makes any calls to + Objective-C. Do not cause the _objc_became_multi_threaded hook to + be executed. */ +void +objc_thread_add(void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_is_multi_threaded = 1; + __objc_runtime_threads_alive++; + objc_mutex_unlock(__objc_runtime_mutex); +} + +/* Make the objc thread system aware that a thread managed (started, + stopped) by some external code will no longer access objc and thus + can be forgotten by the objc thread system. Call + objc_thread_remove() when your alien thread is done with making + calls to Objective-C. */ +void +objc_thread_remove(void) +{ + objc_mutex_lock(__objc_runtime_mutex); + __objc_runtime_threads_alive--; + objc_mutex_unlock(__objc_runtime_mutex); +} + +/* End of File */ diff --git a/Source/unix/GNUmakefile b/Source/unix/GNUmakefile index 11146738f..6f3b80e7e 100644 --- a/Source/unix/GNUmakefile +++ b/Source/unix/GNUmakefile @@ -8,7 +8,7 @@ # This file is part of the GNUstep Base Library. # # This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public +# modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # @@ -17,12 +17,11 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public +# You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. # -PACKAGE_NAME = gnustep-base GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../base.make include $(GNUSTEP_MAKEFILES)/common.make diff --git a/Source/unix/GSRunLoopCtxt.m b/Source/unix/GSRunLoopCtxt.m index 169cec613..1fe79d0a2 100644 --- a/Source/unix/GSRunLoopCtxt.m +++ b/Source/unix/GSRunLoopCtxt.m @@ -6,17 +6,18 @@ * NB. This class is private to NSRunLoop and must not be subclassed. */ -#import "common.h" +#include "config.h" -#import "GNUstepBase/preface.h" -#import "Foundation/NSError.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSStream.h" -#import "../GSRunLoopCtxt.h" -#import "../GSRunLoopWatcher.h" -#import "../GSPrivate.h" +#include "GNUstepBase/preface.h" +#include +#include +#include +#include +#include +#include +#include "../GSRunLoopCtxt.h" +#include "../GSRunLoopWatcher.h" +#include "../GSPrivate.h" #ifdef HAVE_SYS_TYPES_H #include @@ -31,6 +32,8 @@ #include #endif +#define FDCOUNT 128 + #if GS_WITH_GC == 0 static SEL wRelSel; static SEL wRetSel; @@ -56,7 +59,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = 0 }; #else -#define WatcherMapValueCallBacks NSOwnedPointerMapValueCallBacks +#define WatcherMapValueCallBacks NSNonOwnedPointerMapValueCallBacks #endif @implementation GSRunLoopCtxt @@ -97,7 +100,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = #ifdef HAVE_POLL_F if (pollfds != 0) { - NSZoneFree(NSDefaultMallocZone(), pollfds); + objc_free(pollfds); } #endif [super dealloc]; @@ -174,27 +177,16 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = self = [super init]; if (self != nil) { - NSZone *z; + NSZone *z = [self zone]; mode = [theMode copy]; extra = e; -#if GS_WITH_GC - z = (NSZone*)1; - performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); - timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); - watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); - _trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); -#else - z = [self zone]; performers = NSZoneMalloc(z, sizeof(GSIArray_t)); - timers = NSZoneMalloc(z, sizeof(GSIArray_t)); - watchers = NSZoneMalloc(z, sizeof(GSIArray_t)); - _trigger = NSZoneMalloc(z, sizeof(GSIArray_t)); -#endif GSIArrayInitWithZoneAndCapacity(performers, z, 8); + timers = NSZoneMalloc(z, sizeof(GSIArray_t)); GSIArrayInitWithZoneAndCapacity(timers, z, 8); + watchers = NSZoneMalloc(z, sizeof(GSIArray_t)); GSIArrayInitWithZoneAndCapacity(watchers, z, 8); - GSIArrayInitWithZoneAndCapacity(_trigger, z, 8); _efdMap = NSCreateMapTable (NSIntMapKeyCallBacks, WatcherMapValueCallBacks, 0); @@ -202,6 +194,8 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = WatcherMapValueCallBacks, 0); _wfdMap = NSCreateMapTable (NSIntMapKeyCallBacks, WatcherMapValueCallBacks, 0); + _trigger = NSZoneMalloc(z, sizeof(GSIArray_t)); + GSIArrayInitWithZoneAndCapacity(_trigger, z, 8); } return self; } @@ -221,23 +215,11 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) pe->limit = fd + 1; if (pe->index == 0) { -#if GS_WITH_GC - pe->index - = NSAllocateCollectable(pe->limit * sizeof(*(pe->index)), 0); -#else - pe->index = NSZoneMalloc(NSDefaultMallocZone(), - pe->limit * sizeof(*(pe->index))); -#endif + pe->index = objc_malloc(pe->limit * sizeof(*(pe->index))); } else { -#if GS_WITH_GC - pe->index = NSReallocateCollectable(pe->index, - pe->limit * sizeof(*(pe->index)), 0); -#else - pe->index = NSZoneRealloc(NSDefaultMallocZone(), - pe->index, pe->limit * sizeof(*(pe->index))); -#endif + pe->index = objc_realloc(pe->index, pe->limit * sizeof(*(pe->index))); } do { @@ -251,13 +233,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) if (ctxt->pollfds_count >= ctxt->pollfds_capacity) { ctxt->pollfds_capacity += 8; -#if GS_WITH_GC - pollfds = NSReallocateCollectable(pollfds, - ctxt->pollfds_capacity * sizeof (*pollfds), 0); -#else - pollfds = NSZoneRealloc(NSDefaultMallocZone(), - pollfds, ctxt->pollfds_capacity * sizeof (*pollfds)); -#endif + pollfds = + objc_realloc(pollfds, ctxt->pollfds_capacity * sizeof (*pollfds)); ctxt->pollfds = pollfds; } index = ctxt->pollfds_count++; @@ -278,7 +255,6 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) */ - (BOOL) pollUntil: (int)milliseconds within: (NSArray*)contexts { - GSRunLoopThreadInfo *threadInfo = GSRunLoopInfoForThread(nil); int poll_return; int fdEnd; /* Number of descriptors being monitored. */ int fdIndex; @@ -301,37 +277,21 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) /* * Do the pre-listening set-up for the file descriptors of this mode. */ - if (pollfds_capacity < i + 2) + if (pollfds_capacity < i + 1) { - pollfds_capacity = i + 2; + pollfds_capacity = i + 1; if (pollfds == 0) { -#if GS_WITH_GC - pollfds - = NSAllocateCollectable(pollfds_capacity * sizeof(*pollfds), 0); -#else - pollfds = NSZoneMalloc(NSDefaultMallocZone(), - pollfds_capacity * sizeof(*pollfds)); -#endif + pollfds = objc_malloc(pollfds_capacity * sizeof(*pollfds)); } else { -#if GS_WITH_GC - pollfds = NSReallocateCollectable(pollfds, - pollfds_capacity * sizeof(*pollfds), 0); -#else - pollfds = NSZoneRealloc(NSDefaultMallocZone(), - pollfds, pollfds_capacity * sizeof(*pollfds)); -#endif + pollfds = objc_realloc(pollfds, pollfds_capacity * sizeof(*pollfds)); } } pollfds_count = 0; ((pollextra*)extra)->limit = 0; - /* Watch for signals from other threads. - */ - setPollfd(threadInfo->inputFd, POLLIN, self); - while (i-- > 0) { GSRunLoopWatcher *info; @@ -380,15 +340,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) case ET_RPORT: { id port = info->receiver; - int port_fd_count = 128; // FIXME - int port_fd_array[port_fd_count]; + NSInteger port_fd_count = FDCOUNT; + NSInteger port_fd_array[FDCOUNT]; - if ([port respondsToSelector: - @selector(getFds:count:)]) - { - [port getFds: port_fd_array - count: &port_fd_count]; - } + [port getFds: port_fd_array count: &port_fd_count]; NSDebugMLLog(@"NSRunLoop", @"listening to %d port handles\n", port_fd_count); while (port_fd_count--) @@ -410,7 +365,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) * we can service the queue. Similarly, if a task has completed, * we need to deliver its notifications. */ - if (GSPrivateCheckTasks() || GSPrivateNotifyMore(mode) || immediate == YES) + if (GSPrivateCheckTasks() || GSPrivateNotifyMore() || immediate == YES) { milliseconds = 0; } @@ -424,7 +379,14 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) fprintf(stderr, "\n"); } #endif - poll_return = poll (pollfds, pollfds_count, milliseconds); + if (pollfds_count > 0) + { + poll_return = poll (pollfds, pollfds_count, milliseconds); + } + else + { + poll_return = 0; + } #if 0 { unsigned int i; @@ -464,33 +426,33 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) * Trigger any watchers which are set up to for every runloop wait. */ count = GSIArrayCount(_trigger); - while (count-- > 0) + while (completed == NO && count-- > 0) { GSRunLoopWatcher *watcher; watcher = (GSRunLoopWatcher*)GSIArrayItemAtIndex(_trigger, count).obj; - if (watcher->_invalidated == NO) - { - i = [contexts count]; - while (i-- > 0) - { - GSRunLoopCtxt *c = [contexts objectAtIndex: i]; + if (watcher->_invalidated == NO) + { + i = [contexts count]; + while (i-- > 0) + { + GSRunLoopCtxt *c = [contexts objectAtIndex: i]; - if (c != self) - { - [c endEvent: (void*)watcher for: watcher]; - } - } - /* - * The watcher is still valid - so call its - * receivers event handling method. - */ - [watcher->receiver receivedEvent: watcher->data - type: watcher->type - extra: watcher->data - forMode: mode]; - } - GSPrivateNotifyASAP(mode); + if (c != self) + { + [c endEvent: (void*)watcher for: watcher]; + } + } + /* + * The watcher is still valid - so call its + * receivers event handling method. + */ + [watcher->receiver receivedEvent: watcher->data + type: watcher->type + extra: watcher->data + forMode: mode]; + } + GSPrivateNotifyASAP(); } /* @@ -565,7 +527,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) extra: (void*)(uintptr_t)fd forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (completed == YES) { break; // A nested poll has done the job. @@ -597,7 +559,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) extra: (void*)(uintptr_t)fd forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (completed == YES) { break; // A nested poll has done the job. @@ -606,17 +568,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) } if (pollfds[fdIndex].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) { - if (fd == threadInfo->inputFd) - { - NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); - [threadInfo fire]; - watcher = nil; - } - else - { - watcher = (GSRunLoopWatcher*) - NSMapGet(_rfdMap, (void*)(intptr_t)fd); - } + watcher + = (GSRunLoopWatcher*)NSMapGet(_rfdMap, (void*)(intptr_t)fd); if (watcher != nil && watcher->_invalidated == NO) { i = [contexts count]; @@ -638,7 +591,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) extra: (void*)(uintptr_t)fd forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (completed == YES) { break; // A nested poll has done the job. @@ -663,32 +616,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) return YES; } -+ (BOOL) awakenedBefore: (NSDate*)when -{ - GSRunLoopThreadInfo *threadInfo = GSRunLoopInfoForThread(nil); - NSTimeInterval ti = (when == nil) ? 0.0 : [when timeIntervalSinceNow]; - int milliseconds = (ti <= 0.0) ? 0 : (int)(ti*1000); - struct pollfd pollfds; - - /* Watch for signals from other threads. - */ - pollfds.fd = threadInfo->inputFd; - pollfds.events = POLLIN; - pollfds.revents = 0; - if (poll(&pollfds, 1, milliseconds) == 1) - { - NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); - [threadInfo fire]; - return YES; - } - return NO; -} - #else - (BOOL) pollUntil: (int)milliseconds within: (NSArray*)contexts { - GSRunLoopThreadInfo *threadInfo = GSRunLoopInfoForThread(nil); struct timeval timeout; void *select_timeout; int select_return; @@ -697,7 +628,6 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) fd_set read_fds; // Mask for read-ready fds. fd_set exception_fds; // Mask for exception fds. fd_set write_fds; // Mask for write-ready fds. - int fd; int fdEnd = -1; unsigned count; unsigned i; @@ -742,13 +672,6 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) NSResetMapTable(_wfdMap); GSIArrayRemoveAllItems(_trigger); - /* Watch for signals from other threads. - */ - fd = threadInfo->inputFd; - if (fd > fdEnd) - fdEnd = fd; - FD_SET (fd, &read_fds); - while (i-- > 0) { GSRunLoopWatcher *info; @@ -799,15 +722,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) case ET_RPORT: { id port = info->receiver; - int port_fd_count = 128; // xxx #define this constant - int port_fd_array[port_fd_count]; + NSInteger port_fd_count = FDCOUNT; + NSInteger port_fd_array[FDCOUNT]; - if ([port respondsToSelector: - @selector(getFds:count:)]) - { - [port getFds: port_fd_array - count: &port_fd_count]; - } + [port getFds: port_fd_array count: &port_fd_count]; NSDebugMLLog(@"NSRunLoop", @"listening to %d port sockets", port_fd_count); while (port_fd_count--) @@ -836,7 +754,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) * we can service the queue. Similarly, if a task has completed, * we need to deliver its notifications. */ - if (GSPrivateCheckTasks() || GSPrivateNotifyMore(mode) || immediate == YES) + if (GSPrivateCheckTasks() || GSPrivateNotifyMore() || immediate == YES) { timeout.tv_sec = 0; timeout.tv_usec = 0; @@ -845,8 +763,15 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) // NSDebugMLLog(@"NSRunLoop", @"select timeout %d,%d", timeout.tv_sec, timeout.tv_usec); - select_return = select (fdEnd, &read_fds, &write_fds, - &exception_fds, select_timeout); + if (fdEnd >= 0) + { + select_return = select (fdEnd, &read_fds, &write_fds, + &exception_fds, select_timeout); + } + else + { + select_return = 0; + } NSDebugMLLog(@"NSRunLoop", @"select returned %d", select_return); @@ -877,7 +802,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) * Trigger any watchers which are set up to for every runloop wait. */ count = GSIArrayCount(_trigger); - while (count-- > 0) + while (completed == NO && count-- > 0) { GSRunLoopWatcher *watcher; @@ -903,7 +828,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) extra: watcher->data forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } /* @@ -961,10 +886,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) */ [watcher->receiver receivedEvent: watcher->data type: watcher->type - extra: (void*)(intptr_t)fdIndex + extra: watcher->data forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (completed == YES) { break; @@ -993,10 +918,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) */ [watcher->receiver receivedEvent: watcher->data type: watcher->type - extra: (void*)(intptr_t)fdIndex + extra: watcher->data forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (completed == YES) { break; @@ -1007,17 +932,8 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) { GSRunLoopWatcher *watcher; - if (fdIndex == threadInfo->inputFd) - { - NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); - [threadInfo fire]; - watcher = nil; - } - else - { - watcher = (GSRunLoopWatcher*) - NSMapGet(_rfdMap, (void*)(intptr_t)fdIndex); - } + watcher + = (GSRunLoopWatcher*)NSMapGet(_rfdMap, (void*)(intptr_t)fdIndex); if (watcher != nil && watcher->_invalidated == NO) { i = [contexts count]; @@ -1034,10 +950,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) */ [watcher->receiver receivedEvent: watcher->data type: watcher->type - extra: (void*)(intptr_t)fdIndex + extra: watcher->data forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); if (completed == YES) { break; @@ -1061,31 +977,5 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt) return YES; } -+ (BOOL) awakenedBefore: (NSDate*)when -{ - GSRunLoopThreadInfo *threadInfo = GSRunLoopInfoForThread(nil); - NSTimeInterval ti = (when == nil) ? 0.0 : [when timeIntervalSinceNow]; - int milliseconds = (ti <= 0.0) ? 0 : (int)(ti*1000); - struct timeval timeout; - fd_set read_fds; // Mask for read-ready fds. - fd_set exception_fds; // Mask for exception fds. - fd_set write_fds; // Mask for write-ready fds. - - memset(&exception_fds, '\0', sizeof(exception_fds)); - memset(&read_fds, '\0', sizeof(read_fds)); - memset(&write_fds, '\0', sizeof(write_fds)); - timeout.tv_sec = milliseconds/1000; - timeout.tv_usec = (milliseconds - 1000 * timeout.tv_sec) * 1000; - FD_SET (threadInfo->inputFd, &read_fds); - if (select (threadInfo->inputFd, &read_fds, &write_fds, - &exception_fds, &timeout) > 0) - { - NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); - [threadInfo fire]; - return YES; - } - return NO; -} - #endif @end diff --git a/Source/unix/Makefile.preamble b/Source/unix/Makefile.preamble index 756197ec3..976c12759 100644 --- a/Source/unix/Makefile.preamble +++ b/Source/unix/Makefile.preamble @@ -8,7 +8,7 @@ # This file is part of the GNUstep Base Library. # # This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public +# modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # @@ -20,7 +20,7 @@ # If you are interested in a warranty or support for this source code, # contact Scott Christley at scottc@net-community.com # -# You should have received a copy of the GNU Lesser General Public +# You should have received a copy of the GNU Library General Public # License along with this library; see the file COPYING.LIB. # If not, write to the Free Software Foundation, # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -39,7 +39,7 @@ # # Additional flags to pass to the preprocessor -ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS) +ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) -Wall # Additional flags to pass to the Objective-C compiler #ADDITIONAL_OBJCFLAGS = @@ -55,8 +55,7 @@ endif ADDITIONAL_CFLAGS = # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS = -I../../Headers/Additions \ - -I../$(GNUSTEP_TARGET_DIR) +ADDITIONAL_INCLUDE_DIRS = -I../$(GNUSTEP_TARGET_DIR) ifeq ($(FOUNDATION_LIB),gnu) ADDITIONAL_INCLUDE_DIRS += -I../../Headers diff --git a/Source/unix/NSStream.m b/Source/unix/NSStream.m index c982bb7a7..9e58d516d 100644 --- a/Source/unix/NSStream.m +++ b/Source/unix/NSStream.m @@ -6,7 +6,7 @@ Date: 2006 This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,33 +15,44 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ - -#import "common.h" - #include #include -#import "Foundation/NSData.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSException.h" -#import "Foundation/NSError.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSByteOrder.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include +#include +#include +#include +#include +#include +#include -#import "../GSPrivate.h" -#import "../GSStream.h" -#import "../GSSocketStream.h" +#include "../GSStream.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef AF_LOCAL +#define AF_LOCAL AF_UNIX +#endif +#ifndef PF_LOCAL +#define PF_LOCAL PF_UNIX +#endif + +#ifndef socklen_t +#define socklen_t uint32_t +#endif /** * The concrete subclass of NSInputStream that reads from a file @@ -53,7 +64,72 @@ } @end +/** + * The abstract subclass of NSInputStream that reads from a socket + */ +@interface GSSocketInputStream : GSInputStream +{ +@protected + GSOutputStream *_sibling; + BOOL _passive; /* YES means already connected */ +} + +/** + * get the length of the socket addr + */ +- (socklen_t) sockLen; + +/** + * get the sockaddr + */ +- (struct sockaddr*) peerAddr; + +/** + * setter for sibling + */ +- (void) setSibling: (GSOutputStream*)sibling; + +/** + * setter for passive + */ +- (void) setPassive: (BOOL)passive; + +@end + +@interface GSInetInputStream : GSSocketInputStream +{ + @private + struct sockaddr_in _peerAddr; +} + +/** + * the designated initializer + */ +- (id) initToAddr: (NSString*)addr port: (int)port; + +@end + +@interface GSInet6InputStream : GSSocketInputStream +{ + @private +#if defined(AF_INET6) + struct sockaddr_in6 _peerAddr; +#endif +} + +/** + * the designated initializer + */ +- (id) initToAddr: (NSString*)addr port: (int)port; + +@end + @interface GSLocalInputStream : GSSocketInputStream +{ + @private + struct sockaddr_un _peerAddr; +} + /** * the designated initializer */ @@ -72,7 +148,72 @@ } @end +/** + * The concrete subclass of NSOutputStream that writes to a socket + */ +@interface GSSocketOutputStream : GSOutputStream +{ +@protected + GSInputStream *_sibling; + BOOL _passive; /* YES means already connected */ +} + +/** + * get the length of the socket addr + */ +- (socklen_t) sockLen; + +/** + * get the sockaddr + */ +- (struct sockaddr*) peerAddr; + +/** + * setter for sibling + */ +- (void) setSibling: (GSInputStream*)sibling; + +/** + * setter for passive + */ +- (void) setPassive: (BOOL)passive; + +@end + +@interface GSInetOutputStream : GSSocketOutputStream +{ + @private + struct sockaddr_in _peerAddr; +} + +/** + * the designated initializer + */ +- (id) initToAddr: (NSString*)addr port: (int)port; + +@end + +@interface GSInet6OutputStream : GSSocketOutputStream +{ + @private +#if defined(AF_INET6) + struct sockaddr_in6 _peerAddr; +#endif +} + +/** + * the designated initializer + */ +- (id) initToAddr: (NSString*)addr port: (int)port; + +@end + @interface GSLocalOutputStream : GSSocketOutputStream +{ + @private + struct sockaddr_un _peerAddr; +} + /** * the designated initializer */ @@ -80,13 +221,59 @@ @end -@interface GSLocalServerStream : GSSocketServerStream +/** + * The concrete subclass of NSServerStream that accept connection from a socket + */ +@interface GSSocketServerStream : GSAbstractServerStream +/** + * return the class of the inputStream associated with this + * type of serverStream. + */ +- (Class) _inputStreamClass; +/** + * return the class of the outputStream associated with this + * type of serverStream. + */ +- (Class) _outputStreamClass; +/** + * get the length of the socket addr + */ +- (socklen_t) sockLen; +/** + * get the sockaddr + */ +- (struct sockaddr*) serverAddr; + +@end + +@interface GSInetServerStream : GSSocketServerStream { @private - struct sockaddr_un _serverAddr; + struct sockaddr_in _serverAddr; } @end +@interface GSInet6ServerStream : GSSocketServerStream +{ + @private +#if defined(AF_INET6) + struct sockaddr_in6 _serverAddr; +#endif +} +@end + +@interface GSLocalServerStream : GSSocketServerStream +@end + +/** + * set the file descriptor to non-blocking + */ +static void setNonblocking(int fd) +{ + int flags = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); +} + @implementation GSFileInputStream - (id) initWithFileAtPath: (NSString *)path @@ -108,7 +295,7 @@ [super dealloc]; } -- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len { int readLen; @@ -139,11 +326,12 @@ else if (readLen == 0) { [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; } return readLen; } -- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len { return NO; } @@ -176,6 +364,7 @@ if (fd < 0) { [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; return; } _loopID = (void*)(intptr_t)fd; @@ -204,14 +393,237 @@ } @end +@implementation GSSocketInputStream -@implementation GSLocalInputStream +- (socklen_t) sockLen +{ + [self subclassResponsibility: _cmd]; + return 0; +} -- (id) initToAddr: (NSString*)addr +- (struct sockaddr*) peerAddr +{ + [self subclassResponsibility: _cmd]; + return NULL; +} + +- (void) setSibling: (GSOutputStream*)sibling +{ + _sibling = sibling; +} + +- (void) setPassive: (BOOL)passive +{ + _passive = passive; +} + +- (id) init { if ((self = [super init]) != nil) { - if ([self _setSocketAddress: addr port: 0 family: AF_UNIX] == NO) + // so that unopened access will fail + _sibling = nil; + _passive = NO; + } + return self; +} + +- (void) dealloc +{ + if ([self _isOpened]) + { + [self close]; + } + [(GSSocketOutputStream*)_sibling setSibling: nil]; + _sibling = nil; + [super dealloc]; +} + +- (void) open +{ + // could be opened because of sibling + if ([self _isOpened]) + return; + if (_passive || (_sibling && [_sibling _isOpened])) + goto open_ok; + // check sibling status, avoid double connect + if (_sibling && [_sibling streamStatus] == NSStreamStatusOpening) + { + [self _setStatus: NSStreamStatusOpening]; + return; + } + else + { + int result; + + if (_runloop) + { + setNonblocking((intptr_t)_loopID); + } + result = connect((intptr_t)_loopID, [self peerAddr], [self sockLen]); + if (result < 0) + { + if (errno == EINPROGRESS && _runloop != nil) + { + unsigned i = [_modes count]; + + /* + * Need to set the status first, so that the run loop can tell + * it needs to add the stream as waiting on writable, as an + * indication of opened + */ + [self _setStatus: NSStreamStatusOpening]; + while (i-- > 0) + { + [_runloop addStream: self mode: [_modes objectAtIndex: i]]; + } + return; + } + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + return; + } + } + + open_ok: + // put itself to the runloop + [super open]; + setNonblocking((intptr_t)_loopID); +} + +- (void) close +{ + // read shutdown is ignored, because the other side may shutdown first. + if (!_sibling || [_sibling streamStatus] == NSStreamStatusClosed) + close((intptr_t)_loopID); + else + shutdown((intptr_t)_loopID, SHUT_RD); + [super close]; +} + +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len +{ + int readLen; + + if (buffer == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"null pointer for buffer"]; + } + if (len == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"zero byte read write requested"]; + } + + _events &= ~NSStreamEventHasBytesAvailable; + + if ([self streamStatus] == NSStreamStatusClosed) + { + return 0; + } + + readLen = read((intptr_t)_loopID, buffer, len); + if (readLen < 0 && errno != EAGAIN && errno != EINTR) + { + [self _recordError]; + readLen = -1; + } + else if (readLen == 0) + { + [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; + } + return readLen; +} + +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len +{ + return NO; +} + +- (BOOL) hasBytesAvailable +{ + if ([self _isOpened] && [self streamStatus] != NSStreamStatusAtEnd) + return YES; + return NO; +} + +- (void) _dispatch +{ + NSStreamEvent myEvent; + + if ([self streamStatus] == NSStreamStatusOpening) + { + int error; + int result; + socklen_t len = sizeof(error); + unsigned i = [_modes count]; + + while (i-- > 0) + { + [_runloop removeStream: self mode: [_modes objectAtIndex: i]]; + } + result + = getsockopt((intptr_t)_loopID, SOL_SOCKET, SO_ERROR, &error, &len); + + if (result >= 0 && !error) + { // finish up the opening + myEvent = NSStreamEventOpenCompleted; + _passive = YES; + [self open]; + // notify sibling + [_sibling open]; + [_sibling _sendEvent: myEvent]; + } + else // must be an error + { + if (error) + errno = error; + [self _recordError]; + myEvent = NSStreamEventErrorOccurred; + [_sibling _recordError]; + [_sibling _sendEvent: myEvent]; + } + } + else if ([self streamStatus] == NSStreamStatusAtEnd) + { + myEvent = NSStreamEventEndEncountered; + } + else + { + [self _setStatus: NSStreamStatusOpen]; + myEvent = NSStreamEventHasBytesAvailable; + } + [self _sendEvent: myEvent]; +} + +@end + +@implementation GSInetInputStream + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + + int ptonReturn; + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + if ((self = [super init]) != nil) + { + _peerAddr.sin_family = AF_INET; + _peerAddr.sin_port = htons(port); + ptonReturn = inet_pton(AF_INET, addr_c, &(_peerAddr.sin_addr)); + if (ptonReturn == 0) // error { DESTROY(self); } @@ -221,6 +633,77 @@ @end +@implementation GSInet6InputStream +#if defined(AF_INET6) +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in6); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + int ptonReturn; + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + if ((self = [super init]) != nil) + { + _peerAddr.sin6_family = AF_INET6; + _peerAddr.sin6_port = htons(port); + ptonReturn = inet_pton(AF_INET6, addr_c, &(_peerAddr.sin6_addr)); + if (ptonReturn == 0) // error + { + DESTROY(self); + } + } + return self; +} +#else +- (id) initToAddr: (NSString*)addr port: (int)port +{ + RELEASE(self); + return nil; +} +#endif +@end + +@implementation GSLocalInputStream + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_un); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr +{ + const char* real_addr = [addr fileSystemRepresentation]; + + if ((self = [super init]) != nil) + { + _peerAddr.sun_family = AF_LOCAL; + if (strlen(real_addr)>sizeof(_peerAddr.sun_path)-1) // too long + { + DESTROY(self); + } + else + { + strncpy(_peerAddr.sun_path, real_addr, sizeof(_peerAddr.sun_path)-1); + } + } + return self; +} + +@end + @implementation GSFileOutputStream - (id) initToFileAtPath: (NSString *)path append: (BOOL)shouldAppend @@ -244,7 +727,7 @@ [super dealloc]; } -- (NSInteger) write: (const uint8_t *)buffer maxLength: (NSUInteger)len +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len { int writeLen; @@ -293,6 +776,7 @@ if (fd < 0) { // make an error [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; return; } _loopID = (void*)(intptr_t)fd; @@ -333,14 +817,224 @@ } @end +@implementation GSSocketOutputStream -@implementation GSLocalOutputStream +- (socklen_t) sockLen +{ + [self subclassResponsibility: _cmd]; + return 0; +} -- (id) initToAddr: (NSString*)addr +- (struct sockaddr*) peerAddr +{ + [self subclassResponsibility: _cmd]; + return NULL; +} + +- (void) setSibling: (GSInputStream*)sibling +{ + _sibling = sibling; +} + +- (void) setPassive: (BOOL)passive +{ + _passive = passive; +} + +- (id) init { if ((self = [super init]) != nil) { - if ([self _setSocketAddress: addr port: 0 family: AF_UNIX] == NO) + _sibling = nil; + _passive = NO; + } + return self; +} + +- (void) dealloc +{ + if ([self _isOpened]) + { + [self close]; + } + [(GSSocketInputStream*)_sibling setSibling: nil]; + _sibling = nil; + [super dealloc]; +} + +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len +{ + int writeLen; + + if (buffer == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"null pointer for buffer"]; + } + if (len == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"zero byte length write requested"]; + } + + _events &= ~NSStreamEventHasSpaceAvailable; + + if ([self streamStatus] == NSStreamStatusClosed) + { + return 0; + } + + writeLen = write((intptr_t)_loopID, buffer, len); + if (writeLen < 0 && errno != EAGAIN && errno != EINTR) + [self _recordError]; + return writeLen; +} + +- (BOOL) hasSpaceAvailable +{ + if ([self _isOpened]) + return YES; + return NO; +} + +- (void) open +{ + // could be opened because of sibling + if ([self _isOpened]) + return; + if (_passive || (_sibling && [_sibling _isOpened])) + goto open_ok; + // check sibling status, avoid double connect + if (_sibling && [_sibling streamStatus] == NSStreamStatusOpening) + { + [self _setStatus: NSStreamStatusOpening]; + return; + } + else + { + int result; + + if (_runloop) + { + setNonblocking((intptr_t)_loopID); + } + result = connect((intptr_t)_loopID, [self peerAddr], [self sockLen]); + if (result < 0) + { + if (errno == EINPROGRESS && _runloop != nil) + { + unsigned i = [_modes count]; + + /* + * Need to set the status first, so that the run loop can tell + * it needs to add the stream as waiting on writable, as an + * indication of opened + */ + [self _setStatus: NSStreamStatusOpening]; + while (i-- > 0) + { + [_runloop addStream: self mode: [_modes objectAtIndex: i]]; + } + return; + } + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + return; + } + } + + open_ok: + // put itself to the runloop + [super open]; + setNonblocking((intptr_t)_loopID); +} + +- (void) close +{ + // shutdown may fail (broken pipe). Record it. + int closeReturn; + if (!_sibling || [_sibling streamStatus]==NSStreamStatusClosed) + closeReturn = close((intptr_t)_loopID); + else + closeReturn = shutdown((intptr_t)_loopID, SHUT_WR); + if (closeReturn < 0) + [self _recordError]; + [super close]; +} + +- (void) _dispatch +{ + NSStreamEvent myEvent; + + if ([self streamStatus] == NSStreamStatusOpening) + { + int error; + socklen_t len = sizeof(error); + int result; + unsigned i = [_modes count]; + + while (i-- > 0) + { + [_runloop removeStream: self mode: [_modes objectAtIndex: i]]; + } + result + = getsockopt((intptr_t)_loopID, SOL_SOCKET, SO_ERROR, &error, &len); + if (result >= 0 && !error) + { // finish up the opening + myEvent = NSStreamEventOpenCompleted; + _passive = YES; + [self open]; + // notify sibling + [_sibling open]; + [_sibling _sendEvent: myEvent]; + } + else // must be an error + { + if (error) + errno = error; + [self _recordError]; + myEvent = NSStreamEventErrorOccurred; + [_sibling _recordError]; + [_sibling _sendEvent: myEvent]; + } + } + else if ([self streamStatus] == NSStreamStatusAtEnd) + { + myEvent = NSStreamEventEndEncountered; + } + else + { + [self _setStatus: NSStreamStatusOpen]; + myEvent = NSStreamEventHasSpaceAvailable; + } + [self _sendEvent: myEvent]; +} + +@end + +@implementation GSInetOutputStream + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + int ptonReturn; + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + if ((self = [super init]) != nil) + { + _peerAddr.sin_family = AF_INET; + _peerAddr.sin_port = htons(port); + ptonReturn = inet_pton(AF_INET, addr_c, &(_peerAddr.sin_addr)); + if (ptonReturn == 0) // error { DESTROY(self); } @@ -350,16 +1044,88 @@ @end +@implementation GSInet6OutputStream +#if defined(AF_INET6) +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in6); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + int ptonReturn; + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + if ((self = [super init]) != nil) + { + _peerAddr.sin6_family = AF_INET6; + _peerAddr.sin6_port = htons(port); + ptonReturn = inet_pton(AF_INET6, addr_c, &(_peerAddr.sin6_addr)); + if (ptonReturn == 0) // error + { + DESTROY(self); + } + } + return self; +} +#else +- (id) initToAddr: (NSString*)addr port: (int)port +{ + RELEASE(self); + return nil; +} +#endif +@end + +@implementation GSLocalOutputStream + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_un); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr +{ + const char* real_addr = [addr fileSystemRepresentation]; + + if ((self = [super init]) != nil) + { + _peerAddr.sun_family = AF_LOCAL; + if (strlen(real_addr) > sizeof(_peerAddr.sun_path)-1) // too long + { + DESTROY(self); + } + else + { + strncpy(_peerAddr.sun_path, real_addr, sizeof(_peerAddr.sun_path)-1); + } + } + return self; +} + +@end + @implementation NSStream + (void) getStreamsToHost: (NSHost *)host - port: (NSInteger)port + port: (int)port inputStream: (NSInputStream **)inputStream outputStream: (NSOutputStream **)outputStream { - NSString *address = host ? (id)[host address] : (id)@"127.0.0.1"; - GSSocketStream *ins = nil; - GSSocketStream *outs = nil; + NSString *address = [host address]; + GSSocketInputStream *ins = nil; + GSSocketOutputStream *outs = nil; + int sock; // try ipv4 first ins = AUTORELEASE([[GSInetInputStream alloc] @@ -369,43 +1135,60 @@ if (!ins) { #if defined(PF_INET6) - ins = AUTORELEASE([[GSInet6InputStream alloc] - initToAddr: address port: port]); - outs = AUTORELEASE([[GSInet6OutputStream alloc] - initToAddr: address port: port]); + ins = [[GSInet6InputStream alloc] initToAddr: address + port: port]; + outs = [[GSInet6OutputStream alloc] initToAddr: address + port: port]; + sock = socket(PF_INET6, SOCK_STREAM, 0); +#else + sock = -1; #endif } + else + { + sock = socket(PF_INET, SOCK_STREAM, 0); + } + NSAssert(sock >= 0, @"Cannot open socket"); + [ins _setLoopID: (void*)(intptr_t)sock]; + [outs _setLoopID: (void*)(intptr_t)sock]; if (inputStream) { - [ins _setSibling: outs]; - *inputStream = (NSInputStream*)ins; + [ins setSibling: outs]; + *inputStream = ins; } if (outputStream) { - [outs _setSibling: ins]; - *outputStream = (NSOutputStream*)outs; + [outs setSibling: ins]; + *outputStream = outs; } + return; } + (void) getLocalStreamsToPath: (NSString *)path inputStream: (NSInputStream **)inputStream outputStream: (NSOutputStream **)outputStream { - GSSocketStream *ins = nil; - GSSocketStream *outs = nil; + GSSocketInputStream *ins = nil; + GSSocketOutputStream *outs = nil; + int sock; ins = AUTORELEASE([[GSLocalInputStream alloc] initToAddr: path]); outs = AUTORELEASE([[GSLocalOutputStream alloc] initToAddr: path]); + sock = socket(PF_LOCAL, SOCK_STREAM, 0); + + NSAssert(sock >= 0, @"Cannot open socket"); + [ins _setLoopID: (void*)(intptr_t)sock]; + [outs _setLoopID: (void*)(intptr_t)sock]; if (inputStream) { - [ins _setSibling: outs]; - *inputStream = (NSInputStream*)ins; + [ins setSibling: outs]; + *inputStream = ins; } if (outputStream) { - [outs _setSibling: ins]; - *outputStream = (NSOutputStream*)outs; + [outs setSibling: ins]; + *outputStream = outs; } return; } @@ -413,8 +1196,8 @@ + (void) pipeWithInputStream: (NSInputStream **)inputStream outputStream: (NSOutputStream **)outputStream { - GSSocketStream *ins = nil; - GSSocketStream *outs = nil; + GSSocketInputStream *ins = nil; + GSSocketOutputStream *outs = nil; int fds[2]; int pipeReturn; @@ -427,12 +1210,12 @@ [ins _setLoopID: (void*)(intptr_t)fds[0]]; [outs _setLoopID: (void*)(intptr_t)fds[1]]; // no need to connect - [ins _setPassive: YES]; - [outs _setPassive: YES]; + [ins setPassive: YES]; + [outs setPassive: YES]; if (inputStream) - *inputStream = (NSInputStream*)ins; + *inputStream = ins; if (outputStream) - *outputStream = (NSOutputStream*)outs; + *outputStream = outs; return; } @@ -505,7 +1288,7 @@ return AUTORELEASE([[GSFileInputStream alloc] initWithFileAtPath: path]); } -- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len { [self subclassResponsibility: _cmd]; return NO; @@ -519,17 +1302,17 @@ - (id) initWithData: (NSData *)data { - DESTROY(self); + RELEASE(self); return [[GSDataInputStream alloc] initWithData: data]; } - (id) initWithFileAtPath: (NSString *)path { - DESTROY(self); + RELEASE(self); return [[GSFileInputStream alloc] initWithFileAtPath: path]; } -- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len { [self subclassResponsibility: _cmd]; return -1; @@ -539,7 +1322,7 @@ @implementation NSOutputStream -+ (id) outputStreamToBuffer: (uint8_t *)buffer capacity: (NSUInteger)capacity ++ (id) outputStreamToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity { return AUTORELEASE([[GSBufferOutputStream alloc] initToBuffer: buffer capacity: capacity]); @@ -562,26 +1345,26 @@ return NO; } -- (id) initToBuffer: (uint8_t *)buffer capacity: (NSUInteger)capacity +- (id) initToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity { - DESTROY(self); + RELEASE(self); return [[GSBufferOutputStream alloc] initToBuffer: buffer capacity: capacity]; } - (id) initToFileAtPath: (NSString *)path append: (BOOL)shouldAppend { - DESTROY(self); + RELEASE(self); return [[GSFileOutputStream alloc] initToFileAtPath: path append: shouldAppend]; } - (id) initToMemory { - DESTROY(self); + RELEASE(self); return [[GSDataOutputStream alloc] init]; } -- (NSInteger) write: (const uint8_t *)buffer maxLength: (NSUInteger)len +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len { [self subclassResponsibility: _cmd]; return -1; @@ -589,6 +1372,276 @@ @end +@implementation GSServerStream + ++ (id) serverStreamToAddr: (NSString*)addr port: (int)port +{ + GSServerStream *s; + + // try inet first, then inet6 + s = [[GSInetServerStream alloc] initToAddr: addr port: port]; + if (!s) + s = [[GSInet6ServerStream alloc] initToAddr: addr port: port]; + return AUTORELEASE(s); +} + ++ (id) serverStreamToAddr: (NSString*)addr +{ + return AUTORELEASE([[GSLocalServerStream alloc] initToAddr: addr]); +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + RELEASE(self); + // try inet first, then inet6 + self = [[GSInetServerStream alloc] initToAddr: addr port: port]; + if (!self) + self = [[GSInet6ServerStream alloc] initToAddr: addr port: port]; + return self; +} + +- (id) initToAddr: (NSString*)addr +{ + RELEASE(self); + return [[GSLocalServerStream alloc] initToAddr: addr]; +} + +- (void) acceptWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + [self subclassResponsibility: _cmd]; +} + +@end + +@implementation GSSocketServerStream + +- (Class) _inputStreamClass +{ + [self subclassResponsibility: _cmd]; + return Nil; +} + +- (Class) _outputStreamClass +{ + [self subclassResponsibility: _cmd]; + return Nil; +} + +- (void) dealloc +{ + if ([self _isOpened]) + { + [self close]; + } + [super dealloc]; +} + +- (socklen_t) sockLen +{ + [self subclassResponsibility: _cmd]; + return 0; +} + +- (struct sockaddr*) serverAddr +{ + [self subclassResponsibility: _cmd]; + return 0; +} + +#define SOCKET_BACKLOG 256 + +- (void) open +{ + int bindReturn; + int listenReturn; + +#ifndef BROKEN_SO_REUSEADDR + /* + * Under decent systems, SO_REUSEADDR means that the port can be reused + * immediately that this process exits. Under some it means + * that multiple processes can serve the same port simultaneously. + * We don't want that broken behavior! + */ + int status = 1; + + setsockopt((int)(intptr_t)_loopID, SOL_SOCKET, SO_REUSEADDR, + (char *)&status, sizeof(status)); +#endif + + bindReturn = bind((int)(intptr_t)_loopID, [self serverAddr], [self sockLen]); + listenReturn = listen((intptr_t)_loopID, SOCKET_BACKLOG); + if (bindReturn < 0 || listenReturn < 0) + { + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + return; + } + setNonblocking((intptr_t)_loopID); + // put itself to the runloop + [super open]; +} + +- (void) close +{ + // close a server socket is safe + close((intptr_t)_loopID); + [super close]; +} + +- (void) acceptWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + GSSocketInputStream *ins = AUTORELEASE([[self _inputStreamClass] new]); + GSSocketOutputStream *outs = AUTORELEASE([[self _outputStreamClass] new]); + socklen_t len = [ins sockLen]; + int acceptReturn = accept((intptr_t)_loopID, [ins peerAddr], &len); + + _events &= ~NSStreamEventHasBytesAvailable; + if (acceptReturn < 0) + { // test for real error + if (errno != EWOULDBLOCK +#if defined(EAGAIN) + && errno != EAGAIN +#endif +#if defined(ECONNABORTED) + && errno != ECONNABORTED +#endif +#if defined(EPROTO) + && errno != EPROTO +#endif + && errno != EINTR) + { + [self _recordError]; + } + ins = nil; + outs = nil; + } + else + { + // no need to connect again + [ins setPassive: YES]; + [outs setPassive: YES]; + // copy the addr to outs + memcpy([outs peerAddr], [ins peerAddr], len); + [ins _setLoopID: (void*)(intptr_t)acceptReturn]; + [outs _setLoopID: (void*)(intptr_t)acceptReturn]; + } + if (inputStream) + { + [ins setSibling: outs]; + *inputStream = ins; + } + if (outputStream) + { + [outs setSibling: ins]; + *outputStream = outs; + } +} + +- (void) _dispatch +{ + NSStreamEvent myEvent; + + [self _setStatus: NSStreamStatusOpen]; + myEvent = NSStreamEventHasBytesAvailable; + [self _sendEvent: myEvent]; +} + +@end + +@implementation GSInetServerStream + +- (Class) _inputStreamClass +{ + return [GSInetInputStream class]; +} + +- (Class) _outputStreamClass +{ + return [GSInetOutputStream class]; +} + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in); +} + +- (struct sockaddr*) serverAddr +{ + return (struct sockaddr*)&_serverAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + int ptonReturn; + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + [super init]; + _serverAddr.sin_family = AF_INET; + _serverAddr.sin_port = htons(port); + ptonReturn = inet_pton(AF_INET, addr_c, &(_serverAddr.sin_addr)); + _loopID = (void*)(intptr_t)socket(AF_INET, SOCK_STREAM, 0); + if (ptonReturn == 0 || _loopID < 0) // error + { + RELEASE(self); + return nil; + } + NSAssert(_loopID >= 0, @"cannot open socket"); + return self; +} + +@end + +@implementation GSInet6ServerStream +#if defined(AF_INET6) +- (Class) _inputStreamClass +{ + return [GSInet6InputStream class]; +} + +- (Class) _outputStreamClass +{ + return [GSInet6OutputStream class]; +} + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in6); +} + +- (struct sockaddr*) serverAddr +{ + return (struct sockaddr*)&_serverAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + int ptonReturn; + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + [super init]; + _serverAddr.sin6_family = AF_INET6; + _serverAddr.sin6_port = htons(port); + ptonReturn = inet_pton(AF_INET6, addr_c, &(_serverAddr.sin6_addr)); + _loopID = (void*)(intptr_t)socket(AF_INET6, SOCK_STREAM, 0); + if (ptonReturn == 0 || _loopID < 0) // error + { + RELEASE(self); + return nil; + } + NSAssert(_loopID >= 0, @"cannot open socket"); + return self; +} +#else +- (id) initToAddr: (NSString*)addr port: (int)port +{ + RELEASE(self); + return nil; +} +#endif +@end + @implementation GSLocalServerStream - (Class) _inputStreamClass @@ -601,15 +1654,28 @@ return [GSLocalOutputStream class]; } +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_un); +} + +- (struct sockaddr*) serverAddr +{ + return (struct sockaddr*)&_serverAddr; +} + - (id) initToAddr: (NSString*)addr { - if ((self = [super init]) != nil) + const char* real_addr = [addr fileSystemRepresentation]; + [super init]; + _serverAddr.sun_family = AF_LOCAL; + _loopID = (void *)(intptr_t)socket(AF_LOCAL, SOCK_STREAM, 0); + if (strlen(real_addr) > sizeof(_serverAddr.sun_path)-1 || _loopID < 0) { - if ([self _setSocketAddress: addr port: 0 family: AF_UNIX] == NO) - { - DESTROY(self); - } + RELEASE(self); + return nil; } + strncpy(_serverAddr.sun_path, real_addr, sizeof(_serverAddr.sun_path)-1); return self; } diff --git a/Source/win32-def.top b/Source/win32-def.top index 83294f9cc..c856b9400 100644 --- a/Source/win32-def.top +++ b/Source/win32-def.top @@ -12,7 +12,7 @@ ; This file is part of the GNUstep Base Library. ; ; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public +; modify it under the terms of the GNU Library General Public ; License as published by the Free Software Foundation; either ; version 2 of the License, or (at your option) any later version. ; @@ -21,7 +21,7 @@ ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ; Library General Public License for more details. ; -; You should have received a copy of the GNU Lesser General Public +; You should have received a copy of the GNU Library General Public ; License along with this library; if not, write to the Free ; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. ; diff --git a/Source/win32-load.h b/Source/win32-load.h index 172d5f851..eca0175dc 100644 --- a/Source/win32-load.h +++ b/Source/win32-load.h @@ -5,15 +5,14 @@ Copyright (C) 1998, Free Software Foundation This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. -This program is distributed in the +it under the terms of the GNU Library General Public License as published by +the Free Software Foundation; either version 2 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 Lesser General Public License for more details. +PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Lesser General Public License +You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/Source/win32/GNUmakefile b/Source/win32/GNUmakefile index cb4482aa0..9cc6b69c6 100644 --- a/Source/win32/GNUmakefile +++ b/Source/win32/GNUmakefile @@ -8,7 +8,7 @@ # This file is part of the GNUstep Base Library. # # This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public +# modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # @@ -17,12 +17,11 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public +# You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. # -PACKAGE_NAME = gnustep-base GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../base.make include $(GNUSTEP_MAKEFILES)/common.make @@ -31,12 +30,12 @@ include ../../config.mak SUBPROJECT_NAME = win32 win32_OBJC_FILES =\ - GSFileHandle.m \ + GSFileHandleWin32.m \ GSRunLoopCtxt.m \ - NSMessagePort.m \ - NSMessagePortNameServer.m \ - NSStream.m \ - NSUserDefaults.m \ + NSMessagePortWin32.m \ + NSMessagePortNameServerWin32.m \ + NSStreamWin32.m \ + NSUserDefaultsWin32.m \ -include Makefile.preamble diff --git a/Source/win32/GSFileHandle.m b/Source/win32/GSFileHandleWin32.m similarity index 87% rename from Source/win32/GSFileHandle.m rename to Source/win32/GSFileHandleWin32.m index c13401064..03e99148e 100644 --- a/Source/win32/GSFileHandle.m +++ b/Source/win32/GSFileHandleWin32.m @@ -7,7 +7,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -24,7 +24,7 @@ #define _FILE_OFFSET_BITS 64 -#include "common.h" +#include "config.h" #include "GNUstepBase/preface.h" #include "Foundation/NSObject.h" @@ -93,7 +93,7 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey"; * Encapsulates low level read operation to get data from the operating * system. */ -- (NSInteger) read: (void*)buf length: (NSUInteger)len +- (int) read: (void*)buf length: (int)len { #if USE_ZLIB if (gzDescriptor != 0) @@ -108,23 +108,16 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey"; } else { - DWORD readBytes = -1; - - if (ReadFile((HANDLE)_get_osfhandle(descriptor), buf, len, - &readBytes, NULL)) - { - return readBytes; - } - else - { - DWORD err = GetLastError(); - - if (err == ERROR_BROKEN_PIPE || err == ERROR_HANDLE_EOF) - { - return readBytes; - } - return -1; - } + DWORD readBytes=-1; + if (ReadFile((HANDLE)_get_osfhandle(descriptor), buf, len, &readBytes, NULL)) { + return readBytes; + } else { + DWORD err = GetLastError(); + if (err == ERROR_BROKEN_PIPE || err == ERROR_HANDLE_EOF) { + return readBytes; + } + return -1; + } } return len; } @@ -133,7 +126,7 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey"; * Encapsulates low level write operation to send data to the operating * system. */ -- (NSInteger) write: (const void*)buf length: (NSUInteger)len +- (int) write: (const void*)buf length: (int)len { #if USE_ZLIB if (gzDescriptor != 0) @@ -248,14 +241,14 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) RELEASE(service); RELEASE(protocol); - [self finalize]; + [self gcFinalize]; RELEASE(readInfo); RELEASE(writeInfo); [super dealloc]; } -- (void) finalize +- (void) gcFinalize { if (self == fh_stdin) fh_stdin = nil; @@ -701,7 +694,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (s == nil) { NSLog(@"bad argument - service is nil"); - DESTROY(self); + RELEASE(self); return nil; } @@ -723,7 +716,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getAddr(lhost, p, @"tcp", &lsin) == NO) { NSLog(@"bad bind address specification"); - DESTROY(self); + RELEASE(self); return nil; } p = @"tcp"; @@ -769,7 +762,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getAddr(a, s, p, &sin) == NO) { - DESTROY(self); + RELEASE(self); NSLog(@"bad address-service-protocol combination"); return nil; } @@ -793,7 +786,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (getAddr(shost, sport, p, &sin) == NO) { NSLog(@"bad SOCKS host-port combination"); - DESTROY(self); + RELEASE(self); return nil; } } @@ -801,7 +794,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) { NSLog(@"unable to create socket - %@", [NSError _last]); - DESTROY(self); + RELEASE(self); return nil; } /* @@ -817,7 +810,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(lsin.sin_addr), GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); (void) closesocket(net); - DESTROY(self); + RELEASE(self); return nil; } } @@ -836,7 +829,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSLog(@"unable to make connection to %s:%d - %@", inet_ntoa(sin.sin_addr), GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); - DESTROY(self); + RELEASE(self); return nil; } } @@ -870,11 +863,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; } [writeInfo addObject: info]; RELEASE(info); + [self watchWriteDescriptor]; connectOK = YES; acceptOK = NO; readOK = NO; writeOK = NO; - [self watchWriteDescriptor]; } return self; } @@ -888,11 +881,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; #endif SOCKET net; struct sockaddr_in sin; - int size = sizeof(sin); + unsigned int size = sizeof(sin); if (getAddr(a, s, p, &sin) == NO) { - DESTROY(self); + RELEASE(self); NSLog(@"bad address-service-protocol combination"); return nil; } @@ -900,7 +893,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == INVALID_SOCKET) { NSLog(@"unable to create socket - %@", [NSError _last]); - DESTROY(self); + RELEASE(self); return nil; } @@ -919,7 +912,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr), GSSwapBigI16ToHost(sin.sin_port), [NSError _last]); (void) closesocket(net); - DESTROY(self); + RELEASE(self); return nil; } @@ -927,7 +920,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSLog(@"unable to listen on port - %@", [NSError _last]); (void) closesocket(net); - DESTROY(self); + RELEASE(self); return nil; } @@ -935,7 +928,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSLog(@"unable to get socket name - %@", [NSError _last]); (void) closesocket(net); - DESTROY(self); + RELEASE(self); return nil; } @@ -960,7 +953,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (d < 0) { - DESTROY(self); + RELEASE(self); return nil; } else @@ -984,7 +977,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (d < 0) { - DESTROY(self); + RELEASE(self); return nil; } else @@ -1008,7 +1001,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (d < 0) { - DESTROY(self); + RELEASE(self); return nil; } else @@ -1028,7 +1021,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (fh_stderr != nil) { RETAIN(fh_stderr); - DESTROY(self); + RELEASE(self); } else { @@ -1048,7 +1041,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (fh_stdin != nil) { RETAIN(fh_stdin); - DESTROY(self); + RELEASE(self); } else { @@ -1068,7 +1061,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (fh_stdout != nil) { RETAIN(fh_stdout); - DESTROY(self); + RELEASE(self); } else { @@ -1085,25 +1078,10 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; - (id) initWithNullDevice { - int d = _open("NUL", O_RDWR|O_BINARY); - - if (d < 0) - { - DESTROY(self); - return nil; - } - else - { - self = [self initWithFileDescriptor: d closeOnDealloc: YES]; - if (self != nil) - { - connectOK = NO; - acceptOK = NO; - isNullDevice = YES; - isStandardFile = YES; - } - return self; - } + isNullDevice = YES; + isStandardFile = YES; + descriptor = -1; + return self; } - (id) initWithFileDescriptor: (int)desc closeOnDealloc: (BOOL)flag @@ -1112,7 +1090,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (self != nil) { struct _stat sbuf; - HANDLE h = (HANDLE)_get_osfhandle(desc); if (_fstat(desc, &sbuf) != 0) { @@ -1133,18 +1110,24 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; if (isStandardFile == NO) { - if (GetFileType(h) == FILE_TYPE_PIPE) + unsigned long nbio = 0; + + isSocket = YES; + /* + * This is probably a socket ... try + * using a socket specific call and see if that fails. + */ + if (ioctlsocket((SOCKET)_get_osfhandle(desc), FIONBIO, &nbio) == 0) { - /* If we can't get named pipe info, we assume this is a socket. - */ - if (GetNamedPipeInfo(h, 0, 0, 0, 0) == 0) - { - isSocket = YES; - } + wasNonBlocking = (nbio == 0) ? NO : YES; + } + else + { + isSocket = NO; // maybe special file desc. like std in/out/err? } } - isNonBlocking = 0; + isNonBlocking = wasNonBlocking; descriptor = desc; closeOnDealloc = flag; readInfo = nil; @@ -1163,7 +1146,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSLog(@"Invalid Event - '%d'", WSAGetLastError()); return nil; } - WSAEventSelect((SOCKET)h, event, FD_ALL_EVENTS); + WSAEventSelect(_get_osfhandle(descriptor), event, FD_ALL_EVENTS); } else { @@ -1243,7 +1226,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; } if (readInfo) { - [self receivedEventRead]; + [self receivedEventRead]; } } @@ -1663,8 +1646,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; - (void) writeInBackgroundAndNotify: (NSData*)item forModes: (NSArray*)modes { - NSMutableDictionary *info; - BOOL writeWasInProgress; + NSMutableDictionary* info; [self checkWrite]; @@ -1676,20 +1658,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [info setObject: modes forKey: NSFileHandleNotificationMonitorModes]; } - writeWasInProgress = [writeInfo count] == 0 ? NO : YES; [writeInfo addObject: info]; RELEASE(info); - /* On mswindows we receive a write trigger only when a write actually - * completes, so if there is no write in progress, we trigger one. - */ - if (writeWasInProgress == NO) - { - [self receivedEventWrite]; - } - else - { - [self watchWriteDescriptor]; - } + [self watchWriteDescriptor]; } - (void) writeInBackgroundAndNotify: (NSData*)item; @@ -1770,8 +1741,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSRunLoop *l; NSArray *modes; - void *e; - int t; if (descriptor < 0) { @@ -1785,16 +1754,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; modes = (NSArray*)[readInfo objectForKey: NSFileHandleNotificationMonitorModes]; } - if (event == WSA_INVALID_EVENT) - { - e = (void*)(uintptr_t)descriptor; - t = ET_TRIGGER; - } - else - { - e = (void*)(uintptr_t)event; - t = ET_HANDLE; - } if (modes && [modes count]) { @@ -1802,16 +1761,28 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; for (i = 0; i < [modes count]; i++) { - [l removeEvent: e - type: t + if (event) + [l removeEvent: (void*)(uintptr_t)event + type: ET_HANDLE + forMode: [modes objectAtIndex: i] + all: YES]; + else + [l removeEvent:0 + type: ET_TRIGGER forMode: [modes objectAtIndex: i] all: YES]; } } else { - [l removeEvent: e - type: t + if (event) + [l removeEvent: (void*)(uintptr_t)event + type: ET_HANDLE + forMode: NSDefaultRunLoopMode + all: YES]; + else + [l removeEvent:0 + type: ET_TRIGGER forMode: NSDefaultRunLoopMode all: YES]; } @@ -1821,8 +1792,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSRunLoop *l; NSArray *modes; - void *e; - int t; if (descriptor < 0) { @@ -1838,33 +1807,22 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; modes=(NSArray*)[info objectForKey: NSFileHandleNotificationMonitorModes]; } - if (event == WSA_INVALID_EVENT) - { - e = (void*)(uintptr_t)descriptor; - t = ET_TRIGGER; - } - else - { - e = (void*)(uintptr_t)event; - t = ET_HANDLE; - } - if (modes && [modes count]) { unsigned int i; for (i = 0; i < [modes count]; i++) { - [l removeEvent: e - type: t + [l removeEvent: (void*)(uintptr_t)event + type: event ? ET_HANDLE : ET_TRIGGER forMode: [modes objectAtIndex: i] all: YES]; } } else { - [l removeEvent: e - type: t + [l removeEvent: (void*)(uintptr_t)event + type: event ? ET_HANDLE : ET_TRIGGER forMode: NSDefaultRunLoopMode all: YES]; } @@ -1873,8 +1831,6 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; - (void) watchReadDescriptorForModes: (NSArray*)modes; { NSRunLoop *l; - void *e; - int t; if (descriptor < 0) { @@ -1883,26 +1839,20 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; l = [NSRunLoop currentRunLoop]; [self setNonBlocking: YES]; - - if (event == WSA_INVALID_EVENT) - { - e = (void*)(uintptr_t)descriptor; - t = ET_TRIGGER; - } - else - { - e = (void*)(uintptr_t)event; - t = ET_HANDLE; - } - if (modes && [modes count]) { unsigned int i; for (i = 0; i < [modes count]; i++) { - [l addEvent: e - type: t + if (event) + [l addEvent: (void*)(uintptr_t)event + type: ET_HANDLE + watcher: self + forMode: [modes objectAtIndex: i]]; + else + [l addEvent:0 + type: ET_TRIGGER watcher: self forMode: [modes objectAtIndex: i]]; } @@ -1910,8 +1860,14 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; } else { - [l addEvent: e - type: t + if (event) + [l addEvent: (void*)(uintptr_t)event + type: ET_HANDLE + watcher: self + forMode: NSDefaultRunLoopMode]; + else + [l addEvent:0 + type: ET_TRIGGER watcher: self forMode: NSDefaultRunLoopMode]; } @@ -1928,47 +1884,30 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSMutableDictionary *info = [writeInfo objectAtIndex: 0]; NSRunLoop *l = [NSRunLoop currentRunLoop]; NSArray *modes = nil; - void *e; - int t; modes = [info objectForKey: NSFileHandleNotificationMonitorModes]; [self setNonBlocking: YES]; - - if (event == WSA_INVALID_EVENT) - { - e = (void*)(uintptr_t)descriptor; - t = ET_TRIGGER; - } - else - { - e = (void*)(uintptr_t)event; - t = ET_HANDLE; - } - if (modes && [modes count]) { unsigned int i; for (i = 0; i < [modes count]; i++) { - [l addEvent: e - type: t + [l addEvent: (void*)(uintptr_t)event + type: event ? ET_HANDLE : ET_TRIGGER watcher: self forMode: [modes objectAtIndex: i]]; } } else { - [l addEvent: e - type: t + [l addEvent: (void*)(uintptr_t)event + type: event ? ET_HANDLE : ET_TRIGGER watcher: self forMode: NSDefaultRunLoopMode]; } } - else - { - } } - (void) receivedEventRead @@ -1980,7 +1919,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { struct sockaddr_in buf; SOCKET desc; - int blen = sizeof(buf); + unsigned int blen = sizeof(buf); desc = accept((SOCKET)_get_osfhandle(descriptor), (struct sockaddr*)&buf, &blen); @@ -1997,7 +1936,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { // Accept attempt completed. GSFileHandle *h; struct sockaddr_in sin; - int size = sizeof(sin); + unsigned int size = sizeof(sin); int status; /* @@ -2008,109 +1947,78 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; sizeof(status)); h = [[[self class] alloc] initWithNativeHandle: (void*)desc - closeOnDealloc: YES]; + closeOnDealloc: YES]; h->isSocket = YES; getpeername(desc, (struct sockaddr*)&sin, &size); [h setAddr: &sin]; [readInfo setObject: h - forKey: NSFileHandleNotificationFileHandleItem]; + forKey: NSFileHandleNotificationFileHandleItem]; RELEASE(h); } [self postReadNotification]; } + else if (operation == NSFileHandleDataAvailableNotification) + { + [self postReadNotification]; + } else { - /* If this is not a socket or a standard file, we assume it's a pipe - * and therefore we need to check to see if data really is available. + NSMutableData *item; + int length; + int received = 0; + char buf[READ_SIZE]; + + item = [readInfo objectForKey: NSFileHandleNotificationDataItem]; + /* + * We may have a maximum data size set... */ - if (NO == isSocket && NO == isStandardFile) - { - HANDLE h = (HANDLE)_get_osfhandle(descriptor); - DWORD bytes = 0; - - if (PeekNamedPipe(h, 0, 0, 0, &bytes, 0) == 0) - { - DWORD e = GetLastError(); - - if (e != ERROR_BROKEN_PIPE && e != ERROR_HANDLE_EOF) - { - NSLog(@"pipe peek problem %d, %@", e, [NSError _last]); - return; - } - /* In the case of a broken pipe, we fall through so that a read - * attempt is performed allowing higer level code to notice the - * problem and deal with it. - */ + if (readMax > 0) + { + length = (unsigned int)readMax - [item length]; + if (length > (int)sizeof(buf)) + { + length = sizeof(buf); } - else if (bytes == 0) - { - return; // No data available yet. - } - } - - if (operation == NSFileHandleDataAvailableNotification) - { - [self postReadNotification]; } else { - NSMutableData *item; - int length; - int received = 0; - char buf[READ_SIZE]; + length = sizeof(buf); + } - item = [readInfo objectForKey: NSFileHandleNotificationDataItem]; - /* - * We may have a maximum data size set... - */ - if (readMax > 0) - { - length = (unsigned int)readMax - [item length]; - if (length > (int)sizeof(buf)) - { - length = sizeof(buf); - } - } - else - { - length = sizeof(buf); - } + received = [self read: buf length: length]; + if (received == 0) + { // Read up to end of file. + [self postReadNotification]; + } + else if (received < 0) + { + if (isSocket && (WSAGetLastError() != WSAEINTR + && WSAGetLastError() != WSAEWOULDBLOCK)) + { + NSString *s; - received = [self read: buf length: length]; - if (received == 0) - { // Read up to end of file. + s = [NSString stringWithFormat: @"Read attempt failed - %@", + [NSError _last]]; + [readInfo setObject: s forKey: GSFileHandleNotificationError]; [self postReadNotification]; } - else if (received < 0) - { - if (isSocket && (WSAGetLastError() != WSAEINTR - && WSAGetLastError() != WSAEWOULDBLOCK)) - { - NSString *s; + else if (!isSocket && (GetLastError() != ERROR_NO_DATA)) + { + NSString *s; - s = [NSString stringWithFormat: @"Read attempt failed - %@", - [NSError _last]]; - [readInfo setObject: s forKey: GSFileHandleNotificationError]; - [self postReadNotification]; - } - else if (!isSocket && (GetLastError() != ERROR_NO_DATA)) - { - NSString *s; - - s = [NSString stringWithFormat: @"Read attempt failed - %@", - [NSError _last]]; - [readInfo setObject: s forKey: GSFileHandleNotificationError]; - [self postReadNotification]; - } + s = [NSString stringWithFormat: @"Read attempt failed - %@", + [NSError _last]]; + [readInfo setObject: s forKey: GSFileHandleNotificationError]; + [self postReadNotification]; } - else + } + else + { + [item appendBytes: buf length: received]; + if (readMax < 0 || (readMax > 0 && (int)[item length] == readMax)) { - [item appendBytes: buf length: received]; - if (readMax < 0 || (readMax > 0 && (int)[item length] == readMax)) - { - // Read a single chunk of data - [self postReadNotification]; - } + // Read a single chunk of data + [self postReadNotification]; } } } @@ -2132,7 +2040,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { // Connection attempt completed. int result; int rval; - int len = sizeof(result); + unsigned len = sizeof(result); rval = getsockopt((SOCKET)_get_osfhandle(descriptor), SOL_SOCKET, SO_ERROR, (char*)&result, &len); @@ -2205,29 +2113,16 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; extra: (void*)extra forMode: (NSString*)mode { - NSDebugMLLog(@"NSFileHandle", @"%@ event: %lu type: %lu extra: %lu mode: %@", - self, (uintptr_t)data, (uintptr_t)type, (uintptr_t)extra, mode); + WSANETWORKEVENTS ocurredEvents; + + NSDebugMLLog(@"NSFileHandle", @"%@ event: %d", self, type); if (isNonBlocking == NO) { [self setNonBlocking: YES]; } - if (isSocket == YES) + if (isSocket) { - WSANETWORKEVENTS ocurredEvents; - - if (type != ET_HANDLE) - { - NSLog(@"Argh, TRIGGER on socket %lu %lu %@ with event %u desc %u", - (uintptr_t)data, (uintptr_t)extra, mode, (uintptr_t)event, - (uintptr_t)descriptor); -/* - [[NSRunLoop currentRunLoop] removeEvent: data - type: type - forMode: mode - all: YES]; -*/ - } if (WSAEnumNetworkEvents((SOCKET)_get_osfhandle(descriptor), event, &ocurredEvents) == SOCKET_ERROR) { @@ -2239,35 +2134,35 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; NSDebugMLLog(@"NSFileHandle", @"Connect on %x", extra); ocurredEvents.lNetworkEvents ^= FD_CONNECT; [self receivedEventWrite]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } if (ocurredEvents.lNetworkEvents & FD_ACCEPT) { NSDebugMLLog(@"NSFileHandle", @"Accept on %x", extra); ocurredEvents.lNetworkEvents ^= FD_ACCEPT; [self receivedEventRead]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } if (ocurredEvents.lNetworkEvents & FD_WRITE) { NSDebugMLLog(@"NSFileHandle", @"Write on %x", extra); ocurredEvents.lNetworkEvents ^= FD_WRITE; [self receivedEventWrite]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } if (ocurredEvents.lNetworkEvents & FD_READ) { NSDebugMLLog(@"NSFileHandle", @"Read on %x", extra); ocurredEvents.lNetworkEvents ^= FD_READ; [self receivedEventRead]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } if (ocurredEvents.lNetworkEvents & FD_OOB) { NSDebugMLLog(@"NSFileHandle", @"OOB on %x", extra); ocurredEvents.lNetworkEvents ^= FD_OOB; [self receivedEventRead]; - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } if (ocurredEvents.lNetworkEvents & FD_CLOSE) { @@ -2281,7 +2176,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [self receivedEventRead]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } if (ocurredEvents.lNetworkEvents) { @@ -2299,7 +2194,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { [self receivedEventRead]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } } @@ -2337,26 +2232,21 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { unsigned long dummy; - if (isSocket != YES) - { // Not a file and not a socket, must be a pipe - DWORD mode; - - if (flag) - mode = PIPE_NOWAIT; - else - mode = PIPE_WAIT; - if (SetNamedPipeHandleState((HANDLE)_get_osfhandle(descriptor), - &mode, NULL, NULL)) - { - isNonBlocking = flag; - } - else - { + if (isSocket != YES) { + // Not a file and not a socket, must be a pipe + DWORD mode; + if (flag) + mode = PIPE_NOWAIT; + else + mode = PIPE_WAIT; + if (SetNamedPipeHandleState((HANDLE)_get_osfhandle(descriptor), &mode, NULL, NULL)) { + isNonBlocking = flag; + } else { NSLog(@"unable to set pipe non-blocking mode - %d", GetLastError()); - } - return; - } + } + return; + } if (flag) { @@ -2393,10 +2283,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSString *str = nil; struct sockaddr_in sin; - int size = sizeof(sin); + unsigned size = sizeof(sin); - if (getsockname((SOCKET)_get_osfhandle(descriptor), - (struct sockaddr*)&sin, &size) == SOCKET_ERROR) + if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) { NSLog(@"unable to get socket name - %@", [NSError _last]); } @@ -2411,10 +2300,9 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr"; { NSString *str = nil; struct sockaddr_in sin; - int size = sizeof(sin); + unsigned size = sizeof(sin); - if (getsockname((SOCKET)_get_osfhandle(descriptor), - (struct sockaddr*)&sin, &size) == SOCKET_ERROR) + if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR) { NSLog(@"unable to get socket name - %@", [NSError _last]); } diff --git a/Source/win32/GSRunLoopCtxt.m b/Source/win32/GSRunLoopCtxt.m index b6720aaa2..0d268c3a7 100644 --- a/Source/win32/GSRunLoopCtxt.m +++ b/Source/win32/GSRunLoopCtxt.m @@ -6,17 +6,18 @@ * NB. This class is private to NSRunLoop and must not be subclassed. */ -#import "common.h" +#include "config.h" -#import "GNUstepBase/preface.h" -#import "Foundation/NSError.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSNotificationQueue.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSStream.h" -#import "../GSRunLoopCtxt.h" -#import "../GSRunLoopWatcher.h" -#import "../GSPrivate.h" +#include "GNUstepBase/preface.h" +#include +#include +#include +#include +#include +#include +#include "../GSRunLoopCtxt.h" +#include "../GSRunLoopWatcher.h" +#include "../GSPrivate.h" #if GS_WITH_GC == 0 static SEL wRelSel; @@ -146,32 +147,23 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = self = [super init]; if (self != nil) { - NSZone *z; + NSZone *z = [self zone]; mode = [theMode copy]; extra = e; -#if GS_WITH_GC - z = (NSZone*)1; - performers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); - timers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); - watchers = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); - _trigger = NSAllocateCollectable(sizeof(GSIArray_t), NSScannedOption); -#else - z = [self zone]; performers = NSZoneMalloc(z, sizeof(GSIArray_t)); - timers = NSZoneMalloc(z, sizeof(GSIArray_t)); - watchers = NSZoneMalloc(z, sizeof(GSIArray_t)); - _trigger = NSZoneMalloc(z, sizeof(GSIArray_t)); -#endif GSIArrayInitWithZoneAndCapacity(performers, z, 8); + timers = NSZoneMalloc(z, sizeof(GSIArray_t)); GSIArrayInitWithZoneAndCapacity(timers, z, 8); + watchers = NSZoneMalloc(z, sizeof(GSIArray_t)); GSIArrayInitWithZoneAndCapacity(watchers, z, 8); - GSIArrayInitWithZoneAndCapacity(_trigger, z, 8); handleMap = NSCreateMapTable(NSIntMapKeyCallBacks, WatcherMapValueCallBacks, 0); winMsgMap = NSCreateMapTable(NSIntMapKeyCallBacks, WatcherMapValueCallBacks, 0); + _trigger = NSZoneMalloc(z, sizeof(GSIArray_t)); + GSIArrayInitWithZoneAndCapacity(_trigger, z, 8); } return self; } @@ -283,7 +275,6 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = - (BOOL) pollUntil: (int)milliseconds within: (NSArray*)contexts { - GSRunLoopThreadInfo *threadInfo = GSRunLoopInfoForThread(nil); NSMapEnumerator hEnum; GSRunLoopWatcher *watcher; HANDLE handleArray[MAXIMUM_WAIT_OBJECTS-1]; @@ -311,9 +302,8 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = GSIArrayRemoveAllItems(_trigger); i = GSIArrayCount(watchers); - num_handles = 1; // One handle for signals from other threads + num_handles = 0; num_winMsgs = 0; - while (i-- > 0) { GSRunLoopWatcher *info; @@ -339,7 +329,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = switch (info->type) { case ET_HANDLE: - handle = (HANDLE)(size_t)info->data; + handle = (HANDLE)(int)info->data; NSMapInsert(handleMap, (void*)handle, info); num_handles++; break; @@ -363,13 +353,13 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = while (port_handle_count--) { NSMapInsert(handleMap, - (void*)(size_t) port_handle_array[port_handle_count], info); + (void*)port_handle_array[port_handle_count], info); num_handles++; } } break; case ET_WINMSG: - handle = (HANDLE)(size_t)info->data; + handle = (HANDLE)(int)info->data; NSMapInsert(winMsgMap, (void*)handle, info); num_winMsgs++; break; @@ -385,13 +375,12 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = * we can service the queue. Similarly, if a task has completed, * we need to deliver its notifications. */ - if (GSPrivateCheckTasks() || GSPrivateNotifyMore(mode) || immediate == YES) + if (GSPrivateCheckTasks() || GSPrivateNotifyMore() || immediate == YES) { wait_timeout = 0; } i = 0; - handleArray[i++] = threadInfo->event; // Signal from other thread hEnum = NSEnumerateMapTable(handleMap); while (NSNextMapEnumeratorPair(&hEnum, &handle, (void**)&watcher)) { @@ -435,7 +424,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = } else { - SleepEx(wait_timeout, TRUE); + SleepEx(wait_timeout, TRUE); wait_return = WAIT_OBJECT_0; } NSDebugMLLog(@"NSRunLoop", @"wait returned %d", wait_return); @@ -478,14 +467,13 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = */ count = GSIArrayCount(_trigger); completed = NO; - while (count-- > 0) + while (completed == NO && count-- > 0) { GSRunLoopWatcher *watcher; watcher = (GSRunLoopWatcher*)GSIArrayItemAtIndex(_trigger, count).obj; if (watcher->_invalidated == NO) { - NSDebugMLLog(@"NSRunLoop", @"trigger watcher %@", watcher); i = [contexts count]; while (i-- > 0) { @@ -505,21 +493,19 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = extra: watcher->data forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); } // if there are windows message if (wait_return == WAIT_OBJECT_0 + num_handles) { - NSDebugMLLog(@"NSRunLoop", @"processing windows messages"); [self processAllWindowsMessages: num_winMsgs within: contexts]; return NO; } - // if there aren't events + // if there arent events if (wait_return == WAIT_TIMEOUT) { - NSDebugMLLog(@"NSRunLoop", @"timeout without events"); completed = YES; return NO; } @@ -535,16 +521,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = handle = handleArray[i]; - if (handle == threadInfo->event) - { - watcher = nil; - NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); - [threadInfo fire]; - } - else - { - watcher = (GSRunLoopWatcher*)NSMapGet(handleMap, (void*)handle); - } + watcher = (GSRunLoopWatcher*)NSMapGet(handleMap, (void*)handle); if (watcher != nil && watcher->_invalidated == NO) { i = [contexts count]; @@ -564,30 +541,14 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks = NSDebugMLLog(@"NSRunLoop", @"Event callback found"); [watcher->receiver receivedEvent: watcher->data type: watcher->type - extra: (void*)handle + extra: watcher->data forMode: mode]; } - GSPrivateNotifyASAP(mode); + GSPrivateNotifyASAP(); completed = YES; return YES; } -+ (BOOL) awakenedBefore: (NSDate*)when -{ - GSRunLoopThreadInfo *threadInfo = GSRunLoopInfoForThread(nil); - NSTimeInterval ti = (when == nil) ? 0.0 : [when timeIntervalSinceNow]; - int milliseconds = (ti <= 0.0) ? 0 : (int)(ti*1000); - HANDLE h = threadInfo->event; - - if (WaitForMultipleObjects(1, &h, NO, milliseconds) != WAIT_TIMEOUT) - { - NSDebugMLLog(@"NSRunLoop", @"Fire perform on thread"); - [threadInfo fire]; - return YES; - } - return NO; -} - @end diff --git a/Source/win32/Makefile.preamble b/Source/win32/Makefile.preamble index 756197ec3..976c12759 100644 --- a/Source/win32/Makefile.preamble +++ b/Source/win32/Makefile.preamble @@ -8,7 +8,7 @@ # This file is part of the GNUstep Base Library. # # This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public +# modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # @@ -20,7 +20,7 @@ # If you are interested in a warranty or support for this source code, # contact Scott Christley at scottc@net-community.com # -# You should have received a copy of the GNU Lesser General Public +# You should have received a copy of the GNU Library General Public # License along with this library; see the file COPYING.LIB. # If not, write to the Free Software Foundation, # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -39,7 +39,7 @@ # # Additional flags to pass to the preprocessor -ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS) +ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) -Wall # Additional flags to pass to the Objective-C compiler #ADDITIONAL_OBJCFLAGS = @@ -55,8 +55,7 @@ endif ADDITIONAL_CFLAGS = # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS = -I../../Headers/Additions \ - -I../$(GNUSTEP_TARGET_DIR) +ADDITIONAL_INCLUDE_DIRS = -I../$(GNUSTEP_TARGET_DIR) ifeq ($(FOUNDATION_LIB),gnu) ADDITIONAL_INCLUDE_DIRS += -I../../Headers diff --git a/Source/win32/NSMessagePortNameServer.m b/Source/win32/NSMessagePortNameServerWin32.m similarity index 95% rename from Source/win32/NSMessagePortNameServer.m rename to Source/win32/NSMessagePortNameServerWin32.m index 08e5b3523..a7e13923b 100644 --- a/Source/win32/NSMessagePortNameServer.m +++ b/Source/win32/NSMessagePortNameServerWin32.m @@ -5,7 +5,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -14,7 +14,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. @@ -23,8 +23,6 @@ $Date$ $Revision$ */ -#include "common.h" - #include "Foundation/NSPortNameServer.h" #include "Foundation/NSAutoreleasePool.h" @@ -43,16 +41,16 @@ #include "GNUstepBase/GSMime.h" #include "../GSPrivate.h" -#include "../GSPortPrivate.h" +#include "GSPortPrivate.h" #define UNISTR(X) \ ((const unichar*)[(X) cStringUsingEncoding: NSUnicodeStringEncoding]) -extern __declspec(dllimport) int errno; +extern int errno; static NSRecursiveLock *serverLock = nil; static NSMessagePortNameServer *defaultServer = nil; -static NSMapTable *portToNamesMap; +static NSMapTable portToNamesMap; static NSString *registry; static HKEY key; @@ -78,7 +76,7 @@ static void clean_up_names(void) [defaultServer removePort: port]; } NSEndMapTableEnumeration(&mEnum); - IF_NO_GC([arp release]); + DESTROY(arp); RegCloseKey(key); if (unknownThread == YES) { @@ -107,14 +105,14 @@ static void clean_up_names(void) security.nLength = sizeof(SECURITY_ATTRIBUTES); security.lpSecurityDescriptor = 0; // Default - security.bInheritHandle = FALSE; + security.bInheritHandle = TRUE; registry = @"Software\\GNUstepNSMessagePort"; rc = RegCreateKeyExW( HKEY_CURRENT_USER, UNISTR(registry), 0, - (LPWSTR) L"", + L"", REG_OPTION_VOLATILE, STANDARD_RIGHTS_WRITE|STANDARD_RIGHTS_READ|KEY_SET_VALUE |KEY_QUERY_VALUE|KEY_NOTIFY, @@ -229,7 +227,7 @@ OutputDebugStringW(L""); return nil; } - mailslotName = [NSString stringWithUTF8String: (const char *) ptr]; + mailslotName = [NSString stringWithUTF8String: ptr]; if (ptr != buf) { objc_free(ptr); @@ -340,7 +338,7 @@ OutputDebugStringW(L""); } n = [[self class] _translate: name]; - str = (const unsigned char *) [[(NSMessagePort*)port name] UTF8String]; + str = [[(NSMessagePort*)port name] UTF8String]; rc = RegSetValueExW( key, @@ -348,7 +346,7 @@ OutputDebugStringW(L""); 0, REG_BINARY, str, - strlen((const char*) str)+1); + strlen(str)+1); NSDebugLLog(@"NSMessagePortNameServer", @"Set port '%s' for %@", str, n); if (rc == ERROR_SUCCESS) { diff --git a/Source/win32/NSMessagePort.m b/Source/win32/NSMessagePortWin32.m similarity index 97% rename from Source/win32/NSMessagePort.m rename to Source/win32/NSMessagePortWin32.m index 87a6927c2..33ace7cfe 100644 --- a/Source/win32/NSMessagePort.m +++ b/Source/win32/NSMessagePortWin32.m @@ -6,7 +6,7 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,13 +15,13 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include "common.h" +#include "config.h" #include "GNUstepBase/preface.h" #include "GNUstepBase/GSLock.h" #include "Foundation/NSArray.h" @@ -45,11 +45,12 @@ #include "Foundation/NSProcessInfo.h" #include "../GSPrivate.h" -#include "../GSPortPrivate.h" +#include "GSPortPrivate.h" #include +#include -extern __declspec(dllimport) int errno; +extern int errno; #define UNISTR(X) \ ((const unichar*)[(X) cStringUsingEncoding: NSUnicodeStringEncoding]) @@ -193,7 +194,7 @@ static Class messagePortClass = 0; security.nLength = sizeof(SECURITY_ATTRIBUTES); security.lpSecurityDescriptor = 0; // Default - security.bInheritHandle = FALSE; + security.bInheritHandle = TRUE; } } @@ -232,7 +233,7 @@ static Class messagePortClass = 0; - (void) dealloc { - [self finalize]; + [self gcFinalize]; [super dealloc]; } @@ -245,7 +246,7 @@ static Class messagePortClass = 0; return desc; } -- (void) finalize +- (void) gcFinalize { internal *this; @@ -386,7 +387,7 @@ static Class messagePortClass = 0; else { found = YES; - DESTROY(self); + RELEASE(self); self = p; } @@ -595,8 +596,8 @@ static Class messagePortClass = 0; GSPortItemHeader *pih; unsigned off = 0; unsigned len; - unsigned rId = 0; - unsigned nItems = 0; + unsigned rId; + unsigned nItems; NSMessagePort *rPort = nil; NSMutableArray *rItems = nil; @@ -871,11 +872,7 @@ again: } else if ((errno = GetLastError()) != ERROR_IO_PENDING) { - /* This is probably an end of file - * eg. when the process at the other end has terminated. - */ - NSDebugMLog(@"NSMessagePort", - @"unable to write to mailslot '%@' - %@", + NSLog(@"unable to write to mailslot '%@' - %@", this->name, [NSError _last]); [self invalidate]; } @@ -974,7 +971,7 @@ again: from: (NSPort*)receivingPort reserved: (unsigned)length { - NSMutableData *h = nil; + NSMutableData *h; NSMutableData *first; BOOL sent = NO; unsigned c; @@ -1131,8 +1128,8 @@ again: } } M_UNLOCK(this->lock); - RELEASE(h); RELEASE(self); + RELEASE(h); return sent; } diff --git a/Source/win32/NSStream.m b/Source/win32/NSStreamWin32.m similarity index 50% rename from Source/win32/NSStream.m rename to Source/win32/NSStreamWin32.m index 0cda123d8..decab0391 100644 --- a/Source/win32/NSStream.m +++ b/Source/win32/NSStreamWin32.m @@ -6,7 +6,7 @@ Date: 2006 This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -15,34 +15,41 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include "common.h" +#include "config.h" #include "GNUstepBase/preface.h" +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#include -#import "Foundation/NSData.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSException.h" -#import "Foundation/NSError.h" -#import "Foundation/NSValue.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSByteOrder.h" -#import "GNUstepBase/NSObject+GNUstepBase.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include -#import "../GSPrivate.h" -#import "../GSStream.h" -#import "../GSSocketStream.h" +#include "../GSStream.h" +#include "../GSPrivate.h" #define BUFFERSIZE (BUFSIZ*64) +typedef int socklen_t; + /** * The concrete subclass of NSInputStream that reads from a file */ @@ -73,7 +80,58 @@ - (NSStreamStatus) _check; - (void) _queue; - (void) _setHandle: (HANDLE)h; -- (void) _setSibling: (GSPipeOutputStream*)s; +- (void) setSibling: (GSPipeOutputStream*)s; +@end + +@class GSSocketOutputStream; + +/** + * The abstract subclass of NSInputStream that reads from a socket + */ +@interface GSSocketInputStream : GSInputStream +{ +@protected + GSSocketOutputStream *_sibling; + BOOL _passive; /* YES means already connected */ + SOCKET _sock; +} + +/** + * get the length of the socket addr + */ +- (socklen_t) sockLen; + +/** + * get the sockaddr + */ +- (struct sockaddr*) peerAddr; + +/** + * setter for sibling + */ +- (void) setSibling: (GSSocketOutputStream*)sibling; + +/** + * setter for passive + */ +- (void) setPassive: (BOOL)passive; + +- (void) setEvent: (WSAEVENT)event; +- (void) setSock: (SOCKET)sock; + +@end + +@interface GSInetInputStream : GSSocketInputStream +{ + @private + struct sockaddr_in _peerAddr; +} + +/** + * the designated initializer + */ +- (id) initToAddr: (NSString*)addr port: (int)port; + @end /** @@ -105,7 +163,94 @@ - (NSStreamStatus) _check; - (void) _queue; - (void) _setHandle: (HANDLE)h; -- (void) _setSibling: (GSPipeInputStream*)s; +- (void) setSibling: (GSPipeInputStream*)s; +@end + +/** + * The concrete subclass of NSOutputStream that writes to a socket + */ +@interface GSSocketOutputStream : GSOutputStream +{ +@protected + GSSocketInputStream *_sibling; + BOOL _passive; /* YES means already connected */ + SOCKET _sock; +} + +/** + * get the length of the socket addr + */ +- (socklen_t) sockLen; + +/** + * get the sockaddr + */ +- (struct sockaddr*) peerAddr; + +/** + * setter for sibling + */ +- (void) setSibling: (GSSocketInputStream*)sibling; + +/** + * setter for passive + */ +- (void) setPassive: (BOOL)passive; + +/** + * setter for event + */ +- (void) setEvent: (WSAEVENT)event; +- (void) setSock: (SOCKET)sock; + +@end + +@interface GSInetOutputStream : GSSocketOutputStream +{ + @private + struct sockaddr_in _peerAddr; +} + +/** + * the designated initializer + */ +- (id) initToAddr: (NSString*)addr port: (int)port; + +@end + +/** + * The concrete subclass of NSServerStream that accept connection from a socket + */ +@interface GSSocketServerStream : GSAbstractServerStream +{ + SOCKET _sock; +} +/** + * Return the class of the inputStream associated with this + * type of serverStream. + */ +- (Class) _inputStreamClass; +/** + * Return the class of the outputStream associated with this + * type of serverStream. + */ +- (Class) _outputStreamClass; +/** + * get the length of the socket addr + */ +- (socklen_t) sockLen; +/** + * get the sockaddr + */ +- (struct sockaddr*) serverAddr; + +@end + +@interface GSInetServerStream : GSSocketServerStream +{ + @private + struct sockaddr_in _serverAddr; +} @end @@ -120,6 +265,14 @@ } @end +static void setNonblocking(SOCKET fd) +{ + unsigned long dummy = 1; + + if (ioctlsocket(fd, FIONBIO, &dummy) == SOCKET_ERROR) + NSLog(@"unable to set non-blocking mode - %@", [NSError _last]); +} + @implementation GSFileInputStream - (void) close @@ -145,18 +298,11 @@ [super dealloc]; } -- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len { return NO; } -- (BOOL) hasBytesAvailable -{ - if ([self _isOpened] && [self streamStatus] != NSStreamStatusAtEnd) - return YES; - return NO; -} - - (id) initWithFileAtPath: (NSString *)path { if ((self = [super init]) != nil) @@ -180,6 +326,7 @@ if (h == INVALID_HANDLE_VALUE) { [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; return; } [self _setLoopID: (void*)h]; @@ -199,7 +346,7 @@ return [super propertyForKey: key]; } -- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len { DWORD readLen; @@ -229,8 +376,9 @@ else if (readLen == 0) { [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; } - return (NSInteger)readLen; + return (int)readLen; } @@ -297,12 +445,12 @@ { [self close]; } - [_sibling _setSibling: nil]; + [_sibling setSibling: nil]; _sibling = nil; [super dealloc]; } -- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len { if (offset < length) { @@ -414,7 +562,7 @@ } } -- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len { NSStreamStatus myStatus; @@ -445,6 +593,7 @@ { if (myStatus == NSStreamStatusError) { + [self _sendEvent: NSStreamEventErrorOccurred]; return -1; // Waiting for read. } if (myStatus == NSStreamStatusOpen) @@ -454,6 +603,7 @@ * so we must be at EOF. */ [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; } return 0; } @@ -484,7 +634,7 @@ handle = h; } -- (void) _setSibling: (GSPipeOutputStream*)s +- (void) setSibling: (GSPipeOutputStream*)s { _sibling = s; } @@ -539,6 +689,347 @@ } @end +@implementation GSSocketInputStream + +- (socklen_t) sockLen +{ + [self subclassResponsibility: _cmd]; + return 0; +} + +- (struct sockaddr*) peerAddr +{ + [self subclassResponsibility: _cmd]; + return NULL; +} + +- (void) setSibling: (GSSocketOutputStream*)sibling +{ + _sibling = sibling; +} + +-(void) setPassive: (BOOL)passive +{ + _passive = passive; +} + +- (void) setEvent: (WSAEVENT)event +{ + _loopID = event; +} + +- (void) setSock: (SOCKET)sock +{ + _sock = sock; +} + +- (id) init +{ + if ((self = [super init]) != nil) + { + _sibling = nil; + _passive = NO; + _loopID = WSA_INVALID_EVENT; + } + return self; +} + +- (void) dealloc +{ + if ([self _isOpened]) + { + [self close]; + } + [_sibling setSibling: nil]; + _sibling = nil; + [super dealloc]; +} + +- (void) open +{ + // could be opened because of sibling + if ([self _isOpened]) + return; + if (_passive || (_sibling && [_sibling _isOpened])) + goto open_ok; + // check sibling status, avoid double connect + if (_sibling && [_sibling streamStatus] == NSStreamStatusOpening) + { + [self _setStatus: NSStreamStatusOpening]; + return; + } + else + { + int connectReturn = connect(_sock, [self peerAddr], [self sockLen]); + + if (connectReturn == SOCKET_ERROR + && WSAGetLastError() != WSAEWOULDBLOCK) + {// make an error + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + return; + } + // waiting on writable, as an indication of opened + if (_runloop) + { + unsigned i = [_modes count]; + + WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS); + while (i-- > 0) + { + [_runloop addStream: self mode: [_modes objectAtIndex: i]]; + } + } + [self _setStatus: NSStreamStatusOpening]; + return; + } + + open_ok: + [super open]; + setNonblocking(_sock); + WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS); +} + +- (void) close +{ + if (_loopID != WSA_INVALID_EVENT) + { + WSACloseEvent(_loopID); + } + if (_sock != INVALID_SOCKET) + { + if (_sibling && [_sibling streamStatus] != NSStreamStatusClosed) + { + /* + * Windows only permits a single event to be associated with a socket + * at any time, but the runloop system only allows an event handle to + * be added to the loop once, and we have two streams for each socket. + * So we use two events, one for each stream, and when one stream is + * closed, we must call WSAEventSelect to ensure that the event handle + * of the sibling is used to signal events from now on. + */ + WSAEventSelect(_sock, [_sibling _loopID], FD_ALL_EVENTS); + shutdown(_sock, SD_RECEIVE); + } + else + { + closesocket(_sock); + } + _sock = INVALID_SOCKET; + } + [super close]; + _loopID = WSA_INVALID_EVENT; +} + +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len +{ + int readLen; + + if (buffer == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"null pointer for buffer"]; + } + if (len == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"zero byte length read requested"]; + } + + _events &= ~NSStreamEventHasBytesAvailable; + + if ([self streamStatus] == NSStreamStatusClosed) + { + return 0; + } + + readLen = recv(_sock, buffer, len, 0); + if (readLen == SOCKET_ERROR) + { + errno = WSAGetLastError(); + if (errno == WSAEINPROGRESS || errno == WSAEWOULDBLOCK) + { + [self _setStatus: NSStreamStatusReading]; + } + else if (errno != WSAEINTR) + { + [self _recordError]; + } + readLen = -1; + } + else if (readLen == 0) + { + [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; + } + else + { + [self _setStatus: NSStreamStatusOpen]; + } + return readLen; +} + +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len +{ + return NO; +} + +- (void) _dispatch +{ + /* + * Windows only permits a single event to be associated with a socket + * at any time, but the runloop system only allows an event handle to + * be added to the loop once, and we have two streams for each socket. + * So we use two events, one for each stream, and the _dispatch method + * must handle things for both streams. + */ + if ([self streamStatus] == NSStreamStatusClosed) + { + /* + * It is possible the stream is closed yet recieving event because + * of not closed sibling + */ + NSAssert([_sibling streamStatus] != NSStreamStatusClosed, + @"Received event for closed stream"); + [_sibling _dispatch]; + } + else + { + WSANETWORKEVENTS events; + int error = 0; + int getReturn = -1; + + if (WSAEnumNetworkEvents(_sock, _loopID, &events) == SOCKET_ERROR) + { + error = WSAGetLastError(); + } +//else NSLog(@"EVENTS 0x%x on %p", events.lNetworkEvents, self); + + if ([self streamStatus] == NSStreamStatusOpening) + { + unsigned i = [_modes count]; + + while (i-- > 0) + { + [_runloop removeStream: self mode: [_modes objectAtIndex: i]]; + } + if (error == 0) + { + unsigned len = sizeof(error); + + getReturn = getsockopt(_sock, SOL_SOCKET, SO_ERROR, + (char*)&error, &len); + } + + if (getReturn >= 0 && error == 0 + && (events.lNetworkEvents & FD_CONNECT)) + { // finish up the opening + _passive = YES; + [self open]; + // notify sibling + if (_sibling) + { + [_sibling open]; + [_sibling _sendEvent: NSStreamEventOpenCompleted]; + } + [self _sendEvent: NSStreamEventOpenCompleted]; + } + } + + if (error != 0) + { + errno = error; + [self _recordError]; + [_sibling _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + [_sibling _sendEvent: NSStreamEventErrorOccurred]; + } + else + { + if (events.lNetworkEvents & FD_WRITE) + { + NSAssert([_sibling _isOpened], NSInternalInconsistencyException); + /* Clear NSStreamStatusWriting if it was set */ + [_sibling _setStatus: NSStreamStatusOpen]; + } + /* On winsock a socket is always writable unless it has had + * failure/closure or a write blocked and we have not been + * signalled again. + */ + while ([_sibling _unhandledData] == NO + && [_sibling hasSpaceAvailable]) + { + [_sibling _sendEvent: NSStreamEventHasSpaceAvailable]; + } + + if (events.lNetworkEvents & FD_READ) + { + [self _setStatus: NSStreamStatusOpen]; + while ([self hasBytesAvailable] + && [self _unhandledData] == NO) + { + [self _sendEvent: NSStreamEventHasBytesAvailable]; + } + } + if (events.lNetworkEvents & FD_CLOSE) + { + if ([_sibling _isOpened]) + { + [_sibling _setStatus: NSStreamStatusAtEnd]; + [_sibling _sendEvent: NSStreamEventEndEncountered]; + } + while ([self hasBytesAvailable] + && [self _unhandledData] == NO) + { + [self _sendEvent: NSStreamEventHasBytesAvailable]; + } + if ([self _isOpened]) + { + [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; + } + } + } + } +} + +- (BOOL) runLoopShouldBlock: (BOOL*)trigger +{ + *trigger = YES; + return YES; +} +@end + +@implementation GSInetInputStream + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + if ((self = [super init]) != nil) + { + _peerAddr.sin_family = AF_INET; + _peerAddr.sin_port = htons(port); + _peerAddr.sin_addr.s_addr = addr_c ? inet_addr(addr_c) : INADDR_NONE; + if (_peerAddr.sin_addr.s_addr == INADDR_NONE) // error + { + DESTROY(self); + } + } + return self; +} + +@end @implementation GSFileOutputStream @@ -589,6 +1080,7 @@ if (h == INVALID_HANDLE_VALUE) { [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; return; } else if (_shouldAppend == NO) @@ -596,8 +1088,7 @@ if (SetEndOfFile(h) == 0) // Truncate to current file pointer (0) { [self _recordError]; - CloseHandle(h); - return; + [self _sendEvent: NSStreamEventErrorOccurred]; } } [self _setLoopID: (void*)h]; @@ -617,7 +1108,7 @@ return [super propertyForKey: key]; } -- (NSInteger) write: (const uint8_t *)buffer maxLength: (NSUInteger)len +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len { DWORD writeLen; @@ -648,7 +1139,7 @@ [self _recordError]; return -1; } - return (NSInteger)writeLen; + return (int)writeLen; } - (void) _dispatch @@ -735,7 +1226,7 @@ { [self close]; } - [_sibling _setSibling: nil]; + [_sibling setSibling: nil]; _sibling = nil; [super dealloc]; } @@ -796,7 +1287,7 @@ } } -- (NSInteger) write: (const uint8_t *)buffer maxLength: (NSUInteger)len +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len { NSStreamStatus myStatus = [self streamStatus]; @@ -878,7 +1369,7 @@ handle = h; } -- (void) _setSibling: (GSPipeInputStream*)s +- (void) setSibling: (GSPipeInputStream*)s { _sibling = s; } @@ -933,17 +1424,365 @@ } @end +@implementation GSSocketOutputStream + +- (socklen_t) sockLen +{ + [self subclassResponsibility: _cmd]; + return 0; +} + +- (struct sockaddr*) peerAddr +{ + [self subclassResponsibility: _cmd]; + return NULL; +} + +- (void) setSibling: (GSSocketInputStream*)sibling +{ + _sibling = sibling; +} + +-(void) setPassive: (BOOL)passive +{ + _passive = passive; +} + +- (void) setEvent: (WSAEVENT)event +{ + _loopID = event; +} + +- (void) setSock: (SOCKET)sock +{ + _sock = sock; +} + +- (id) init +{ + if ((self = [super init]) != nil) + { + _sibling = nil; + _passive = NO; + _loopID = WSA_INVALID_EVENT; + } + return self; +} + +- (void) dealloc +{ + if ([self _isOpened]) + { + [self close]; + } + [_sibling setSibling: nil]; + _sibling = nil; + [super dealloc]; +} + +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len +{ + int writeLen; + + if (buffer == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"null pointer for buffer"]; + } + if (len == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"zero byte length write requested"]; + } + + _events &= ~NSStreamEventHasSpaceAvailable; + + if ([self streamStatus] == NSStreamStatusClosed) + { + return 0; + } + + writeLen = send(_sock, buffer, len, 0); + if (writeLen == SOCKET_ERROR) + { + errno = WSAGetLastError(); + if (errno == WSAEINPROGRESS || errno == WSAEWOULDBLOCK) + { + [self _setStatus: NSStreamStatusWriting]; + } + else if (errno != WSAEINTR) + { + [self _recordError]; + } + writeLen = -1; + } + else + { + [self _setStatus: NSStreamStatusOpen]; + } + return writeLen; +} + +- (void) open +{ + // could be opened because of sibling + if ([self _isOpened]) + return; + if (_passive || (_sibling && [_sibling _isOpened])) + goto open_ok; + // check sibling status, avoid double connect + if (_sibling && [_sibling streamStatus] == NSStreamStatusOpening) + { + [self _setStatus: NSStreamStatusOpening]; + return; + } + else + { + int connectReturn = connect(_sock, [self peerAddr], [self sockLen]); + + if (connectReturn == SOCKET_ERROR + && WSAGetLastError() != WSAEWOULDBLOCK) + {// make an error + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + return; + } + // waiting on writable, as an indication of opened + if (_runloop) + { + unsigned i = [_modes count]; + + WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS); + + while (i-- > 0) + { + [_runloop addStream: self mode: [_modes objectAtIndex: i]]; + } + } + [self _setStatus: NSStreamStatusOpening]; + return; + } + + open_ok: + setNonblocking(_sock); + WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS); + [super open]; +} + +- (void) close +{ + if (_loopID != WSA_INVALID_EVENT) + { + WSACloseEvent(_loopID); + } + + if (_sock != INVALID_SOCKET) + { + int closeReturn; // shutdown may fail (broken pipe). Record it. + + if (_sibling && [_sibling streamStatus] != NSStreamStatusClosed) + { + /* + * Windows only permits a single event to be associated with a socket + * at any time, but the runloop system only allows an event handle to + * be added to the loop once, and we have two streams for each socket. + * So we use two events, one for each stream, and when one stream is + * closed, we must call WSAEventSelect to ensure that the event handle + * of the sibling is used to signal events from now on. + */ + WSAEventSelect(_sock, [_sibling _loopID], FD_ALL_EVENTS); + closeReturn = shutdown(_sock, SD_SEND); + } + else + { + closeReturn = closesocket(_sock); + } + _sock = INVALID_SOCKET; + if (closeReturn < 0) + { + [self _recordError]; + } + } + [super close]; + _loopID = WSA_INVALID_EVENT; +} + +- (void) _dispatch +{ + /* + * Windows only permits a single event to be associated with a socket + * at any time, but the runloop system only allows an event handle to + * be added to the loop once, and we have two streams for each socket. + * So we use two events, one for each stream, and the _dispatch method + * must handle things for both streams. + */ + if ([self streamStatus] == NSStreamStatusClosed) + { + /* + * It is possible the stream is closed yet recieving event because + * of not closed sibling + */ + NSAssert([_sibling streamStatus] != NSStreamStatusClosed, + @"Received event for closed stream"); + [_sibling _dispatch]; + } + else + { + WSANETWORKEVENTS events; + int error = 0; + int getReturn = -1; + + if (WSAEnumNetworkEvents(_sock, _loopID, &events) == SOCKET_ERROR) + { + error = WSAGetLastError(); + } +//else NSLog(@"EVENTS 0x%x on %p", events.lNetworkEvents, self); + + if ([self streamStatus] == NSStreamStatusOpening) + { + unsigned i = [_modes count]; + + while (i-- > 0) + { + [_runloop removeStream: self mode: [_modes objectAtIndex: i]]; + } + + if (error == 0) + { + unsigned len = sizeof(error); + + getReturn = getsockopt(_sock, SOL_SOCKET, SO_ERROR, + (char*)&error, &len); + } + + if (getReturn >= 0 && error == 0 + && (events.lNetworkEvents & FD_CONNECT)) + { // finish up the opening + events.lNetworkEvents ^= FD_CONNECT; + _passive = YES; + [self open]; + // notify sibling + if (_sibling) + { + [_sibling open]; + [_sibling _sendEvent: NSStreamEventOpenCompleted]; + } + [self _sendEvent: NSStreamEventOpenCompleted]; + } + } + + if (error != 0) + { + errno = error; + [self _recordError]; + [_sibling _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + [_sibling _sendEvent: NSStreamEventErrorOccurred]; + } + else + { + if (events.lNetworkEvents & FD_WRITE) + { + /* Clear NSStreamStatusWriting if it was set */ + [self _setStatus: NSStreamStatusOpen]; + } + + /* On winsock a socket is always writable unless it has had + * failure/closure or a write blocked and we have not been + * signalled again. + */ + while ([self _unhandledData] == NO && [self hasSpaceAvailable]) + { + [self _sendEvent: NSStreamEventHasSpaceAvailable]; + } + + if (events.lNetworkEvents & FD_READ) + { + [_sibling _setStatus: NSStreamStatusOpen]; + while ([_sibling hasBytesAvailable] + && [_sibling _unhandledData] == NO) + { + [_sibling _sendEvent: NSStreamEventHasBytesAvailable]; + } + } + if (events.lNetworkEvents & FD_CLOSE) + { + [self _setStatus: NSStreamStatusAtEnd]; + [self _sendEvent: NSStreamEventEndEncountered]; + while ([_sibling hasBytesAvailable] + && [_sibling _unhandledData] == NO) + { + [_sibling _sendEvent: NSStreamEventHasBytesAvailable]; + } + if ([_sibling _isOpened]) + { + [_sibling _setStatus: NSStreamStatusAtEnd]; + [_sibling _sendEvent: NSStreamEventEndEncountered]; + } + } + } + } +} + +- (BOOL) runLoopShouldBlock: (BOOL*)trigger +{ + *trigger = YES; + if ([self _unhandledData] == NO && [self streamStatus] == NSStreamStatusOpen) + { + /* In winsock, a writable status is only signalled if an earlier + * write failed (because it would block), so we must simulate the + * writable event by having the run loop trigger without blocking. + */ + return NO; + } + return YES; +} +@end + +@implementation GSInetOutputStream + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in); +} + +- (struct sockaddr*) peerAddr +{ + return (struct sockaddr*)&_peerAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + if ((self = [super init]) != nil) + { + _peerAddr.sin_family = AF_INET; + _peerAddr.sin_port = htons(port); + _peerAddr.sin_addr.s_addr = addr_c ? inet_addr(addr_c) : INADDR_NONE; + if (_peerAddr.sin_addr.s_addr == INADDR_NONE) // error + { + DESTROY(self); + } + } + return self; +} + +@end + @implementation NSStream + (void) getStreamsToHost: (NSHost *)host - port: (NSInteger)port + port: (int)port inputStream: (NSInputStream **)inputStream outputStream: (NSOutputStream **)outputStream { - NSString *address = host ? (id)[host address] : (id)@"127.0.0.1"; - GSSocketStream *ins = nil; - GSSocketStream *outs = nil; + NSString *address = [host address]; + GSSocketInputStream *ins = nil; + GSSocketOutputStream *outs = nil; int sock; + WSAEVENT ievent; + WSAEVENT oevent; ins = AUTORELEASE([[GSInetInputStream alloc] initToAddr: address port: port]); @@ -961,19 +1800,24 @@ * streams so that whichever stream gets signalled, the correct * actions are taken. */ + ievent = CreateEvent(NULL, NO, NO, NULL); + oevent = CreateEvent(NULL, NO, NO, NULL); + NSAssert(sock != INVALID_SOCKET, @"Cannot open socket"); - [ins _setSock: sock]; - [outs _setSock: sock]; + [ins setSock: sock]; + [outs setSock: sock]; + [ins setEvent: ievent]; + [outs setEvent: oevent]; if (inputStream) { - [ins _setSibling: outs]; - *inputStream = (NSInputStream*)ins; + [ins setSibling: outs]; + *inputStream = ins; } if (outputStream) { - [outs _setSibling: ins]; - *outputStream = (NSOutputStream*)outs; + [outs setSibling: ins]; + *outputStream = outs; } return; } @@ -1016,7 +1860,7 @@ fileSystemRepresentation]; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = FALSE; + saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; handle = CreateFileW(name, @@ -1038,9 +1882,9 @@ outs = AUTORELEASE([GSPipeOutputStream new]); [ins _setHandle: handle]; - [ins _setSibling: outs]; + [ins setSibling: outs]; [outs _setHandle: handle]; - [outs _setSibling: ins]; + [outs setSibling: ins]; done: if (inputStream) @@ -1067,7 +1911,7 @@ done: int rc; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = FALSE; + saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; /* @@ -1203,7 +2047,7 @@ done: return AUTORELEASE([[GSFileInputStream alloc] initWithFileAtPath: path]); } -- (BOOL) getBuffer: (uint8_t **)buffer length: (NSUInteger *)len +- (BOOL) getBuffer: (uint8_t **)buffer length: (unsigned int *)len { [self subclassResponsibility: _cmd]; return NO; @@ -1217,17 +2061,17 @@ done: - (id) initWithData: (NSData *)data { - DESTROY(self); + RELEASE(self); return [[GSDataInputStream alloc] initWithData: data]; } - (id) initWithFileAtPath: (NSString *)path { - DESTROY(self); + RELEASE(self); return [[GSFileInputStream alloc] initWithFileAtPath: path]; } -- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len +- (int) read: (uint8_t *)buffer maxLength: (unsigned int)len { [self subclassResponsibility: _cmd]; return -1; @@ -1242,7 +2086,7 @@ done: return AUTORELEASE([[GSDataOutputStream alloc] init]); } -+ (id) outputStreamToBuffer: (uint8_t *)buffer capacity: (NSUInteger)capacity ++ (id) outputStreamToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity { return AUTORELEASE([[GSBufferOutputStream alloc] initToBuffer: buffer capacity: capacity]); @@ -1260,26 +2104,26 @@ done: return NO; } -- (id) initToBuffer: (uint8_t *)buffer capacity: (NSUInteger)capacity +- (id) initToBuffer: (uint8_t *)buffer capacity: (unsigned int)capacity { - DESTROY(self); + RELEASE(self); return [[GSBufferOutputStream alloc] initToBuffer: buffer capacity: capacity]; } - (id) initToFileAtPath: (NSString *)path append: (BOOL)shouldAppend { - DESTROY(self); + RELEASE(self); return [[GSFileOutputStream alloc] initToFileAtPath: path append: shouldAppend]; } - (id) initToMemory { - DESTROY(self); + RELEASE(self); return [[GSDataOutputStream alloc] init]; } -- (NSInteger) write: (const uint8_t *)buffer maxLength: (NSUInteger)len +- (int) write: (const uint8_t *)buffer maxLength: (unsigned int)len { [self subclassResponsibility: _cmd]; return -1; @@ -1287,6 +2131,253 @@ done: @end +@implementation GSServerStream + ++ (id) serverStreamToAddr: (NSString*)addr port: (int)port +{ + GSServerStream *s; + + s = [[GSInetServerStream alloc] initToAddr: addr port: port]; + return AUTORELEASE(s); +} + ++ (id) serverStreamToAddr: (NSString*)addr +{ + GSServerStream *s; + + s = [[GSLocalServerStream alloc] initToAddr: addr]; + return AUTORELEASE(s); +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + RELEASE(self); + self = [[GSInetServerStream alloc] initToAddr: addr port: port]; + return self; +} + +- (id) initToAddr: (NSString*)addr +{ + RELEASE(self); + self = [[GSLocalServerStream alloc] initToAddr: addr]; + return self; +} + +- (void) acceptWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + [self subclassResponsibility: _cmd]; +} + +@end + +@implementation GSSocketServerStream + +- (Class) _inputStreamClass +{ + [self subclassResponsibility: _cmd]; + return Nil; +} + +- (Class) _outputStreamClass +{ + [self subclassResponsibility: _cmd]; + return Nil; +} + +- (id) init +{ + if ((self = [super init]) != nil) + { + _loopID = WSA_INVALID_EVENT; + } + return self; +} + +- (void) dealloc +{ + if ([self _isOpened]) + { + [self close]; + } + [super dealloc]; +} + +- (socklen_t) sockLen +{ + [self subclassResponsibility: _cmd]; + return 0; +} + +- (struct sockaddr*) serverAddr +{ + [self subclassResponsibility: _cmd]; + return 0; +} + +#define SOCKET_BACKLOG 255 + +- (void) open +{ + int bindReturn; + int listenReturn; +#ifndef BROKEN_SO_REUSEADDR + int status = 1; + + /* + * Under decent systems, SO_REUSEADDR means that the port can be reused + * immediately that this process exits. Under some it means + * that multiple processes can serve the same port simultaneously. + * We don't want that broken behavior! + */ + setsockopt(_sock, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status)); +#endif + bindReturn = bind(_sock, [self serverAddr], [self sockLen]); + listenReturn = listen(_sock, SOCKET_BACKLOG); + if (bindReturn < 0 || listenReturn < 0) + { + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + return; + } + setNonblocking(_sock); + _loopID = CreateEvent(NULL, NO, NO, NULL); + WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS); + [super open]; +} + +- (void) close +{ + if (_loopID != WSA_INVALID_EVENT) + { + WSACloseEvent(_loopID); + } + if (_sock != INVALID_SOCKET) + { + // close a server socket is safe + closesocket(_sock); + _sock = INVALID_SOCKET; + } + [super close]; + _loopID = WSA_INVALID_EVENT; +} + +- (void) acceptWithInputStream: (NSInputStream **)inputStream + outputStream: (NSOutputStream **)outputStream +{ + GSSocketInputStream *ins = AUTORELEASE([[self _inputStreamClass] new]); + GSSocketOutputStream *outs = AUTORELEASE([[self _outputStreamClass] new]); + socklen_t len = [ins sockLen]; + int acceptReturn = accept(_sock, [ins peerAddr], &len); + + _events &= ~NSStreamEventHasBytesAvailable; + if (acceptReturn == INVALID_SOCKET) + { + errno = WSAGetLastError();// test for real error + if (errno != WSAEWOULDBLOCK && errno != WSAECONNRESET && + errno != WSAEINPROGRESS && errno != WSAEINTR) + { + [self _recordError]; + } + ins = nil; + outs = nil; + } + else + { + /* + * Windows only permits a single event to be associated with a socket + * at any time, but the runloop system only allows an event handle to + * be added to the loop once, and we have two streams. + * So we create two events, one for each stream, so that we can have + * both streams scheduled in the run loop, but we make sure that the + * _dispatch method in each stream actually handles things for both + * streams so that whichever stream gets signalled, the correct + * actions are taken. + */ + WSAEVENT ievent = CreateEvent(NULL, NO, NO, NULL); + WSAEVENT oevent = CreateEvent(NULL, NO, NO, NULL); + // no need to connect again + [ins setPassive: YES]; + [outs setPassive: YES]; + // copy the addr to outs + memcpy([outs peerAddr], [ins peerAddr], len); + [ins setSock: acceptReturn]; + [outs setSock: acceptReturn]; + [ins setEvent: ievent]; + [outs setEvent: oevent]; + } + if (inputStream) + { + [ins setSibling: outs]; + *inputStream = ins; + } + if (outputStream) + { + [outs setSibling: ins]; + *outputStream = outs; + } +} + +- (void) _dispatch +{ + WSANETWORKEVENTS events; + + if (WSAEnumNetworkEvents(_sock, _loopID, &events) == SOCKET_ERROR) + { + errno = WSAGetLastError(); + [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; + } + else if (events.lNetworkEvents & FD_ACCEPT) + { + events.lNetworkEvents ^= FD_ACCEPT; + [self _setStatus: NSStreamStatusReading]; + [self _sendEvent: NSStreamEventHasBytesAvailable]; + } +} + +@end + +@implementation GSInetServerStream + +- (Class) _inputStreamClass +{ + return [GSInetInputStream class]; +} + +- (Class) _outputStreamClass +{ + return [GSInetOutputStream class]; +} + +- (socklen_t) sockLen +{ + return sizeof(struct sockaddr_in); +} + +- (struct sockaddr*) serverAddr +{ + return (struct sockaddr*)&_serverAddr; +} + +- (id) initToAddr: (NSString*)addr port: (int)port +{ + const char *addr_c = [addr cStringUsingEncoding: NSUTF8StringEncoding]; + + [super init]; + _serverAddr.sin_family = AF_INET; + _serverAddr.sin_port = htons(port); + _serverAddr.sin_addr.s_addr = addr_c ? inet_addr(addr_c) : INADDR_NONE; + _sock = socket(AF_INET, SOCK_STREAM, 0); + if (_serverAddr.sin_addr.s_addr == INADDR_NONE || _loopID < 0) // error + { + RELEASE(self); + return nil; + } + return self; +} + +@end @implementation GSLocalServerStream @@ -1346,7 +2437,7 @@ done: NSAssert(handle == INVALID_HANDLE_VALUE, NSInternalInconsistencyException); saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = FALSE; + saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; handle = CreateNamedPipeW([path fileSystemRepresentation], @@ -1360,6 +2451,7 @@ done: if (handle == INVALID_HANDLE_VALUE) { [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; return; } @@ -1382,6 +2474,7 @@ done: else if (errno != ERROR_IO_PENDING) { [self _recordError]; + [self _sendEvent: NSStreamEventErrorOccurred]; return; } } @@ -1393,6 +2486,7 @@ done: if (alreadyConnected == YES) { [self _setStatus: NSStreamStatusOpen]; + [self _sendEvent: NSStreamEventHasBytesAvailable]; } } @@ -1435,12 +2529,12 @@ done: if (inputStream) { - [ins _setSibling: outs]; + [ins setSibling: outs]; *inputStream = ins; } if (outputStream) { - [outs _setSibling: ins]; + [outs setSibling: ins]; *outputStream = outs; } } diff --git a/Source/win32/NSUserDefaults.m b/Source/win32/NSUserDefaultsWin32.m similarity index 97% rename from Source/win32/NSUserDefaults.m rename to Source/win32/NSUserDefaultsWin32.m index cb9c1bf60..24688bf30 100644 --- a/Source/win32/NSUserDefaults.m +++ b/Source/win32/NSUserDefaultsWin32.m @@ -1,15 +1,13 @@ -#import "common.h" - -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSException.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSLock.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define UNISTR(X) \ ((const unichar*)[(X) cStringUsingEncoding: NSUnicodeStringEncoding]) @@ -555,7 +553,7 @@ struct NSUserDefaultsWin32_DomainInfo rc = RegCreateKeyExW(HKEY_CURRENT_USER, UNISTR(dPath), 0, - (LPWSTR) L"", + L"", REG_OPTION_NON_VOLATILE, STANDARD_RIGHTS_WRITE|STANDARD_RIGHTS_READ|KEY_SET_VALUE |KEY_QUERY_VALUE, diff --git a/Testing/.cvsignore b/Testing/.cvsignore new file mode 100644 index 000000000..637254b1a --- /dev/null +++ b/Testing/.cvsignore @@ -0,0 +1,12 @@ + + +*.txt *.dat +LoadMe.bundle +nsprocessinfo nsarchiver invocation diningPhilosophers nsmaptable nshashtable +nstimer nsnotification nxst fref heap basic +pipes server client string values nsarray nsbundle nsdictionary nsset +release nsscanner nsdate awake thread-except nscharacterset +shared_debug_obj +shared_obj +tcpport-server tcpport-client coder cstream float prepend randoms +test?? diff --git a/Testing/.gdbinit b/Testing/.gdbinit new file mode 100644 index 000000000..28f8572e1 --- /dev/null +++ b/Testing/.gdbinit @@ -0,0 +1 @@ +directory . .. diff --git a/Testing/English.lproj/NXStringTable.example b/Testing/English.lproj/NXStringTable.example new file mode 100644 index 000000000..469509da1 --- /dev/null +++ b/Testing/English.lproj/NXStringTable.example @@ -0,0 +1,21 @@ +/* This is an example of a string table file. Everything inside a comment +is completely ignored, even if in "quotes", or \escape characters, etc. +*/ + +"title" = "pattern II target 1"; + +/* This is an example of excape codes in the string table, codes */ +/* that are not one of abfnrtv are stripped of the \ character */ +"escapes" = "This is a tab \t and a return \n or a \a but not a \p"; +"escapes2" = "Well how about a \0? Guess not."; + +/* more parameters, white space between tokens is ignored */ +"actualSize" + = + "0.000250 0.000250"; + +/* a key with no value assumes the value is the same as the key */ +"hoe322070.element"; + +/* this will produce an error */ +"unterminated"= "this is a string with no ending quote; diff --git a/Testing/GNUmakefile b/Testing/GNUmakefile new file mode 100644 index 000000000..47b711b23 --- /dev/null +++ b/Testing/GNUmakefile @@ -0,0 +1,163 @@ +# +# checks makefile for the GNUstep Base Library +# +# Copyright (C) 1997 Free Software Foundation, Inc. +# +# Written by: Scott Christley +# +# This file is part of the GNUstep Base Library. +# +# This library 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 2 of the License, or (at your option) any later version. +# +# This library 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 library; if not, write to the Free +# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA. +# + +ifeq ($(GNUSTEP_MAKEFILES),) + GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)$(warning computed GNUSTEP_MAKEFILES) +endif + +ifeq ($(GNUSTEP_MAKEFILES),) + $(error You need to set GNUSTEP_MAKEFILES before compiling!) +endif + +GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make + +include $(GNUSTEP_MAKEFILES)/common.make + +include ../Version +include ../config.mak + +# The tools to be compiled +CHECKABLE_TOOLS = \ + awake \ + basic \ + benchmark \ + call \ + containers \ + exported-strings \ + fref \ + gsbehavior \ + gslock \ + nsarchiver \ + nsarray \ + nsattributedstring \ + nsbundle \ + nscharacterset \ + nsconnection \ + nsdata \ + nsdate \ + nsdictionary \ + nsfilehandle \ + nsfilemanager \ + nshashtable \ + nshost \ + nsindexset \ + nsinvocation \ + nsmaptable \ + nsmethodsignature \ + nsnotification \ + nspathutilities \ + nsprocessinfo \ + nsscanner \ + nsset \ + nstask \ + nstimer \ + nstimezone \ + nsundomanager \ + nsxmlparser \ + release \ + string \ + thread \ + thread-except \ + values \ + +TEST_TOOL_NAME = $(CHECKABLE_TOOLS) + +# Don't make these normally +ADDITIONAL_TOOLS = \ + diningPhilosophers \ + nsconnection_client \ + nsconnection_server \ + +TEST_TOOL_NAME += $(ADDITIONAL_TOOLS) + +# The tool Objective-C source files to be compiled +awake_OBJC_FILES = awake.m +basic_OBJC_FILES = basic.m +benchmark_OBJC_FILES = benchmark.m +call_OBJC_FILES = call.m +containers_OBJC_FILES = containers.m +diningPhilosophers_OBJC_FILES = diningPhilosophers.m +exported-strings_OBJC_FILES = exported-strings.m +fref_OBJC_FILES = fref.m +gsbehavior_OBJC_FILES = gsbehavior.m +gslock_OBJC_FILES = gslock.m +nsarchiver_OBJC_FILES = nsarchiver.m +nsarray_OBJC_FILES = nsarray.m +nsattributedstring_OBJC_FILES = nsattributedstring.m +nsbundle_OBJC_FILES = nsbundle.m +nscharacterset_OBJC_FILES = nscharacterset.m +nsconnection_OBJC_FILES = nsconnection.m +nsconnection_client_OBJC_FILES = nsconnection_client.m +nsconnection_server_OBJC_FILES = nsconnection_server.m +nsdata_OBJC_FILES = nsdata.m +nsdate_OBJC_FILES = nsdate.m +nsdictionary_OBJC_FILES = nsdictionary.m +nsfilehandle_OBJC_FILES = nsfilehandle.m +nsfilemanager_OBJC_FILES = nsfilemanager.m +nshashtable_OBJC_FILES = nshashtable.m +nshost_OBJC_FILES = nshost.m +nsindexset_OBJC_FILES = nsindexset.m +nsinvocation_OBJC_FILES = nsinvocation.m +nskvo_OBJC_FILES = nskvo.m +nsmaptable_OBJC_FILES = nsmaptable.m +nsmethodsignature_OBJC_FILES = nsmethodsignature.m +nsnotification_OBJC_FILES = nsnotification.m +nspathutilities_OBJC_FILES = nspathutilities.m +nsprocessinfo_OBJC_FILES = nsprocessinfo.m +nsscanner_OBJC_FILES = nsscanner.m +nsset_OBJC_FILES = nsset.m +nstask_OBJC_FILES = nstask.m +nstimer_OBJC_FILES = nstimer.m +nstimezone_OBJC_FILES = nstimezone.m +nsxmlparser_OBJC_FILES = nsxmlparser.m +nsundomanager_OBJC_FILES = nsundomanager.m +prepend_OBJC_FILES = prepend.m +release_OBJC_FILES = release.m +string_OBJC_FILES = string.m +testtool_OBJC_FILES = testtool.m +thread_OBJC_FILES = thread.m +thread-except_OBJC_FILES = thread-except.m +values_OBJC_FILES = values.m + +# The bundles to be compiled +BUNDLE_NAME=LoadMe + +# The bundle Objective-C source files to be compiled +LoadMe_OBJC_FILES = LoadMe.m MyCategory.m SecondClass.m + +# The bundle resource files and directories +LoadMe_RESOURCE_FILES = English.lproj/NXStringTable.example +LoadMe_RESOURCE_DIRS = English.lproj + +# Manually disable installation of LoadMe bundle +LoadMe_STANDARD_INSTALL = no + +-include Makefile.preamble + +-include GNUmakefile.local + +include $(GNUSTEP_MAKEFILES)/test-tool.make +include $(GNUSTEP_MAKEFILES)/bundle.make + +-include Makefile.postamble diff --git a/Testing/LoadMe.h b/Testing/LoadMe.h new file mode 100644 index 000000000..27706c135 --- /dev/null +++ b/Testing/LoadMe.h @@ -0,0 +1,24 @@ +/* Test Class for NSBundle. + Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#include + +@interface LoadMe : NSObject +{ + int var; +} + +- init; +- afterLoad; + +@end diff --git a/Testing/LoadMe.m b/Testing/LoadMe.m new file mode 100644 index 000000000..89e0ae1b7 --- /dev/null +++ b/Testing/LoadMe.m @@ -0,0 +1,33 @@ +/* Test Class for NSBundle. + Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#include +#include +#include "LoadMe.h" + +@implementation LoadMe + +- init +{ + [super init]; + var = 10; + return self; +} + +- afterLoad +{ + printf("%s's instance variable is %i\n", [[self description] cString], var); + return self; +} + +@end diff --git a/Testing/Makefile.postamble b/Testing/Makefile.postamble new file mode 100644 index 000000000..ee357a8e7 --- /dev/null +++ b/Testing/Makefile.postamble @@ -0,0 +1,79 @@ +# +# Makefile.postamble +# +# Copyright (C) 1997 Free Software Foundation, Inc. +# +# Author: Scott Christley +# +# This file is part of the GNUstep Base Library. +# +# This library 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 2 of the License, or (at your option) any later version. +# +# This library 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. +# +# If you are interested in a warranty or support for this source code, +# contact Scott Christley at scottc@net-community.com +# +# You should have received a copy of the GNU General Public +# License along with this library; see the file COPYING.LIB. +# If not, write to the Free Software Foundation, +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# +# Makefile.postamble +# +# Project specific makefile rules +# +# Uncomment the targets you want. +# The double colons (::) are important, do not make them single colons +# otherwise the normal makefile rules will not be performed. +# + +# Things to do before compiling +# before-all:: + +# Things to do after compiling +# after-all:: + +# Things to do before installing +# before-install:: + +# Things to do after installing +# after-install:: + +# Things to do before uninstalling +# before-uninstall:: + +# Things to do after uninstalling +# after-uninstall:: + +# Things to do before cleaning +# before-clean:: + +# Things to do after cleaning +# after-clean:: + +# Things to do before distcleaning +# before-distclean:: + +# Things to do after distcleaning +after-distclean:: + rm -f cstream.dat fref.dat nsarchiver.dat + +check:: $(CHECKABLE_TOOLS) + for f in $(CHECKABLE_TOOLS); do \ + obj/$$f ; \ + done + +# Things to do before checking +# before-check:: + +# Things to do after checking +# after-check:: + diff --git a/Testing/Makefile.preamble b/Testing/Makefile.preamble new file mode 100644 index 000000000..30c9ad31a --- /dev/null +++ b/Testing/Makefile.preamble @@ -0,0 +1,74 @@ +# +# checks makefile for the GNUstep Base Library +# +# Copyright (C) 1997 Free Software Foundation, Inc. +# +# Written by: Scott Christley +# +# This file is part of the GNUstep Base Library. +# +# This library 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 2 of the License, or (at your option) any later version. +# +# This library 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 library; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +# + +# +# Makefile.preamble +# +# Project specific makefile variables, and additional +# +# Do not put any Makefile rules in this file, instead they should +# be put into Makefile.postamble. +# + +# +# Flags dealing with compiling and linking +# + +# Additional flags to pass to the preprocessor +ADDITIONAL_CPPFLAGS = + +# Additional flags to pass to the Objective-C compiler +ADDITIONAL_OBJCFLAGS = -g + +# Additional flags to pass to the C compiler +ADDITIONAL_CFLAGS = + +# Additional include directories the compiler should search +ADDITIONAL_INCLUDE_DIRS = -I../Headers/Additions \ + -I../Source/$(GNUSTEP_TARGET_DIR) + +ifeq ($(FOUNDATION_LIB),gnu) + ADDITIONAL_INCLUDE_DIRS += -I../Headers +endif + + +# Additional LDFLAGS to pass to the linker +ADDITIONAL_LDFLAGS = + +# Additional library directories the linker should search +ADDITIONAL_LIB_DIRS = -L../Source/$(GNUSTEP_OBJ_DIR) + +ifeq ($(GNUSTEP_TARGET_OS),mingw32) +BUNDLE_LIBS += -lgnustep-base -lobjc +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +BUNDLE_LIBS += -lgnustep-base -lobjc +endif + +# +# Flags dealing with installing and uninstalling +# + +# Additional directories to be created during installation +ADDITIONAL_INSTALL_DIRS = diff --git a/Testing/MyCategory.h b/Testing/MyCategory.h new file mode 100644 index 000000000..f3439d466 --- /dev/null +++ b/Testing/MyCategory.h @@ -0,0 +1,20 @@ +/* Test Category for NSBundle. + Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#include + +@interface NSObject(MyCategory) + +- printMyName; + +@end diff --git a/Testing/MyCategory.m b/Testing/MyCategory.m new file mode 100644 index 000000000..97ad99d37 --- /dev/null +++ b/Testing/MyCategory.m @@ -0,0 +1,25 @@ +/* Test Category for NSBundle. + Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#include "MyCategory.h" +#include + +@implementation NSObject(MyCategory) + +- printMyName +{ + printf("Class %s had MyCategory added to it\n", [[self description] cString]); + return self; +} + +@end diff --git a/Testing/NSData-test.m b/Testing/NSData-test.m new file mode 100644 index 000000000..5714cda74 --- /dev/null +++ b/Testing/NSData-test.m @@ -0,0 +1,404 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/****************************************************************************** +* Module : NSMutableData(NSData) --- Black Box test module for the +* *Data classes to make sure that methods that raise exceptions +* do so, and that the exceptions are raised properly. +* +* Author : John W. M. Stevens + +............................................................................... +15 April 1997 + +******************************************************************************/ + +#include +#include +#include +#include +#include +#include + +/* Data for stuffing into *Data objects. I like printable data, as it +* gives a quick visual check mechanism, but it has the disadvantage +* of not checking for 8 bit cleanliness. +*/ +char *testString = "Test string for mutable data and archiver classes."; +char *subString = "Sub String"; + +/*----------------------------------------------------------------------------- +| Routine : TestNSMutableData() --- Create an instance of an NSMutableData +| class, initialize it with a C string (to have something +| printable for tests) and invoke the two methods that +| should raise NSRangeException exceptions using ranges that +| cross both edges of the buffer boundary. +| +| Notes : Please see work logs for discussion. +-----------------------------------------------------------------------------*/ + +void +TestNSMutableData(void) +{ + auto NSMutableData *nsMutData; + auto char *str; + auto NSRange range; + + /* Allocate and initialize an instance of an NSMutableData + * class. + */ + nsMutData = [NSMutableData dataWithLength: strlen( testString ) + 1]; + str = (char *) [nsMutData mutableBytes]; + strcpy(str, testString); + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsMutData mutableBytes]; + printf("NSMutableData Test ---------------------------------------------" + "---------------\n" + "1) String: (%s)\n", str); + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + range = NSMakeRange(-2, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(41, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length that is less than zero? */ +NS_DURING + range = NSMakeRange(6, -3.0); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + range = NSMakeRange(-2, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(41, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length less than zero? */ +NS_DURING + range = NSMakeRange(6.0, -3.0); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsMutData mutableBytes]; + printf("2) String: (%s)\n", str); + + /* Attempt to force an out of memory exception. */ +#if 0 + for ( ; ; ) + { + /* Append. */ + [nsMutData appendBytes: testString + length : strlen( testString ) + 1]; + + /* Show current value. */ + printf("%9u\r", [nsMutData length]); + } +#endif +} + +/*----------------------------------------------------------------------------- +| Routine : TestNSData() --- Create an instance of an NSData +| class, initialize it with a C string (to have something +| printable for tests) and invoke the two methods that +| should raise NSRangeException exceptions using ranges that +| cross both edges of the buffer boundary. +| +| Notes : Please see work logs for discussion. +-----------------------------------------------------------------------------*/ + +void +TestNSData(void) +{ + auto NSData *nsData; + auto NSData *newNsData; + auto char *str; + auto char bfr[128]; + auto NSRange range; + + /* Allocate and initialize an instance of an NSData + * class. + */ + nsData = [NSData dataWithBytes: testString + length : (unsigned int) strlen( testString ) + 1]; + + /* Get contents, display. */ + str = (char *) [nsData bytes]; + printf("NSData Test ----------------------------------------------------" + "---------------\n" + "1) String: (%s)\n", str); + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(-2.0, 6.0); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[6] = '\0'; + printf(" A) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get piece. */ + range = NSMakeRange(41, strlen( subString )); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" B) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" C) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about less than zero length? */ +NS_DURING + range = NSMakeRange(5.0, -4.0); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" C) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + +/*=================== subDataWithRange ======================================*/ + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(-2.0, 6.0); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[6] = '\0'; + printf(" D) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(41, strlen( subString )); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" E) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(42, strlen( subString )); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" F) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length less than zero? */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(9.0, -6.0); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" F) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsData bytes]; + printf("2) String: (%s)\n", str); +} + +int +main(int argc, + char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + /* Test NSMutableData. */ + TestNSMutableData(); + + /* Test NSData. */ + TestNSData(); + [arp release]; + return 0; +} diff --git a/Testing/README b/Testing/README new file mode 100644 index 000000000..622458e14 --- /dev/null +++ b/Testing/README @@ -0,0 +1,10 @@ + +These tests are mostly just samples of code that developers put together +to do quick checks to make sure things are working. This is not a +comprehensive test suite. Some tests don't say if they have passed or +not. Some tests do not even output anything. Some tests never quit! + +If you want to run a comprehensive testsuite, run the gnustep testsuite +http://svn.gna.org/viewcvs/gnustep/tests/testsuite +(also ftp://ftp.gnustep.org/pub/gnustep/test). + diff --git a/Testing/SecondClass.h b/Testing/SecondClass.h new file mode 100644 index 000000000..347cabd88 --- /dev/null +++ b/Testing/SecondClass.h @@ -0,0 +1,25 @@ +/* Test Class for NSBundle. + Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#include + +@interface SecondClass : NSObject +{ + int h; + char *dummy; +} + +- init; +- printName; + +@end diff --git a/Testing/SecondClass.m b/Testing/SecondClass.m new file mode 100644 index 000000000..6f0555516 --- /dev/null +++ b/Testing/SecondClass.m @@ -0,0 +1,33 @@ +/* Test Class for NSBundle. + Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#include "SecondClass.h" +#include + +@implementation SecondClass + +- init +{ + [super init]; + h = 25; + return self; +} + +- printName + +{ + printf("Hi my name is %s\n", [[self description] cString]); + return self; +} + +@end diff --git a/Testing/awake.m b/Testing/awake.m new file mode 100644 index 000000000..9d4f41cc8 --- /dev/null +++ b/Testing/awake.m @@ -0,0 +1,313 @@ +/* Test use of -awakeAfterUsingCoder: + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. + + This is a rather complicated, strenuous test, borrowing elements + from the fref.m test. + */ + + +/* Beginning of some parameters to vary. */ +/* 0 and 0 works. + 1 and 0 works for the first test, but has no way of getting the + super_foo in second test right, because we haven't resolved the + forward reference when -awakeAfterUsingCoder is called; this is + an inherent problem of decoding. + 0 and 1 crashes, as does NeXT's (for reasons related to forward + references, having nothing to do with awakeAfterUsingCoder). */ + +/* Use GNU Archiving features, if they are available. */ +#define TRY_GNU_ARCHIVING 0 + +/* In the forward self-reference test, -initWithCoder substitutes + another object for self. */ +#define SELF_REF_INITWITHCODER_SUBSTITUTES 0 + +/* End of some parameters to vary. */ + +#ifdef NX_CURRENT_COMPILER_RELEASE +#include +#include +#include +#else +#include +#include +#include +#endif +#include + +#define GNU_ARCHIVING \ +(TRY_GNU_ARCHIVING && defined(GNUSTEP_BASE_MAJOR_VERSION)) + +#if GNU_ARCHIVING +#include +#endif /* GNU_ARCHIVING */ + + +/* The -initWithCoder methods substitutes another object for self. */ +int initWithCoder_substitutes; +int Foo_awakeAfterUsingCoder_substitutes = 0; +int SubFoo_awakeAfterUsingCoder_substitutes = 1; + +/* This object encodes an -encodeConditionalObject: reference to a Foo. */ +@interface SubFoo : NSObject +{ + id super_foo; + int label; +} +@end + +/* This object encodes an -encodeObject: reference to a SubFoo */ +/* Object may offer a replacement of itself using -awakeAfterUsingCoder: */ +@interface Foo : NSObject +{ + id sub_foo; + int label; +} +- (int) label; +- (void) setLabel: (int)l; +@end + + +/* Object may offer a replacement of itself using -awakeAfterUsingCoder: */ +@implementation SubFoo + +- initWithSuperFoo: o label: (int)l +{ + [super init]; + super_foo = o; + label = l; + return self; +} + +- awakeAfterUsingCoder: coder +{ + if (SubFoo_awakeAfterUsingCoder_substitutes) + { + SubFoo *replacement = [[[self class] alloc] + initWithSuperFoo: super_foo + label: label + 100]; + /* NOTE: We can't use the ivar SUPER_FOO here because it won't have + been resolved by the Decoder yet. */ + [self release]; + return replacement; + } + return self; +} + +- superFoo +{ + return super_foo; +} + +- (void) encodeWithCoder: coder +{ + printf ("In [SubFoo encodeWithCoder:]\n"); +#if GNU_ARCHIVING + [coder encodeObjectReference: super_foo + withName: @"super foo"]; +#else + [coder encodeConditionalObject: super_foo]; +#endif + [coder encodeValueOfObjCType: @encode(int) + at: &label]; +} + +- initWithCoder: coder +{ + if (initWithCoder_substitutes) + { + id o = self; + self = [[[self class] alloc] init]; + [o release]; + } +#if GNU_ARCHIVING + [coder decodeObjectAt: &super_foo + withName: NULL]; +#else + super_foo = [coder decodeObject]; +#endif + [coder decodeValueOfObjCType: @encode(int) + at: &label]; + return self; +} + +- (void) print +{ + printf ("SubFoo label = %d, super label = %d\n", + label, [super_foo label]); +} + +@end + + +@implementation Foo + +- init +{ + [super init]; + sub_foo = nil; + label = 0; + return self; +} + +- awakeAfterUsingCoder: coder +{ + if (Foo_awakeAfterUsingCoder_substitutes) + { + Foo *replacement = [[[self class] alloc] init]; + [replacement setLabel: label + 100]; + /* NOTE: We can't use the ivar SUPER_FOO here because it won't have + been resolved by the Decoder yet. */ + [self release]; + return replacement; + } + return self; +} + +- (void) setSubFoo: o +{ + sub_foo = o; +} + +- subFoo +{ + return sub_foo; +} + +- (void) encodeWithCoder: coder +{ + printf ("In [Foo encodeWithCoder:]\n"); + [coder encodeObject: sub_foo]; + [coder encodeValueOfObjCType: @encode(int) + at: &label]; +} + +- initWithCoder: coder +{ + if (initWithCoder_substitutes) + { + id o = self; + self = [[[self class] alloc] init]; + [o release]; + } + sub_foo = [coder decodeObject]; + [coder decodeValueOfObjCType: @encode(int) + at: &label]; + return self; +} + +- (int) label +{ + return label; +} + +- (void) setLabel: (int)l +{ + label = l; +} + +- (void) print +{ + printf (" Foo label = %d, sub label = %d\n", + label, [sub_foo label]); +} + +@end + +/* Test the use of -encodeConditional to encode a forward reference + to an object. */ +void +test_fref () +{ + id array; + id foo, sub_foo; + printf ("\nTest awakeAfterUsingCoder substitution of objects that will\n" + " satisfy backward references\n"); + initWithCoder_substitutes = 0; + + array = [[NSMutableArray alloc] init]; + foo = [[Foo alloc] init]; + [foo setLabel: 4]; + sub_foo = [[SubFoo alloc] initWithSuperFoo: nil label: 3]; + [array addObject: foo]; + [array addObject: sub_foo]; + +#if GNU_ARCHIVING + [Archiver archiveRootObject: array toFile: @"fref.dat"]; +#else + [NSArchiver archiveRootObject: array toFile: @"fref.dat"]; +#endif + printf ("Encoded: "); + [sub_foo print]; + [foo release]; + [sub_foo release]; + [array release]; + + array = [NSUnarchiver unarchiveObjectWithFile: @"fref.dat"]; + foo = [array objectAtIndex: 0]; + sub_foo = [array objectAtIndex: 1]; + printf ("Decoded: "); + [sub_foo print]; +} + +/* Test awakeAfterUsingCoder of a self-referential forward reference. */ +void +test_self_fref () +{ + id foo, sub_foo; + printf ("\nTest awakeAfterUsingCoder substitution of objects that\n" + " will satisfy self-referential forward references\n"); + initWithCoder_substitutes = SELF_REF_INITWITHCODER_SUBSTITUTES; + + foo = [[Foo alloc] init]; + [foo setLabel: 4]; + sub_foo = [[SubFoo alloc] initWithSuperFoo: foo label: 3]; + [foo setSubFoo: sub_foo]; + +#if GNU_ARCHIVING + [Archiver archiveRootObject: foo toFile: @"fref.dat"]; +#else + [NSArchiver archiveRootObject: foo toFile: @"fref.dat"]; +#endif + printf ("Encoded: "); + [sub_foo print]; + [foo release]; + [sub_foo release]; + + foo = [NSUnarchiver unarchiveObjectWithFile: @"fref.dat"]; + sub_foo = [foo subFoo]; + printf ("Decoded: "); + [sub_foo print]; +} + +int +main () +{ + id arp; + + arp = [NSAutoreleasePool new]; + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + GSDebugAllocationActive(YES); + +#if TEXTCSTREAM + [Archiver setDefaultCStreamClass: [TextCStream class]]; +#endif + + [arp release]; + arp = [NSAutoreleasePool new]; + printf ("Decoded SubFoo label's should be 100 more than Encoded.\n"); + test_fref (); + [arp release]; + arp = [NSAutoreleasePool new]; + test_self_fref (); + [arp release]; + printf("Object allocation info -\n%s\n", GSDebugAllocationList(0)); + exit (0); +} diff --git a/Testing/basic.m b/Testing/basic.m new file mode 100644 index 000000000..f7b34ed77 --- /dev/null +++ b/Testing/basic.m @@ -0,0 +1,8 @@ +#include +int main () +{ + static unsigned char bytes[9] = {'\355', '\264', '\200', '\346', '\224', '\200', '\347', '\214', '\200'}; + NSString *s = [[NSString alloc] initWithBytes: bytes length: 9 encoding: NSUTF8StringEncoding]; + NSLog(@"s %@", s); + return 0; +} diff --git a/Testing/benchmark.m b/Testing/benchmark.m new file mode 100755 index 000000000..052ee69ed --- /dev/null +++ b/Testing/benchmark.m @@ -0,0 +1,767 @@ +/* Simple benchmark program. + Copyright (C) 1998 Free Software Foundation, Inc. + + Written by: Adam Fedor + Modified: Richard Frith-Macdonald + Modified: Nicola Pero + + This file is part of the GNUstep Base Library. + + This library 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 2 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + +*/ + +#include +#include +#include + +#define MAX_COUNT 100000 + +#define START_TIMER sTime = [NSDate date] +#define END_TIMER eTime = [NSDate date] +#define PRINT_TIMER(str) printf(" %-20s\t %6.3f \t %6.3f\n", str, \ + [eTime timeIntervalSinceDate: sTime], \ + [eTime timeIntervalSinceDate: sTime]/baseline) +#define PRINT_TIMER_NO_BASELINE(str) \ + printf(" %-20s\t %6.3f \t %6.3f\n", str, \ + [eTime timeIntervalSinceDate: sTime] - baseline, \ + [eTime timeIntervalSinceDate: sTime]/baseline - 1) + +#define AUTO_START id pool = [NSAutoreleasePool new] +#define AUTO_END [pool release] + +NSDate *sTime = nil; +NSDate *eTime = nil; +/* Set to a baseline to null out speed of runtime */ +NSTimeInterval baseline = 0.0; + +NSZone *myZone; +Class rootClass; +Class stringClass; +IMP cstring; + +@interface MyObject : NSObject +@end + +@implementation MyObject +@end + +@implementation MyObject (Category) +- (id) self +{ + return [super self]; +} +@end + +void +bench_object() +{ + int i; + id obj; + objc_mutex_t mutex; + AUTO_START; + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [rootClass class]; + } + END_TIMER; + baseline = [eTime timeIntervalSinceDate: sTime]; + PRINT_TIMER("Baseline: 10 method calls\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + /* Ten class methods with the more common class names */ + id i; + i = [NSObject class]; + i = [NSString class]; + i = [NSDictionary class]; + i = [NSArray class]; + i = [NSData class]; + i = [NSUserDefaults class]; + i = [NSMutableArray class]; + i = [NSFileManager class]; + i = [NSMutableString class]; + i = [NSMutableDictionary class]; + } + END_TIMER; + PRINT_TIMER("Class: 10 class method calls\t\t"); + + obj = [MyObject new]; + + START_TIMER; + for (i = 0; i < MAX_COUNT * 10; i++) + { + id i; + i = [obj self]; + } + END_TIMER; + PRINT_TIMER_NO_BASELINE("Category: 10 super calls\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + /* Corresponding look ups */ + id i; + i = NSClassFromString (@"NSObject"); + i = NSClassFromString (@"NSString"); + i = NSClassFromString (@"NSDictionary"); + i = NSClassFromString (@"NSArray"); + i = NSClassFromString (@"NSData"); + i = NSClassFromString (@"NSUserDefaults"); + i = NSClassFromString (@"NSMutableArray"); + i = NSClassFromString (@"NSFileManager"); + i = NSClassFromString (@"NSMutableString"); + i = NSClassFromString (@"NSMutableDictionary"); + } + END_TIMER; + PRINT_TIMER("Function: 10 NSClassFromStr\t\t"); + + START_TIMER; + myZone = NSCreateZone(2048, 2048, 1); + for (i = 0; i < MAX_COUNT; i++) + { + void *mem = NSZoneMalloc(myZone, 32); + NSZoneFree(myZone, mem); + } + NSRecycleZone(myZone); + END_TIMER; + PRINT_TIMER("Function: 1 zone alloc/free\t\t"); + + START_TIMER; + myZone = NSCreateZone(2048, 2048, 0); + for (i = 0; i < MAX_COUNT; i++) + { + void *mem = NSZoneMalloc(myZone, 32); + NSZoneFree(myZone, mem); + } + NSRecycleZone(myZone); + END_TIMER; + PRINT_TIMER("Function: 1 zone2alloc/free\t\t"); + + myZone = NSDefaultMallocZone(); + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + void *mem = NSZoneMalloc(myZone, 32); + NSZoneFree(myZone, mem); + } + END_TIMER; + PRINT_TIMER("Function: 1 def alloc/free\t\t"); + + START_TIMER; + myZone = NSCreateZone(2048, 2048, 1); + for (i = 0; i < MAX_COUNT; i++) + { + obj = [[rootClass allocWithZone: myZone] init]; + [obj release]; + } + NSRecycleZone(myZone); + END_TIMER; + PRINT_TIMER("NSObject: 1 zone all/init/rel\t\t"); + + START_TIMER; + myZone = NSCreateZone(2048, 2048, 0); + for (i = 0; i < MAX_COUNT; i++) + { + obj = [[rootClass allocWithZone: myZone] init]; + [obj release]; + } + NSRecycleZone(myZone); + END_TIMER; + PRINT_TIMER("NSObject: 1 zone2all/init/rel\t\t"); + + myZone = NSDefaultMallocZone(); + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + obj = [[rootClass allocWithZone: myZone] init]; + [obj release]; + } + END_TIMER; + PRINT_TIMER("NSObject: 1 def all/init/rel\t\t"); + + obj = [rootClass new]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [obj retain]; + [obj release]; + } + END_TIMER; + PRINT_TIMER("NSObject: 10 retain/rel\t\t"); + [obj release]; + + obj = [rootClass new]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [obj autorelease]; + [obj retain]; + } + END_TIMER; + PRINT_TIMER("NSObject: 10 autorel/ret\t\t"); + [obj release]; + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [rootClass instancesRespondToSelector: @selector(hash)]; + } + END_TIMER; + PRINT_TIMER("ObjC: 10 inst responds to sel\t\t"); + + mutex = objc_mutex_allocate(); + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + objc_mutex_lock(mutex); + objc_mutex_unlock(mutex); + } + END_TIMER; + PRINT_TIMER("ObjC: 10 objc_mutex_lock/unl\t\t"); + objc_mutex_deallocate(mutex); + + obj = [NSLock new]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [obj lock]; + [obj unlock]; + } + END_TIMER; + PRINT_TIMER("NSLock: 10 lock/unlock\t\t"); + [obj release]; + + + AUTO_END; +} + +void +bench_array() +{ + int i; + id array; + NSString *strings[MAX_COUNT]; + + AUTO_START; + for (i = 0; i < MAX_COUNT; i++) + { + char buf1[100]; + sprintf(buf1, "str%0d", i); + strings[i] = [stringClass stringWithUTF8String: buf1]; + } + printf("NSArray\n"); + array = [NSMutableArray arrayWithCapacity: 16]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [array addObject: strings[i/10]]; + } + END_TIMER; + PRINT_TIMER("NSArray (10 addObject:)\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT/100; i++) + { + [array indexOfObject: strings[i]]; + } + END_TIMER; + PRINT_TIMER("NSArray (1/100 indexOfObj)\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT/100; i++) + { + [array indexOfObjectIdenticalTo: strings[i]]; + } + END_TIMER; + PRINT_TIMER("NSArray (1/100 indexIdent)\t\t"); + + START_TIMER; + for (i = 0; i < 1; i++) + { + [array makeObjectsPerformSelector: @selector(hash)]; + } + END_TIMER; + PRINT_TIMER("NSArray (once perform)\t\t"); + AUTO_END; +} + +void +bench_dict() +{ + int i; + NSMutableDictionary *dict; + id obj2; + NSString *keys[MAX_COUNT/10]; + NSString *vals[MAX_COUNT/10]; + + AUTO_START; + for (i = 0; i < MAX_COUNT/10; i++) + { + char buf1[100], buf2[100]; + sprintf(buf1, "key%0d", i); + sprintf(buf2, "val%0d", i); + keys[i] = [stringClass stringWithUTF8String: buf1]; + vals[i] = [stringClass stringWithUTF8String: buf2]; + } + printf("NSDictionary\n"); + dict = [NSMutableDictionary dictionaryWithCapacity: 16]; + START_TIMER; + for (i = 0; i < MAX_COUNT/10; i++) + { + int j; + + for (j = 0; j < 10; j++) + { + [dict setObject: vals[i] forKey: keys[i]]; + } + } + END_TIMER; + PRINT_TIMER("NSDict (1 setObject:) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + int j; + + for (j = 0; j < 10; j++) + { + [dict objectForKey: keys[i/10]]; + } + } + END_TIMER; + PRINT_TIMER("NSDict (10 objectFor:) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [dict count]; + } + END_TIMER; + PRINT_TIMER("NSDictionary (10 count)\t\t"); + + obj2 = [dict copy]; + START_TIMER; + for (i = 0; i < 10; i++) + { + [dict isEqual: obj2]; + } + END_TIMER; + PRINT_TIMER("NSDict (ten times isEqual:)\t\t"); + AUTO_END; +} + +void +bench_number() +{ + int i; + int j; + NSMutableDictionary *dict; + NSNumber *n[MAX_COUNT*10]; + + AUTO_START; + + printf("NSNumber\n"); + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + n[i] = [NSNumber numberWithInt: i]; + } + END_TIMER; + PRINT_TIMER("NSNumber (creation) \t\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + [n[i] hash]; + } + END_TIMER; + PRINT_TIMER("NSNumber (hash) \t\t\t"); + + dict = [NSMutableDictionary dictionaryWithCapacity: MAX_COUNT]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [dict setObject: n[i] forKey: n[i]]; + } + END_TIMER; + PRINT_TIMER("NSNumber (dictionary setObject:)\t"); + + START_TIMER; + for (i = 1; i < MAX_COUNT; i++) + { + [n[i] isEqual: n[i-1]]; + } + END_TIMER; + PRINT_TIMER("NSNumber (isEqual:)\t\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + [n[i] copyWithZone: NSDefaultMallocZone()]; + } + END_TIMER; + PRINT_TIMER("NSNumber (copy)\t\t\t"); + + AUTO_END; +} + +void +bench_str() +{ + int i; + NSString *str; + NSMutableString *ms; + id plist; + NSString *plstr; + Class arc = [NSArchiver class]; + Class una = [NSUnarchiver class]; + Class ser = [NSSerializer class]; + Class des = [NSDeserializer class]; + Class md = [NSMutableDictionary class]; + AUTO_START; + + [[md new] release]; + + plist = [NSDictionary dictionaryWithObjectsAndKeys: + @"Value1", @"Key1", + @"", @"Key2", + [NSArray array], @"Key3", + [NSArray arrayWithObjects: + @"Array1 entry1", + @"Array1 entry2", + [NSArray arrayWithObjects: + @"Array2 entry1", + @"Array2 entry2", + nil], + [NSDictionary dictionary], + [NSDictionary dictionaryWithObjectsAndKeys: + @"Value", @"Key", + nil], + nil], @"Key4", + [NSDictionary dictionary], @"Key5", + [NSDictionary dictionaryWithObjectsAndKeys: + @"Value", @"Key", + nil], @"Key6", + [NSData data], @"Key7", + [NSData dataWithBytes: "hello" length: 5], @"Key8", + nil]; + plstr = [plist description]; + + printf("NSString\n"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + str = [[stringClass alloc] initWithFormat: @"Hello %d", i]; + RELEASE(str); + } + END_TIMER; + PRINT_TIMER("NSString (1 initWithFormat:) \t\t"); + + ms = [NSMutableString stringWithCapacity: 0]; + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + [ms appendFormat: @"%d", i]; + } + END_TIMER; + PRINT_TIMER("NSString (1 appendFormat:) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + str = [stringClass stringWithUTF8String: "hello world"]; + } + END_TIMER; + PRINT_TIMER("NSString (1 cstring:) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str length]; + } + END_TIMER; + PRINT_TIMER("NSString (10 length) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str copy]; + } + END_TIMER; + PRINT_TIMER("NSString (10 copy) "); + + str = @"ConstantString"; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str copy]; + } + END_TIMER; + PRINT_TIMER("NSString (10 copy) <@'ConstantString'> "); + + str = [[NSString alloc] initWithCStringNoCopy: (char *)[str cString] + length: [str length] + freeWhenDone: NO]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str copy]; + } + END_TIMER; + PRINT_TIMER("NSString (10 copy) "); + + str = [[NSString alloc] initWithCStringNoCopy: (char *)[str cString] + length: [str length] + freeWhenDone: YES]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str copy]; + } + END_TIMER; + PRINT_TIMER("NSString (10 copy) "); + + str = [stringClass stringWithCString: "hello world"]; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str hash]; + } + END_TIMER; + PRINT_TIMER("NSString (10 hash) "); + + str = @"ConstantString"; + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + [str hash]; + } + END_TIMER; + PRINT_TIMER("NSString (10 hash) <@'ConstantString'> "); + + START_TIMER; + for (i = 0; i < MAX_COUNT/100; i++) + { + id arp = [NSAutoreleasePool new]; + [plist description]; + [arp release]; + } + END_TIMER; + PRINT_TIMER("NSString (1/100 mkplist) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT/1000; i++) + { + [plstr propertyList]; + } + END_TIMER; + PRINT_TIMER("NSString (1/1000 plparse)\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT/1000; i++) + { + id arp = [NSAutoreleasePool new]; + NSString *s = [plist description]; + id p = [s propertyList]; + if ([p isEqual: plist] == NO) + printf("Argh 1\n"); + if ([s isEqual: plstr] == NO) + printf("Argh 2\n"); + [arp release]; + } + END_TIMER; + PRINT_TIMER("NSString (1/1000 plcomp)\t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT/100; i++) + { + NSData *d = [ser serializePropertyList: plist]; + [des deserializePropertyListFromData: d mutableContainers: NO]; + } + END_TIMER; + PRINT_TIMER("NSString (1/100 ser/des)\t\t"); + + [NSDeserializer uniquing: YES]; + START_TIMER; + for (i = 0; i < MAX_COUNT/100; i++) + { + NSData *d = [ser serializePropertyList: plist]; + [des deserializePropertyListFromData: d mutableContainers: NO]; + } + END_TIMER; + PRINT_TIMER("NSString (1/100 ser/des - uniquing)\t"); + [NSDeserializer uniquing: NO]; + + START_TIMER; + for (i = 0; i < MAX_COUNT/100; i++) + { + NSData *d = [arc archivedDataWithRootObject: plist]; + [una unarchiveObjectWithData: d]; + } + END_TIMER; + PRINT_TIMER("NSString (1/100 arc/una)\t\t"); + + AUTO_END; +} + +void +bench_date() +{ + int i; + id d; + AUTO_START; + Class dateClass = [NSCalendarDate class]; + + printf("NSCalendarDate\n"); + START_TIMER; + for (i = 0; i < MAX_COUNT/10; i++) + { + d = [[dateClass alloc] init]; + [d description]; + [d dayOfYear]; + [d minuteOfHour]; + [d release]; + } + END_TIMER; + PRINT_TIMER("NSCalendarDate (various)\t\t"); + AUTO_END; +} + +void +bench_data() +{ + int i; + id d, o; + AUTO_START; + Class dataClass = [NSData class]; + + printf("NSData\n"); + START_TIMER; + for (i = 0; i < MAX_COUNT/10; i++) + { + d = [[dataClass alloc] initWithContentsOfFile:@"benchmark.m"]; + [d length]; + o = [d copy]; + [o release]; + o = [d mutableCopy]; + [o release]; + [d release]; + } + END_TIMER; + PRINT_TIMER("NSData (various)\t\t\t"); + AUTO_END; +} + +void +bench_maptable() +{ + int i; + NSMapTable *table; + NSMapTable *table2; + NSString *keys[MAX_COUNT/10]; + NSString *vals[MAX_COUNT/10]; + + AUTO_START; + for (i = 0; i < MAX_COUNT/10; i++) + { + char buf1[100], buf2[100]; + sprintf(buf1, "key%0d", i); + sprintf(buf2, "val%0d", i); + keys[i] = [stringClass stringWithCString: buf1]; + vals[i] = [stringClass stringWithCString: buf2]; + } + printf("NSMapTable\n"); + table = NSCreateMapTable(NSObjectMapKeyCallBacks, + NSObjectMapValueCallBacks, 16); + START_TIMER; + for (i = 0; i < MAX_COUNT/10; i++) + { + int j; + + for (j = 0; j < 10; j++) + { + NSMapInsert(table, keys[i], vals[i]); + } + } + END_TIMER; + PRINT_TIMER("NSMapTable (1 NSMapInsert) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT; i++) + { + int j; + + for (j = 0; j < 10; j++) + { + NSMapGet(table, keys[i/10]); + } + } + END_TIMER; + PRINT_TIMER("NSMapTable (10 NSMapGet) \t\t"); + + START_TIMER; + for (i = 0; i < MAX_COUNT*10; i++) + { + NSCountMapTable(table); + } + END_TIMER; + PRINT_TIMER("NSMapTable (10 NSCountMapTable)\t"); + + table2 = NSCopyMapTableWithZone(table, NSDefaultMallocZone()); + START_TIMER; + for (i = 0; i < 10; i++) + { + NSCompareMapTables(table, table2); + } + END_TIMER; + PRINT_TIMER("NSMapTable (ten times NSCompareMapTables)"); + AUTO_END; +} + +int main(int argc, char *argv[], char **env) +{ + id pool; + +#if LIB_FOUNDATION_LIBRARY || defined(GS_PASS_ARGUMENTS) + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; +#endif + + /* + * Cache classes to remove overhead of objc runtime class lookup from + * the benchmark. + */ + rootClass = [NSObject class]; + stringClass = [NSString class]; + + pool = [NSAutoreleasePool new]; + printf(" Test \t\t\t\t time (sec) \t index\n"); + bench_object(); + bench_number(); + bench_str(); + bench_array(); + bench_dict(); + bench_maptable(); + bench_date(); + bench_data(); + AUTO_END; + return 0; +} + diff --git a/Testing/call.m b/Testing/call.m new file mode 100644 index 000000000..01df80206 --- /dev/null +++ b/Testing/call.m @@ -0,0 +1,199 @@ + +/* call - Program to test NSFileHandle TCP/IP connection. + + Copyright (C) 2002 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Richard Frith-Macdonald + Date: Jun 2002 + + This file is part of the GNUstep Base Library. +*/ + +#include + +GS_EXPORT NSString * const GSTelnetNotification; +GS_EXPORT NSString * const GSTelnetErrorKey; +GS_EXPORT NSString * const GSTelnetTextKey; +@class GSTelnetHandle; + +@interface Call : NSObject +{ + NSFileHandle *ichan; + NSFileHandle *ochan; + id remote; + NSMutableData *buf; +} +- (void) didRead: (NSNotification*)notification; +- (void) didWrite: (NSNotification*)notification; +- (void) gotTelnet: (NSNotification*)notification; +@end + + +@implementation Call + +- (void) dealloc +{ + RELEASE(ichan); + RELEASE(ochan); + RELEASE(remote); + RELEASE(buf); + [super dealloc]; +} + +- (void) didRead: (NSNotification*)notification +{ + NSDictionary *userInfo = [notification userInfo]; + NSData *d; + + d = [userInfo objectForKey: NSFileHandleNotificationDataItem]; + if (d == nil || [d length] == 0) + { + NSLog(@"Read EOF"); + exit(0); + } + else + { + char *ptr; + unsigned len; + int i; + + [buf appendData: d]; + ptr = [buf mutableBytes]; + len = [buf length]; + for (i = 0; i < len; i++) + { + if (ptr[i] == '\n') + { + NSString *s; + + if (i > 0 && ptr[i-1] == '\r') + { + s = [NSString stringWithUTF8String: ptr length: i-1]; + } + else + { + s = [NSString stringWithUTF8String: ptr length: i]; + } + len -= (i + 1); + if (len > 0) + { + memcpy(ptr, &ptr[i+1], len); + } + [buf setLength: len]; + ptr = [buf mutableBytes]; + i = -1; + [remote putTelnetLine: s]; + } + } + [ichan readInBackgroundAndNotify]; + } +} + +- (void) didWrite: (NSNotification*)notification +{ + NSDictionary *userInfo = [notification userInfo]; + NSString *e; + + e = [userInfo objectForKey: GSFileHandleNotificationError]; + if (e) + { + NSLog(@"%@", e); + exit(0); + } +} + +- (void) gotTelnet: (NSNotification*)notification +{ + NSDictionary *info = [notification userInfo]; + NSArray *text; + + text = [info objectForKey: GSTelnetTextKey]; + if (text == nil) + { + NSLog(@"Lost telnet - %@", [info objectForKey: GSTelnetErrorKey]); + exit(0); + } + else + { + unsigned i; + + for (i = 0; i < [text count]; i++) + { + [ochan writeInBackgroundAndNotify: + [[text objectAtIndex: i] dataUsingEncoding: NSUTF8StringEncoding]]; + } + } +} + +- (id) init +{ + NSArray *args = [[NSProcessInfo processInfo] arguments]; + NSString *host = @"localhost"; + NSString *service = @"telnet"; + NSString *protocol = @"tcp"; + + if ([args count] > 1) + { + host = [args objectAtIndex: 1]; + if ([args count] > 2) + { + service = [args objectAtIndex: 2]; + if ([args count] > 3) + { + protocol = [args objectAtIndex: 3]; + } + } + } + buf = [NSMutableData new]; + ichan = RETAIN([NSFileHandle fileHandleWithStandardInput]); + ochan = RETAIN([NSFileHandle fileHandleWithStandardOutput]); + remote = [[GSTelnetHandle alloc] initWithHandle: + [NSFileHandle fileHandleAsClientAtAddress: + host service: service protocol: protocol] isConnected: YES]; + if (remote == nil) + { + NSLog(@"Failed to create connection"); + DESTROY(self); + } + else + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + + [nc addObserver: self + selector: @selector(didRead:) + name: NSFileHandleReadCompletionNotification + object: ichan]; + [nc addObserver: self + selector: @selector(didWrite:) + name: GSFileHandleWriteCompletionNotification + object: ochan]; + [nc addObserver: self + selector: @selector(gotTelnet:) + name: GSTelnetNotification + object: remote]; + [ichan readInBackgroundAndNotify]; + } + return self; +} + +@end + + + +int +main() +{ + Call *console; + CREATE_AUTORELEASE_POOL(arp); + + console = [Call new]; + RELEASE(arp); + [[NSRunLoop currentRunLoop] run]; + RELEASE(console); + return 0; +} + diff --git a/Testing/coder.m b/Testing/coder.m new file mode 100644 index 000000000..85476e173 --- /dev/null +++ b/Testing/coder.m @@ -0,0 +1,110 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* A demonstration of writing and reading GNU Objective C objects to a file. */ +// Fri Oct 23 03:01:09 MET DST 1998 dave@turbocat.de + +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + id array, dictionary; + id archiver; + id name; + id arp; + int i; + Class cstream_class; + + if (argc > 1) + cstream_class = objc_get_class (argv[1]); + else + cstream_class = [BinaryCStream class]; + + [NSObject enableDoubleReleaseCheck: YES]; + arp = [[NSAutoreleasePool alloc] init]; + + /* Create an Array and Dictionary */ + array = [Array new]; + dictionary = [Dictionary new]; + + for (i = 0; i < 6; i++) + { + [array addObject: [NSNumber numberWithInt: i]]; + [dictionary putObject: [NSNumber numberWithInt: i] + atKey: [NSNumber numberWithInt: i*i]]; + } + [array printForDebugger]; + [dictionary printForDebugger]; + + /* Write them to a file */ + + /* Create an instances of the Archiver class, specify that we + want human-readable "Text"-style, instead of "Binary"-style + coding. */ + archiver = [[Archiver alloc] initForWritingToFile: @"./coder.dat" + withCStreamClass: cstream_class]; + [archiver encodeObject: array + withName: @"Test Array"]; + [archiver encodeObject: dictionary + withName: @"Test Dictionary"]; + + /* Release the objects that were coded */ + [array release]; + [dictionary release]; + + /* Close the archiver, (and thus flush the stream); then release it. + We must separate the idea of "closing" a stream and + "deallocating" a stream because of delays in deallocation due to + -autorelease. */ + [archiver close]; + [archiver release]; + + + /* Read them back in from the file */ + + /* First create the unarchiver */ + archiver = [Unarchiver newReadingFromFile: @"./coder.dat"]; + + /* Read in the Array */ + [archiver decodeObjectAt: &array withName: &name]; + if (name) + printf ("got object named %s\n", [name cString]); + else + printf ("got object named (unnamed)\n"); + + /* Read in the Dictionary */ + [archiver decodeObjectAt: &dictionary withName: &name]; + if (name) + printf ("got object named %s\n", [name cString]); + else + printf ("got object named (unnamed)\n"); + + /* Display what we read, to make sure it matches what we wrote */ + [array printForDebugger]; + [dictionary printForDebugger]; + + /* Relase the objects we read */ + [array release]; + [dictionary release]; + + /* Release the unarchiver. */ + [archiver release]; + + /* Do the autorelease. */ + [arp release]; + + exit(0); +} diff --git a/Testing/containers.m b/Testing/containers.m new file mode 100644 index 000000000..dd97ea036 --- /dev/null +++ b/Testing/containers.m @@ -0,0 +1,247 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include + +@interface Foo: NSObject +{ +} + ++ foo; +- (BOOL) conformsToProtocol: (Protocol *) aProtocol; +- (BOOL) respondsToSelector: (SEL) aSelector; +- copyWithZone: (NSZone *) zone; +- mutableCopyWithZone: (NSZone *) zone; +@end + + +@implementation Foo + ++ foo +{ + return [[[Foo alloc] init] autorelease]; +} + +- (BOOL) conformsToProtocol: (Protocol *) aProtocol +{ + BOOL ret = [super conformsToProtocol: aProtocol]; + + NSLog(@"-[<%@:0x%x> %@<%s>] -> %@", + NSStringFromClass([self class]), self, NSStringFromSelector(_cmd), + [aProtocol name], ret ? @"YES" : @"NO"); + return ret; +} + + +- (BOOL) respondsToSelector: (SEL) aSelector +{ + BOOL ret = [super respondsToSelector: aSelector]; + + if (![NSStringFromSelector(aSelector) hasPrefix:@"description"]) + NSLog(@"-[<%@:0x%x> %@%@] -> %@", + NSStringFromClass([self class]), self, NSStringFromSelector(_cmd), + NSStringFromSelector(aSelector), ret ? @"YES" : @"NO"); + return ret; +} + +- copyWithZone: (NSZone *) zone +{ + id ret = [Foo foo]; + + NSLog(@"-[<%@:0x%x> %@0x%x] -> <%@:0x%x>", + NSStringFromClass([self class]), self, + NSStringFromSelector(_cmd), zone, NSStringFromClass([ret class]), ret); + return ret; +} + +- mutableCopyWithZone: (NSZone *) zone +{ + id ret = [Foo foo]; + + NSLog(@"-[<%@:0x%x> %@0x%x] -> <%@:0x%x>", + NSStringFromClass([self class]), self, + NSStringFromSelector(_cmd), zone, NSStringFromClass([ret class]), ret); + return ret; +} + +- retain +{ + id ret = [super retain]; + + NSLog(@"-[<%@:0x%x> %@] -> retainCount = %d", + NSStringFromClass([self class]), self, + NSStringFromSelector(_cmd), [ret retainCount]); + return ret; +} + +@end + +void +isDeepArrayCopy(NSArray *obj1, NSArray *obj2) +{ + id obj1FirstObject = [obj1 objectAtIndex:0]; + id obj2FirstObject = [obj2 objectAtIndex:0]; + + NSLog(@"<%@:0x%x> -> <%@:0x%x>, %@", + NSStringFromClass([obj1 class]), obj1, + NSStringFromClass([obj2 class]), obj2, + (obj1FirstObject == obj2FirstObject) ? ((obj1 == obj2) ? @"retained" : @"shallow") : @"deep(ish)"); +} + +void +isDeepDictionaryCopy(NSDictionary *obj1, NSDictionary *obj2) +{ + id obj1FirstObject = [obj1 objectForKey: @"Key"]; + id obj2FirstObject = [obj2 objectForKey: @"Key"]; + + NSLog(@"<%@:0x%x> -> <%@:0x%x>, %@", + NSStringFromClass([obj1 class]), obj1, + NSStringFromClass([obj2 class]), obj2, + (obj1FirstObject == obj2FirstObject) ? ((obj1 == obj2) ? @"retained" : @"shallow") : @"deep(ish)"); +} + +void +isDeepSetCopy(NSSet *obj1, NSSet *obj2) +{ + id obj1FirstObject = [obj1 anyObject]; + id obj2FirstObject = [obj2 anyObject]; + + NSLog(@"<%@:0x%x> -> <%@:0x%x>, %@", + NSStringFromClass([obj1 class]), obj1, + NSStringFromClass([obj2 class]), obj2, + (obj1FirstObject == obj2FirstObject) ? ((obj1 == obj2) ? @"retained" : @"shallow") : @"deep(ish)"); +} + + +int main(int argc, char **argv) +{ + NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init]; + NSArray *anArrayCopy; + NSArray *aMutableArrayCopy; + NSArray *anArrayMutableCopy; + NSArray *aMutableArrayMutableCopy; + NSMutableArray *aMutableArray + = [NSMutableArray arrayWithObject: [Foo foo]]; + NSArray *anArray = [NSArray arrayWithObject: [Foo foo]]; + NSDictionary *aDictionaryCopy; + NSDictionary *aMutableDictionaryCopy; + NSDictionary *aDictionaryMutableCopy; + NSDictionary *aMutableDictionaryMutableCopy; + NSMutableDictionary *aMutableDictionary + = [NSMutableDictionary dictionaryWithObjectsAndKeys: [Foo foo], @"Key", nil]; + NSDictionary *aDictionary + = [NSDictionary dictionaryWithObjectsAndKeys: [Foo foo], @"Key", nil]; + NSSet *aSetCopy; + NSSet *aMutableSetCopy; + NSSet *aSetMutableCopy; + NSSet *aMutableSetMutableCopy; + NSMutableSet *aMutableSet = [NSMutableSet setWithObject: [Foo foo]]; + NSSet *aSet = [NSSet setWithObject: [Foo foo]]; + NSZone *zone = NSDefaultMallocZone(); + + while (zone != 0) + { + NSLog(@"Copying from zone 0x%x -> 0x%x", NSDefaultMallocZone(), zone); + + NSLog(@"MutableArray -copy"); + aMutableArrayCopy = [aMutableArray copyWithZone:zone]; + NSLog(@"MutableArray -mutableCopy"); + aMutableArrayMutableCopy = [aMutableArray mutableCopyWithZone:zone]; + NSLog(@"Array -copy"); + anArrayCopy = [anArray copyWithZone:zone]; + NSLog(@"Array -mutableCopy"); + anArrayMutableCopy = [anArray mutableCopyWithZone:zone]; + + NSLog(@"MutableArray: %@", aMutableArray); + NSLog(@"MutableArrayCopy: %@", aMutableArrayCopy); + NSLog(@"MutableArrayMutableCopy: %@", aMutableArrayMutableCopy); + NSLog(@"anArray: %@", anArray); + NSLog(@"anArrayCopy: %@", anArrayCopy); + NSLog(@"anArrayCopy: %@", anArrayMutableCopy); + + NSLog(@"Test MutableArray against Copy"); + isDeepArrayCopy(aMutableArray, aMutableArrayCopy); + + NSLog(@"Test MutableArray against MutableCopy"); + isDeepArrayCopy(aMutableArray, aMutableArrayMutableCopy); + + NSLog(@"Test Array against Copy"); + isDeepArrayCopy(anArray, anArrayCopy); + + NSLog(@"Test Array against MutableCopy"); + isDeepArrayCopy(anArray, anArrayMutableCopy); + + NSLog(@"MutableDictionary -copy"); + aMutableDictionaryCopy = [aMutableDictionary copyWithZone:zone]; + NSLog(@"MutableDictionary -mutableCopy"); + aMutableDictionaryMutableCopy = [aMutableDictionary mutableCopyWithZone:zone]; + NSLog(@"Dictionary -copy"); + aDictionaryCopy = [aDictionary copyWithZone:zone]; + NSLog(@"Dictionary -mutableCopy"); + aDictionaryMutableCopy = [aDictionary mutableCopyWithZone:zone]; + + NSLog(@"MutableDictionary: %@", aMutableDictionary); + NSLog(@"MutableDictionaryCopy: %@", aMutableDictionaryCopy); + NSLog(@"MutableDictionaryMutableCopy: %@", aMutableDictionaryMutableCopy); + NSLog(@"aDictionary: %@", aDictionary); + NSLog(@"aDictionaryCopy: %@", aDictionaryCopy); + NSLog(@"aDictionaryCopy: %@", aDictionaryMutableCopy); + + NSLog(@"Test MutableDictionary against Copy"); + isDeepDictionaryCopy(aMutableDictionary, aMutableDictionaryCopy); + + NSLog(@"Test MutableDictionary against MutableCopy"); + isDeepDictionaryCopy(aMutableDictionary, aMutableDictionaryMutableCopy); + + NSLog(@"Test Dictionary against Copy"); + isDeepDictionaryCopy(aDictionary, aDictionaryCopy); + + NSLog(@"Test Dictionary against MutableCopy"); + isDeepDictionaryCopy(aDictionary, aDictionaryMutableCopy); + + NSLog(@"MutableSet -copy"); + aMutableSetCopy = [aMutableSet copyWithZone:zone]; + NSLog(@"MutableSet -mutableCopy"); + aMutableSetMutableCopy = [aMutableSet mutableCopyWithZone:zone]; + NSLog(@"Set -copy"); + aSetCopy = [aSet copyWithZone:zone]; + NSLog(@"Set -mutableCopy"); + aSetMutableCopy = [aSet mutableCopyWithZone:zone]; + + NSLog(@"MutableSet: %@", aMutableSet); + NSLog(@"MutableSetCopy: %@", aMutableSetCopy); + NSLog(@"MutableSetMutableCopy: %@", aMutableSetMutableCopy); + NSLog(@"aSet: %@", aSet); + NSLog(@"aSetCopy: %@", aSetCopy); + NSLog(@"aSetCopy: %@", aSetMutableCopy); + + NSLog(@"Test MutableSet against Copy"); + isDeepSetCopy(aMutableSet, aMutableSetCopy); + + NSLog(@"Test MutableSet against MutableCopy"); + isDeepSetCopy(aMutableSet, aMutableSetMutableCopy); + + NSLog(@"Test Set against Copy"); + isDeepSetCopy(aSet, aSetCopy); + + NSLog(@"Test Set against MutableCopy"); + isDeepSetCopy(aSet, aSetMutableCopy); + + if (zone == NSDefaultMallocZone()) + zone = NSCreateZone(NSPageSize(), NSPageSize(), YES); + else + zone = 0; + } + [thePool release]; + + return 0; +} + diff --git a/Examples/diningPhilosophers.m b/Testing/diningPhilosophers.m similarity index 92% rename from Examples/diningPhilosophers.m rename to Testing/diningPhilosophers.m index 9ad544973..0794a9442 100644 --- a/Examples/diningPhilosophers.m +++ b/Testing/diningPhilosophers.m @@ -11,18 +11,18 @@ This file is part of the GNUstep Application Kit Library. - This file is free software; you can redistribute it and/or + This library 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. + version 2 of the License, or (at your option) any later version. - This file is distributed in the hope that it will be useful, + This library 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 file; if not, write to the Free + License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ diff --git a/Testing/exported-strings.m b/Testing/exported-strings.m new file mode 100644 index 000000000..1d92e4255 --- /dev/null +++ b/Testing/exported-strings.m @@ -0,0 +1,169 @@ +/** externs.m Program to test correct initialization of externs. + Copyright (C) 2003 Free Software Foundation, Inc. + + Written by: David Ayers + + This file is part of the GNUstep Base Library. + + This library 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 2 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +*/ + +#include + +#include + +#define MyAssert1(IDENT) do { \ + cache[i++] = IDENT; \ + assert (IDENT != 0); \ + } while (0) + +#define MyAssert2(IDENT) do { \ + NSCAssert2([IDENT isEqual: \ + [NSString stringWithUTF8String: #IDENT]], \ + @"Invalid value: %@ for: %s", \ + IDENT, #IDENT); \ + NSCAssert2([cache[i++] isEqual: IDENT], \ + @"Initial values differ:%@ %@", \ + cache[i-1], IDENT); \ + } while (0) + +#define CACHE_SIZE 256 +NSString *cache[CACHE_SIZE]; + +int +main() +{ + NSAutoreleasePool *pool; + int i = 0; + + /* Insure extern identifiers are initialized + before ObjC code is executed. */ + MyAssert1(NSConnectionDidDieNotification); + MyAssert1(NSConnectionDidInitializeNotification); + MyAssert1(NSWillBecomeMultiThreadedNotification); + MyAssert1(NSThreadDidStartNotification); + MyAssert1(NSThreadWillExitNotification); + MyAssert1(NSPortDidBecomeInvalidNotification); + MyAssert1(NSConnectionReplyMode); + MyAssert1(NSBundleDidLoadNotification); + MyAssert1(NSShowNonLocalizedStrings); + MyAssert1(NSLoadedClasses); + // MyAssert1(StreamException); + MyAssert1(NSArgumentDomain); + MyAssert1(NSGlobalDomain); + MyAssert1(NSRegistrationDomain); + MyAssert1(NSUserDefaultsDidChangeNotification); + MyAssert1(NSWeekDayNameArray); + MyAssert1(NSShortWeekDayNameArray); + MyAssert1(NSMonthNameArray); + MyAssert1(NSShortMonthNameArray); + MyAssert1(NSTimeFormatString); + MyAssert1(NSDateFormatString); + MyAssert1(NSShortDateFormatString); + MyAssert1(NSTimeDateFormatString); + MyAssert1(NSShortTimeDateFormatString); + MyAssert1(NSCurrencySymbol); + MyAssert1(NSDecimalSeparator); + MyAssert1(NSThousandsSeparator); + MyAssert1(NSInternationalCurrencyString); + MyAssert1(NSCurrencyString); + // MyAssert1(NSNegativeCurrencyFormatString); + // MyAssert1(NSPositiveCurrencyFormatString); + MyAssert1(NSDecimalDigits); + MyAssert1(NSAMPMDesignation); + MyAssert1(NSHourNameDesignations); + MyAssert1(NSYearMonthWeekDesignations); + MyAssert1(NSEarlierTimeDesignations); + MyAssert1(NSLaterTimeDesignations); + MyAssert1(NSThisDayDesignations); + MyAssert1(NSNextDayDesignations); + MyAssert1(NSNextNextDayDesignations); + MyAssert1(NSPriorDayDesignations); + MyAssert1(NSDateTimeOrdering); + MyAssert1(NSLanguageCode); + MyAssert1(NSLanguageName); + MyAssert1(NSFormalName); + MyAssert1(NSLocale); + MyAssert1(NSConnectionRepliesReceived); + MyAssert1(NSConnectionRepliesSent); + MyAssert1(NSConnectionRequestsReceived); + MyAssert1(NSConnectionRequestsSent); + MyAssert1(NSConnectionLocalCount); + MyAssert1(NSConnectionProxyCount); + MyAssert1(NSClassDescriptionNeededForClassNotification); + + assert(i < CACHE_SIZE); /* incread the cache size. */ + + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + pool = [[NSAutoreleasePool alloc] init]; + + i = 0; + MyAssert2(NSConnectionDidDieNotification); + MyAssert2(NSConnectionDidInitializeNotification); + MyAssert2(NSWillBecomeMultiThreadedNotification); + MyAssert2(NSThreadDidStartNotification); + MyAssert2(NSThreadWillExitNotification); + MyAssert2(NSPortDidBecomeInvalidNotification); + MyAssert2(NSConnectionReplyMode); + MyAssert2(NSBundleDidLoadNotification); + MyAssert2(NSShowNonLocalizedStrings); + MyAssert2(NSLoadedClasses); + MyAssert2(NSArgumentDomain); + MyAssert2(NSGlobalDomain); + MyAssert2(NSRegistrationDomain); + MyAssert2(NSUserDefaultsDidChangeNotification); + MyAssert2(NSWeekDayNameArray); + MyAssert2(NSShortWeekDayNameArray); + MyAssert2(NSMonthNameArray); + MyAssert2(NSShortMonthNameArray); + MyAssert2(NSTimeFormatString); + MyAssert2(NSDateFormatString); + MyAssert2(NSShortDateFormatString); + MyAssert2(NSTimeDateFormatString); + MyAssert2(NSShortTimeDateFormatString); + MyAssert2(NSCurrencySymbol); + MyAssert2(NSDecimalSeparator); + MyAssert2(NSThousandsSeparator); + MyAssert2(NSInternationalCurrencyString); + MyAssert2(NSCurrencyString); + // MyAssert2(NSNegativeCurrencyFormatString); + // MyAssert2(NSPositiveCurrencyFormatString); + MyAssert2(NSDecimalDigits); + MyAssert2(NSAMPMDesignation); + MyAssert2(NSHourNameDesignations); + MyAssert2(NSYearMonthWeekDesignations); + MyAssert2(NSEarlierTimeDesignations); + MyAssert2(NSLaterTimeDesignations); + MyAssert2(NSThisDayDesignations); + MyAssert2(NSNextDayDesignations); + MyAssert2(NSNextNextDayDesignations); + MyAssert2(NSPriorDayDesignations); + MyAssert2(NSDateTimeOrdering); + MyAssert2(NSLanguageCode); + MyAssert2(NSLanguageName); + MyAssert2(NSFormalName); + MyAssert2(NSLocale); + MyAssert2(NSConnectionRepliesReceived); + MyAssert2(NSConnectionRepliesSent); + MyAssert2(NSConnectionRequestsReceived); + MyAssert2(NSConnectionRequestsSent); + MyAssert2(NSConnectionLocalCount); + MyAssert2(NSConnectionProxyCount); + MyAssert2(NSClassDescriptionNeededForClassNotification); + + [pool release]; + + exit(0); +} diff --git a/Testing/fref.m b/Testing/fref.m new file mode 100644 index 000000000..c65b45a68 --- /dev/null +++ b/Testing/fref.m @@ -0,0 +1,201 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* Test NSArchiver on encoding of self-referential forward references. */ + +#include +#include +#include + +/* This object encodes an -encodeConditionalObject: reference to a Foo. */ +@interface SubFoo : NSObject +{ + id super_foo; + int label; +} +@end + +/* This object encodes an -encodeObject: reference to a SubFoo. */ +@interface Foo : NSObject +{ + id sub_foo; + int label; +} +- (int) label; +@end + +@implementation SubFoo + +- (void) dealloc +{ + RELEASE(super_foo); + [super dealloc]; +} + +- (id) initWithSuperFoo: (id)o label: (int)l +{ + self = [super init]; + super_foo = RETAIN(o); + label = l; + return self; +} + +- (id) superFoo +{ + return super_foo; +} + +- (void) encodeWithCoder: (NSCoder*)coder +{ + printf ("In [SubFoo encodeWithCoder:]\n"); + [coder encodeConditionalObject: super_foo]; + [coder encodeValueOfObjCType: @encode(int) + at: &label]; +} + +- (id) initWithCoder: (NSCoder*)coder +{ + [coder decodeValueOfObjCType: @encode(id) + at: &super_foo]; + [coder decodeValueOfObjCType: @encode(int) + at: &label]; + return self; +} + +- (void) print +{ + printf ("label = %d, super label = %d\n", + label, [super_foo label]); +} + +@end + +@implementation Foo + +- (void) dealloc +{ + RELEASE(sub_foo); + [super dealloc]; +} + +- (id) init +{ + self = [super init]; + sub_foo = nil; + label = 0; + return self; +} + +- (void) setSubFoo: o +{ + ASSIGN(sub_foo, o); +} + +- (id) subFoo +{ + return sub_foo; +} + +- (void) encodeWithCoder: (NSCoder*)coder +{ + printf ("In [Foo encodeWithCoder:]\n"); + [coder encodeObject: sub_foo]; + [coder encodeValueOfObjCType: @encode(int) + at: &label]; +} + +- (id) initWithCoder: (NSCoder*)coder +{ + [coder decodeValueOfObjCType: @encode(id) + at: &sub_foo]; + [coder decodeValueOfObjCType: @encode(int) + at: &label]; + return self; +} + +- (int) label +{ + return label; +} + +- (void) setLabel: (int)l +{ + label = l; +} + +@end + +/* Test the use of -encodeConditional to encode a forward reference + to an object. */ +void +test_fref () +{ + id array; + id foo, sub_foo; + printf ("\nTest encoding of forward references\n"); + + array = [[NSMutableArray alloc] init]; + foo = [[Foo alloc] init]; + [foo setLabel: 4]; + sub_foo = [[SubFoo alloc] initWithSuperFoo: foo label: 3]; + [foo setSubFoo: sub_foo]; + [array addObject: foo]; + [array insertObject: sub_foo atIndex: 0]; + + [NSArchiver archiveRootObject: array toFile: @"fref.dat"]; + printf ("Encoded: "); + [sub_foo print]; + RELEASE(foo); + RELEASE(sub_foo); + RELEASE(array); + + array = [NSUnarchiver unarchiveObjectWithFile: @"fref.dat"]; + foo = [array objectAtIndex: 1]; + sub_foo = [foo subFoo]; + printf ("Decoded: "); + [sub_foo print]; +} + +/* Test the encode of a self-referential forward reference. */ +void +test_self_fref () +{ + id foo, sub_foo; + printf ("\nTest encoding of self-referential forward references\n"); + + foo = [[Foo alloc] init]; + [foo setLabel: 4]; + sub_foo = [[SubFoo alloc] initWithSuperFoo: foo label: 3]; + [foo setSubFoo: sub_foo]; + + [NSArchiver archiveRootObject: foo toFile: @"fref.dat"]; + printf ("Encoded: "); + [sub_foo print]; + RELEASE(foo); + RELEASE(sub_foo); + + foo = [NSUnarchiver unarchiveObjectWithFile: @"fref.dat"]; + sub_foo = [foo subFoo]; + printf ("Decoded: "); + [sub_foo print]; +} + +int +main () +{ + CREATE_AUTORELEASE_POOL(arp); + + test_fref (); + test_self_fref (); + + RELEASE(arp); + + exit (0); +} diff --git a/Testing/gsbehavior.m b/Testing/gsbehavior.m new file mode 100644 index 000000000..eae11800d --- /dev/null +++ b/Testing/gsbehavior.m @@ -0,0 +1,377 @@ +/** gsbehavior - Program to test GSObjCAddClassBehavior. + Copyright (C) 2003 Free Software Foundation, Inc. + + Written by: David Ayers + + This file is part of the GNUstep Base Library. + + This library 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 2 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +*/ + + +#include +#include +#include +#include + +#include + +/*------------------------------------*/ +@interface MyClass : NSObject +-(const char *)text; +-(const char *)textBase; +@end +@implementation MyClass +-(void)myClassMain {}; +-(const char *)text +{ + return "class_main"; +} +-(const char *)textBase +{ + return "class_main_base"; +} +@end + +@interface MyClass (Category1) +-(void)myClassCategory1; +@end +@implementation MyClass (Category1) +-(void)myClassCategory1 {}; +-(const char *)text +{ + return "class_category_1"; +} +@end + +@interface MyClass (Category2) +-(void)myClassCategory2; +@end +@implementation MyClass (Category2) +-(void)myClassCategory2 {}; +-(const char *)text +{ + return "class_category_2"; +} +@end + +/*------------------------------------*/ + +@interface MyTemplate1 : NSObject +@end +@implementation MyTemplate1 +@end + +/*------------------------------------*/ +/*------------------------------------*/ + +@interface MyTemplate2 : NSObject +-(const char *)text; +@end +@implementation MyTemplate2 +-(const char *)text +{ + return "template_main"; +} +@end + +/*------------------------------------*/ + +@interface MyBehavior : NSObject +-(const char *)text; +-(const char *)textBase; +@end +@implementation MyBehavior +-(void)myBehaviorMain {}; +-(const char *)text +{ + return "behavior_main"; +} +-(const char *)textBase +{ + return "behavior_main_base"; +} +@end +@interface MyBehavior (Category1) +-(void)myBehaviorCategory1; +@end +@implementation MyBehavior (Category1) +-(void)myBehaviorCategory1 {}; +-(const char *)text +{ + return "behavior_category_1"; +} +@end + +@interface MyBehavior (Category2) +-(void)myBehaviorCategory2; +@end +@implementation MyBehavior (Category2) +-(void)myBehaviorCategory2 {}; +-(const char *)text +{ + return "behavior_category_2"; +} +@end + +/*------------------------------------*/ + +void +test_basic(void) +{ + id myClass; + id myBehavior; + + myClass = [MyClass new]; + myBehavior = [MyBehavior new]; + + NSCAssert(strncmp([myClass text], "class_category", 14) == 0, + @"Default implementation isn't Category!"); + NSCAssert(strncmp([myBehavior text], "behavior_category", 17) == 0, + @"Default implementation isn't Category!"); + + RELEASE(myClass); + RELEASE(myBehavior); +} + +void +test_create_list(void) +{ + GSMethodList myList; + GSMethod myMethod; + Class myClass; + void *it; + IMP imp_main; + IMP imp_1; + IMP imp_2; + const char *types; + id myObj; + + it = 0; + myClass = [MyClass class]; + myObj = [myClass new]; + myList = GSMethodListForSelector(myClass, @selector(text), &it, YES); + NSCAssert(myList,@"List is NULL!"); + myMethod = GSMethodFromList(myList, @selector(text), NO); + NSCAssert(myMethod,@"Method is NULL!"); + imp_1 = myMethod->method_imp; + + myList = GSMethodListForSelector(myClass, @selector(text), &it, YES); + NSCAssert(myList,@"List is NULL!"); + myMethod = GSMethodFromList(myList, @selector(text), NO); + NSCAssert(myMethod,@"Method is NULL!"); + imp_2 = myMethod->method_imp; + + myList = GSMethodListForSelector(myClass, @selector(text), &it, YES); + NSCAssert(myList,@"List is NULL!"); + myMethod = GSMethodFromList(myList, @selector(text), NO); + NSCAssert(myMethod,@"Method is NULL!"); + imp_main = myMethod->method_imp; + + types = myMethod->method_types; + + myList = GSAllocMethodList(3); + GSAppendMethodToList(myList, @selector(text_main), types, imp_main, YES); + GSAppendMethodToList(myList, @selector(text_1), types, imp_1, YES); + GSAppendMethodToList(myList, @selector(text_2), types, imp_2, YES); + + GSAddMethodList(myClass, myList, YES); + GSFlushMethodCacheForClass(myClass); + NSCAssert([myObj respondsToSelector:@selector(text_main)] == YES, + @"Add failed."); + NSCAssert([myObj respondsToSelector:@selector(text_1)] == YES, + @"Add failed."); + NSCAssert([myObj respondsToSelector:@selector(text_2)] == YES, + @"Add failed."); + NSCAssert(strcmp([myObj text_main], "class_main") == 0, + @"Add failed to add correct implementation!"); + NSCAssert(strncmp([myObj text_1], "class_category", 14) == 0, + @"Add failed to add correct implementation!"); + NSCAssert(strncmp([myObj text_2], "class_category", 14) == 0, + @"Add failed to add correct implementation!"); + +} + +void +test_reorder_list(void) +{ + Class myClass; + id myObj; + GSMethodList list; + + myClass = [MyClass class]; + myObj = [MyClass new]; + + list = GSMethodListForSelector(myClass, @selector(myClassMain), 0, YES); + + /* Remove */ + GSRemoveMethodList(myClass, list, YES); + GSFlushMethodCacheForClass(myClass); + NSCAssert([myObj respondsToSelector:@selector(myClassMain)] == NO, + @"Remove failed."); + + /* Add */ + GSAddMethodList(myClass, list, YES); + GSFlushMethodCacheForClass(myClass); + + NSCAssert([myObj respondsToSelector:@selector(myClassMain)] == YES, + @"Add failed."); + NSCAssert(strcmp([myObj text], "class_main") == 0, + @"Add failed to add correct implementation!"); + + RELEASE(myClass); +} + +void +test_exchange_method(void) +{ + Class myClass; + Class myBehavior; + id myClsObj; + id myBhvObj; + GSMethodList myListC; + GSMethodList myListB; + GSMethod myMethodC; + GSMethod myMethodB; + struct objc_method myMethodStructC; + struct objc_method myMethodStructB; + + myClass = [MyClass class]; + myBehavior = [MyBehavior class]; + + myClsObj = [myClass new]; + myBhvObj = [myBehavior new]; + + NSCAssert(strcmp([myClsObj textBase], "class_main_base") == 0, + @"Wrong precondition!"); + NSCAssert(strcmp([myBhvObj textBase], "behavior_main_base") == 0, + @"Wrong precondition!"); + + myListC = GSMethodListForSelector(myClass, @selector(textBase), 0, YES); + myListB = GSMethodListForSelector(myBehavior, @selector(textBase), 0, YES); + + myMethodC = GSMethodFromList(myListC, @selector(textBase), NO); + myMethodStructC = *myMethodC; + myMethodC = &myMethodStructC; + myMethodB = GSMethodFromList(myListB, @selector(textBase), NO); + myMethodStructB = *myMethodB; + myMethodB = &myMethodStructB; + + GSRemoveMethodFromList(myListC, @selector(textBase), NO); + GSRemoveMethodFromList(myListB, @selector(textBase), NO); + + GSAppendMethodToList(myListC, + myMethodB->method_name, + myMethodB->method_types, + myMethodB->method_imp, + NO); + GSAppendMethodToList(myListB, + myMethodC->method_name, + myMethodC->method_types, + myMethodC->method_imp, + NO); + + GSFlushMethodCacheForClass(myClass); + GSFlushMethodCacheForClass(myBehavior); + + NSCAssert(strcmp([myClsObj textBase], "behavior_main_base") == 0, + @"Couldn't replace implementation!"); + NSCAssert(strcmp([myBhvObj textBase], "class_main_base") == 0, + @"Couldn't replace implementation!"); + +} + +void +test_behavior1(void) +{ + Class myTmplClass; + id myTmplObj; + + myTmplClass = [MyTemplate1 class]; + myTmplObj = [MyTemplate1 new]; + + NSCAssert([myTmplObj respondsToSelector:@selector(text)] == NO, + @"Initial state invalid"); + GSObjCAddClassBehavior(myTmplClass, [MyClass class]); + NSCAssert([myTmplObj respondsToSelector:@selector(text)] == YES, + @"Behavior failed"); + +} + + +void +test_behavior2(void) +{ + Class myTmplClass; + id myTmplObj; + + myTmplClass = [MyTemplate2 class]; + myTmplObj = [MyTemplate2 new]; + + NSCAssert([myTmplObj respondsToSelector:@selector(myClassCategory1)] == NO, + @"Initial state invalid"); + GSObjCAddClassBehavior(myTmplClass, [MyClass class]); + NSCAssert([myTmplObj respondsToSelector:@selector(myClassCategory1)] == YES, + @"Behavior failed"); + + NSCAssert(strcmp([myTmplObj text], "template_main") == 0, + @"Overwritten existing implementation!"); +} + +void +test_methodnames(void) +{ + id obj = [NSNotificationCenter defaultCenter]; + NSArray *names; + + names = GSObjCMethodNames(obj); + NSDebugLog(@"obj:%@", names); + names = GSObjCMethodNames([obj class]); + NSDebugLog(@"class:%@", names); +} + +int +main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool; + // [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + pool = [[NSAutoreleasePool alloc] init]; + + NS_DURING + { + test_methodnames(); + test_basic(); + test_create_list(); + test_reorder_list(); + test_exchange_method(); + + NSLog(@"Behavior Test Succeeded."); + } + NS_HANDLER + { + NSLog(@"Behavior Test Failed:"); + NSLog(@"%@ %@ %@", + [localException name], + [localException reason], + [localException userInfo]); + [localException raise]; + } + NS_ENDHANDLER + + [pool release]; + + exit(0); +} + diff --git a/Testing/gslock.m b/Testing/gslock.m new file mode 100644 index 000000000..082ac8203 --- /dev/null +++ b/Testing/gslock.m @@ -0,0 +1,227 @@ +/** gslock - Program to test GSLazyLocks. + Copyright (C) 2003 Free Software Foundation, Inc. + + Written by: David Ayers + + This file is part of the GNUstep Base Library. + + This library 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 2 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +*/ + + +#include +#include +#include +#include +#include +#include +#include + +#include + +NSLock *lock = nil; + +NSLock *gLock1 = nil; +GSLazyRecursiveLock *gLock2 = nil; + +NSConditionLock *cLock = nil; + +volatile int counter = 0; +volatile int threadExitCounter; + +void +wait_a_while () +{ + volatile int i; + for (i = 0; i < 5; i++) + i = ((i + 1) + (i - 1) / 2); +} + +#define NUM_ITERATIONS 10000 + +@interface Tester : NSObject +- (void)runTest:(NSString *)ident; +- (void)dummy:(id)none; +- (void)createNewLockAt:(id)none; +@end +@implementation Tester +- (void)dummy:(id)none +{ + NSLog(@"Multithreaded:%@",[NSThread currentThread]); +} +- (void)runTest:(NSString *)ident +{ + NSDate *start; + NSDate *end; + int i,j; + NSTimeInterval time = 0; + NSAutoreleasePool *pool; + BOOL makeMulti; + + pool = [[NSAutoreleasePool alloc] init]; + + makeMulti = ([ident isEqualToString: @"Make Multithreaded GS"]); + + for (i = 0; i < 100; i++) + { + start = [NSDate date]; + for (j = 0; j < NUM_ITERATIONS; j++) + { + volatile int temp; + + [lock lock]; + + temp = counter; + wait_a_while (); + + if (makeMulti && i == 49 ) + { + [NSThread detachNewThreadSelector: @selector(dummy:) + toTarget: self + withObject: nil]; + makeMulti = NO; + } + + + counter = temp + 1; + wait_a_while (); + + [lock unlock]; + } + end = [NSDate date]; + time += [end timeIntervalSinceDate: start]; + } + NSLog(@"End (%@/%@/%@):%f ", + [NSThread currentThread], ident, lock, time / 100 ); + + threadExitCounter++; + + [pool release]; +} + +-(void)createNewLockAt:(id)none +{ + [cLock lock]; + + GS_INITIALIZED_LOCK(gLock1,NSLock); + GS_INITIALIZED_LOCK(gLock2,GSLazyRecursiveLock); + + NSLog(@"Created locks: %@ %@", gLock1, gLock2); + + [cLock unlockWithCondition: YES]; +} +@end + +void +test_lazyLocks() +{ + Tester *tester; + int i; + + tester = [Tester new]; + + [tester runTest:@"empty"]; + + lock = [GSLazyLock new]; + [tester runTest:@"single GS"]; + + lock = [GSLazyRecursiveLock new]; + [tester runTest:@"single (r) GS"]; + + lock = [NSLock new]; + [tester runTest:@"single NS"]; + + lock = [NSRecursiveLock new]; + [tester runTest:@"single (r) NS"]; + + lock = [GSLazyLock new]; + [tester runTest:@"Make Multithreaded GS"]; + + /* We are now multithreaded. */ + NSCAssert1 ([lock class] == [NSLock class], + @"Class didn't morph:%@", lock); + + lock = [GSLazyLock new]; + NSCAssert1 ([lock class] == [NSLock class], + @"Returned wrong lock:%@", lock); + /* These tests actually only test NS*Lock locking, but... */ + [tester runTest:@"multi simple GS"]; + + lock = [GSLazyRecursiveLock new]; + NSCAssert1 ([lock class] == [NSRecursiveLock class], + @"Returned wrong lock:%@", lock); + [tester runTest:@"multi simple (r) GS"]; + + lock = [NSLock new]; + [tester runTest:@"multi simple NS"]; + + lock = [NSRecursiveLock new]; + [tester runTest:@"multi simple NS"]; + + /* Let's test locking anyway while we're at it. */ + for (threadExitCounter = 0, i = 0; i < 3; i++) + { + NSString *ident; + ident = [NSString stringWithFormat: @"multi complex (%d)", i]; + [NSThread detachNewThreadSelector: @selector(runTest:) + toTarget: tester + withObject: ident]; + } + + while (threadExitCounter < 3) + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 10.0]]; + + NSCAssert1 (counter == NUM_ITERATIONS * 1300, + @"Locks broken! %d", counter ); + +} + +void +test_newLockAt(void) +{ + Tester *t = [Tester new]; + + cLock = [[NSConditionLock alloc] initWithCondition: NO]; + + [NSThread detachNewThreadSelector: @selector(createNewLockAt:) + toTarget: t + withObject: nil]; + + [cLock lockWhenCondition: YES + beforeDate: [NSDate dateWithTimeIntervalSinceNow: 10.0]]; + [cLock unlock]; + + NSCAssert1([gLock1 isKindOfClass: [NSLock class]], + @"-[NSLock newLockAt:] returned %@", gLock1); + NSCAssert1([gLock2 isKindOfClass: [NSRecursiveLock class]], + @"-[GSLazyRecursiveLock newLockAt:] returned %@", gLock1); + +} + + +int +main() +{ + NSAutoreleasePool *pool; + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + pool = [[NSAutoreleasePool alloc] init]; + + test_lazyLocks(); + test_newLockAt(); + + [pool release]; + + exit(0); +} diff --git a/Testing/heap.m b/Testing/heap.m new file mode 100644 index 000000000..aedccd341 --- /dev/null +++ b/Testing/heap.m @@ -0,0 +1,63 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* Test Heap class. */ + +#include +#include +#include + +#define N 20 + +#if defined(__svr4__) || defined(__hpux) || defined(_SEQUENT_) +long lrand48(); +#define random lrand48 +#endif + +int main() +{ + int i, s; + id s1, s2; + id arp; + + Heap* heap = [Heap new]; + Array* array = [Array new]; + + arp = [NSAutoreleasePool new]; + + for (i = 0; i < N; i++) + { + s = random () % 100; + [heap addObject: [NSNumber numberWithInt: s]]; + [array addObject: [NSNumber numberWithInt: s]]; + } + [array sortContents]; + + [heap printForDebugger]; + [array printForDebugger]; + + for (i = 0; i < N; i++) + { + s1 = [heap firstObject]; + s2 = [array firstObject]; + [heap removeFirstObject]; + [array removeFirstObject]; + printf("(%d,%d) ", [s1 intValue], [s2 intValue]); + assert ([s1 intValue] == [s2 intValue]); + } + printf("\n"); + + [heap release]; + [array release]; + + [arp release]; + + exit(0); +} diff --git a/Testing/nsarchiver.m b/Testing/nsarchiver.m new file mode 100644 index 000000000..a63407b00 --- /dev/null +++ b/Testing/nsarchiver.m @@ -0,0 +1,303 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* A demonstration of writing and reading with NSArchiver */ + +#if 1 + +#include +#include +#include +#include +#include +#include +#include + +@interface ClassOne : NSObject +@end +@implementation ClassOne +- (void) encodeWithCoder: (NSCoder*)aCoder +{ +} +- (id) initWithCoder: (NSCoder*)aCoder +{ + return self; +} +@end +@interface ClassTwo : NSObject +@end +@implementation ClassTwo +- (void) encodeWithCoder: (NSCoder*)aCoder +{ +} +- (id) initWithCoder: (NSCoder*)aCoder +{ + return self; +} +@end + +typedef struct { char a; double b; char c;} tstruct; +int main() +{ + id obj; + id set; + id arp; + id arc; + id una; + id xxx; + id apl; + tstruct ss; + tstruct tt; + + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + + arp = [[NSAutoreleasePool alloc] init]; + + /* Create a Set of int's */ + set = [[NSSet alloc] initWithObjects: + @"apple", @"banana", @"carrot", @"dal", @"escarole", @"fava", + [NSValue valueWithPoint: NSMakePoint(1,1)], + [NSValue valueWithSize: NSMakeSize(11,11)], + [NSValue valueWithRange: NSMakeRange(10,2)], + [NSValue valueWithRect: NSMakeRect(11,11,22,22)], + nil]; + + /* Display the set */ + printf("Writing:\n"); + { + id o, e = [set objectEnumerator]; + while ((o = [e nextObject])) + printf("%s\n", [[o description] cString]); + } + + apl = [[NSAutoreleasePool alloc] init]; + ss.a = 'A'; + ss.b = 1.234; + ss.c = 'Z'; + arc = [[NSArchiver new] autorelease]; + [arc encodeValueOfObjCType: @encode(tstruct) at: &ss]; + una = [[[NSUnarchiver alloc] initForReadingWithData: [arc archiverData]] autorelease]; + [una decodeValueOfObjCType: @encode(tstruct) at: &tt]; + [apl release]; + if (ss.a != tt.a) printf("Encoded '%c' in 'a' but got '%c'\n", ss.a, tt.a); + if (ss.b != tt.b) printf("Encoded '%f' in 'a' but got '%f'\n", ss.b, tt.b); + if (ss.c != tt.c) printf("Encoded '%c' in 'a' but got '%c'\n", ss.c, tt.c); + + apl = [[NSAutoreleasePool alloc] init]; + arc = [[NSArchiver new] autorelease]; +printf("%u\n", [arc retainCount]); + [arc retain]; +printf("%u\n", [arc retainCount]); + [arc release]; +printf("%u\n", [arc retainCount]); + [arc encodeRootObject: set]; + una = [[[NSUnarchiver alloc] initForReadingWithData: [arc archiverData]] autorelease]; + xxx = [una decodeObject]; + if ([xxx isEqual: set] == NO) + printf("Argh\n"); + printf("%s\n", [[xxx description] cString]); + [apl release]; + + + /* Write it to a file */ + [NSArchiver archiveRootObject: set toFile: @"./nsarchiver.dat"]; + + /* Release the object that was coded */ + [set release]; + + /* Read it back in from the file */ +#if 1 + { + id d = [[NSData alloc] initWithContentsOfFile:@"./nsarchiver.dat"]; + id a = [NSUnarchiver alloc]; + a = [a initForReadingWithData:d]; + set = [a decodeObject]; + } +#else + set = [NSUnarchiver unarchiveObjectWithFile: @"./nsarchiver.dat"]; +#endif + + /* Display what we read, to make sure it matches what we wrote */ + printf("\nReading:\n"); + { + id o, e = [set objectEnumerator]; + while ((o = [e nextObject])) + printf("%s\n", [[o description] cString]); + } + + obj = [ClassOne new]; + [NSArchiver archiveRootObject: obj toFile: @"./nsarchiver.dat"]; + RELEASE(obj); + [NSUnarchiver decodeClassName: @"ClassOne" asClassName: @"ClassTwo"]; + obj = [NSUnarchiver unarchiveObjectWithFile: @"./nsarchiver.dat"]; + if ([obj isKindOfClass: [ClassTwo class]] == NO) + NSLog(@"ERROR: ClassOne decoded as %@", NSStringFromClass([obj class])); + +#if 0 +/* + * Benchmark use of very lightwight archiving - a single + * archiver/unarchiver pair using a single mutable data object to + * archive and unarchive many times. + */ + { + NSDate *start = [NSDate date]; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + int i; + NSUnarchiver *u = nil; + NSMutableData *d; + NSArchiver *a; + + d = [NSMutableData data]; + a = [[NSArchiver alloc] initForWritingWithMutableData: d]; + + [NSAutoreleasePool enableDoubleReleaseCheck:NO]; + for (i = 0; i < 10000; i++) + { + id o; + + [a encodeRootObject: set]; + if (u == nil) + { + u = [[NSUnarchiver alloc] initForReadingWithData: d]; + } + else + { + [u resetUnarchiverWithData: d atIndex: 0]; + } + o = [u decodeObject]; + [d setLength: 0]; + [a resetArchiver]; + } + [a release]; + [u release]; + [arp release]; + printf("Time: %f\n", -[start timeIntervalSinceNow]); + } +#endif + + /* Do the autorelease. */ + [arp release]; + + exit(0); +} + + +/* An old, unused test. */ +#else + +#include +#include +#include + +@interface TestClass : NSObject +{ + id next_responder; +} + +- (void)setNextResponder: anObject; +- nextResponder; +@end + +@implementation TestClass + +- (void)setNextResponder: anObject +{ + next_responder = anObject; +} + +- nextResponder +{ + return next_responder; +} + +// NSCoding protocol +- (void)encodeWithCoder:aCoder +{ + [super encodeWithCoder:aCoder]; + [aCoder encodeObjectReference:next_responder withName:@"Next Responder"]; +} + +- initWithCoder:aDecoder +{ + id d; + [super initWithCoder:aDecoder]; + [aDecoder decodeObjectAt:&next_responder withName:&d]; + return self; +} +@end + +//////////////////////////////////////// + +int main() +{ + id arp; + id r1, r2; + + arp = [[NSAutoreleasePool alloc] init]; + + // Create a simple loop + r1 = [[TestClass alloc] init]; + r2 = [[TestClass alloc] init]; + [r1 setNextResponder: r2]; + [r2 setNextResponder: r1]; + + printf("Writing\n"); + printf("%d\n", [r1 hash]); + printf("%d\n", [r2 hash]); + printf("%d\n", [[r1 nextResponder] hash]); + printf("%d\n", [[r2 nextResponder] hash]); + + /* Write it to a file */ + { + id d = [[NSMutableData alloc] init]; + id a = [[Archiver alloc] initForWritingWithMutableData: d]; + + [a startEncodingInterconnectedObjects]; + [a encodeObject: r1 withName:@"one"]; + [a encodeObject: r2 withName:@"another"]; + [a finishEncodingInterconnectedObjects]; + + [d writeToFile: @"./nsarchiver.dat" atomically:NO]; + + [d release]; + [a release]; + } + + /* Release the object that was coded */ + [r1 release]; + [r2 release]; + + /* Read it back in from the file */ + printf("\nReading:\n"); + { + id d; + id a = [Unarchiver newReadingFromFile:@"./nsarchiver.dat"]; + + [a startDecodingInterconnectedObjects]; + [a decodeObjectAt: &r1 withName:&d]; + [a decodeObjectAt: &r2 withName:&d]; + [a finishDecodingInterconnectedObjects]; + } + + /* Display what we read, to make sure it matches what we wrote */ + { + printf("%d\n", [r1 hash]); + printf("%d\n", [r2 hash]); + printf("%d\n", [[r1 nextResponder] hash]); + printf("%d\n", [[r2 nextResponder] hash]); + } + + /* Do the autorelease. */ + [arp release]; + + exit(0); +} + +#endif diff --git a/Testing/nsarray.m b/Testing/nsarray.m new file mode 100644 index 000000000..dfeab2765 --- /dev/null +++ b/Testing/nsarray.m @@ -0,0 +1,385 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include + +int compare(id elem1, id elem2, void* context) +{ + return (int)[elem1 performSelector:@selector(compare:) withObject:elem2]; +} + +int +main() +{ + id a, b, c, d, e, f, g, h; /* arrays */ + id enumerator; + id i; + id s = @"Hello World\n"; + id pool; + id o1, o2, o3; + unsigned int p; + + //behavior_set_debug(0); + + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + pool = [[NSAutoreleasePool alloc] init]; + + o1 = [NSNumber numberWithInt:1]; + o2 = [NSNumber numberWithInt:2]; + o3 = [NSNumber numberWithInt:3]; + a = [[[NSArray arrayWithObject:o1] arrayByAddingObject:o2] arrayByAddingObject:o3]; + printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]); + b = [[a copy] autorelease]; + printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]); + c = [[b mutableCopy] autorelease]; + printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]); + d = [[c copy] autorelease]; + printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]); + + // NSArray tests + { + // Class methods for allocating and initializing an array + printf("Method: +array\n"); + a = [NSArray array]; + if ([a count] == 0) + printf("Empty array count is zero\n"); + else + printf("Error: empty array count is not zero\n"); + + printf("Method: +arrayWithObject:\n"); + b = [NSArray arrayWithObject: s]; + printf("NSArray has count %d\n", [b count]); + if ([b count] != 1) + printf("Error: count != 1\n"); + + printf("Method: +arrayWithObjects:...\n"); + c = [NSArray arrayWithObjects: + [NSObject class], + [NSArray class], + [NSMutableArray class], + nil]; + printf("NSArray has count %d\n", [c count]); + if ([c count] != 3) + printf("Error: count != 3\n"); + } + + { + // Instance methods for allocating and initializing an array + printf("Method: -arrayByAddingObject:\n"); + d = [c arrayByAddingObject: s]; + printf("NSArray has count %d\n", [c count]); + if ([d count] != 4) + printf("Error: count != 4\n"); + + printf("Method: -arrayByAddingObjectsFromArray:\n"); + e = [c arrayByAddingObjectsFromArray: b]; + printf("NSArray has count %d\n", [c count]); + if ([e count] != 4) + printf("Error: count != 4\n"); + } + + { + // Querying the arra + NSCParameterAssert([c containsObject:[NSObject class]]); + + p = [e indexOfObject:@"Hello World\n"]; + if (p == NSNotFound) + printf("Error: index of object not found\n"); + else + printf("Index of object is %d\n", p); + + p = [e indexOfObjectIdenticalTo:s]; + if (p == NSNotFound) + printf("Error: index of identical object not found\n"); + else + printf("Index of identical object is %d\n", p); + + NSCParameterAssert([c lastObject]); + printf("Class at index 2 is %s\n", [[[c objectAtIndex:2] description] cString]); + + printf("Forward enumeration\n"); + enumerator = [e objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Reverse enumeration\n"); + enumerator = [e reverseObjectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + } + + { + // Sending messages to elements + [c makeObjectsPerform:@selector(description)]; + + //[c makeObjectsPerform:@selector(isEqual:) withObject: @"NSArray"]; + } + + { + // Comparing arrays + NSCParameterAssert([d firstObjectCommonWithArray:e]); + + if ([d isEqualToArray: d]) + printf("NSArray is equal to itself\n"); + else + printf("Error: NSArray is not equal to itself\n"); + + if ([d isEqualToArray: e]) + printf("NSArrays are equal\n"); + else + printf("Error: NSArrays are not equal\n"); + } + + { + // Deriving new arrays + NSRange r = NSMakeRange(0, 3); + + f = [NSMutableArray array]; + [f addObject: @"Lions"]; + [f addObject: @"Tigers"]; + [f addObject: @"Bears"]; + [f addObject: @"Penguins"]; + [f addObject: @"Giraffes"]; + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [i cString]); + printf("\n"); + + printf("Method: -sortedArrayUsingSelector:\n"); + g = [f sortedArrayUsingSelector: @selector(compare:)]; + printf("Method: -sortedArrayUsingFunction:context:\n"); + h = [f sortedArrayUsingFunction: compare context: NULL]; + + enumerator = [g objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [i cString]); + printf("\n"); + + if (([g isEqualToArray: h]) && (![g isEqualToArray: f])) + printf("Sorted arrays are correct\n"); + else + printf("Error: Sorted arrays are not correct\n"); + + printf("Method: -subarrayWithRange:\n"); + f = [e subarrayWithRange: r]; + + printf("NSArray has count %d\n", [f count]); + if ([f count] != 3) + printf("Error: count != 3\n"); + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + if ([f isEqualToArray: c]) + printf("Subarray is correct\n"); + else + printf("Error: Subarray does not have correct elements\n"); + } + + { + // Joining string elements + printf("Method: -componentsJoinedByString:\n"); + i = [c componentsJoinedByString: @"/"]; + if ([i isEqual: @"NSObject/NSArray/NSMutableArray"]) + printf("%s is correct\n", [i cString]); + else + { + printf("Error: %s is not correct\n", [i cString]); + printf("Should be NSObject/NSArray/NSMutableArray\n"); + } + } + + { + // Creating a string description of the array + /* What do the -description methods do? + [e description] + [e descriptionWithLocale:] + [e descriptionWithLocale: indent:] + */ + } + + // NSMutableArray tests + printf("*** Start of NSMutableArray tests\n"); + { + // Creating and initializing an NSMutableArray + f = [NSMutableArray arrayWithCapacity: 10]; + NSCParameterAssert(f); + f = [[NSMutableArray alloc] initWithCapacity: 10]; + [f release]; + NSCParameterAssert(f); + } + + { + // Adding objects + f = [e mutableCopy]; + NSCParameterAssert([f count]); + + printf("Method -addObject:[NSObject class]\n"); + [f addObject:[NSObject class]]; + printf("NSMutableArray has count %d\n", [f count]); + if ([f count] != 5) + printf("Error: count != 5\n"); + + printf("Method -addObjectsFromArray:\n"); + [f addObjectsFromArray: c]; + printf("NSMutableArray has count %d\n", [f count]); + if ([f count] != 8) + printf("Error: count != 8\n"); + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Method -insertObject: [NSMutableArray class] atIndex: 2\n"); + [f insertObject: [NSMutableArray class] atIndex: 2]; + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + } + + g = [f mutableCopy]; + h = [f mutableCopy]; + + { + // Removing objects + unsigned int ind[7] = {7, 4, 1, 3, 5, 0, 6}; + + printf("Method -removeAllObjects\n"); + printf("Array count is %d\n", [h count]); + [h removeAllObjects]; + printf("Array count is %d\n", [h count]); + if ([h count] != 0) + printf("Error: count != 0\n"); + + h = [f mutableCopy]; + + printf("Method -removeLastObject\n"); + [f removeLastObject]; + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Method -removeObject: [NSObject class]\n"); + [f removeObject: [NSObject class]]; + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Method -removeObjectIdenticalTo: [NSArray class]\n"); + [f removeObjectIdenticalTo: [NSArray class]]; + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Method -removeObjectAtIndex: 2\n"); + [f removeObjectAtIndex: 2]; + + enumerator = [f objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Method -removeObjectsFromIndices: {7,4,1,3,5,0,6} " + "numIndices: 6\n"); + enumerator = [g objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + [g removeObjectsFromIndices: ind numIndices: 7]; + enumerator = [g objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + if ([f isEqualToArray: g]) + printf("Remove methods worked properly\n"); + else + printf("Error: remove methods failed\n"); + + printf("Method -removeObjectsInArray:\n"); + printf("Receiver array\n"); + enumerator = [h objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + printf("Removing objects in this array\n"); + enumerator = [c objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + [h removeObjectsInArray: c]; + + printf("Array count is %d\n", [h count]); + if ([h count] != 1) + printf("Error: count != 1\n"); + + printf("%s", [[h objectAtIndex: 0] cString]); + if ([[h objectAtIndex: 0] isEqual: s]) + printf("-removeObjectsInArray: worked correctly\n"); + else + printf("Error: object in array is not correct\n"); + } + + { + // Replacing objects + c = [[c mutableCopy] autorelease]; + printf("Method -replaceObjectAtIndex: 2 withObject:[NSString class]\n"); + enumerator = [c objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + [c replaceObjectAtIndex: 2 withObject:[NSString class]]; + enumerator = [c objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + + printf("Method -setArray:\n"); + [h setArray: f]; + enumerator = [h objectEnumerator]; + while ((i = [enumerator nextObject])) + printf("%s ", [[i description] cString]); + printf("\n"); + if ([h isEqualToArray: h]) + printf("-setArray worked properly\n"); + else + printf("Error: array is incorrect\n"); + } + + { + // Sorting Elements + //[ sortUsingFunction: context:]; + //[ sortUsingSelector:]; + } + + [pool release]; + + exit(0); +} diff --git a/Testing/nsattributedstring.m b/Testing/nsattributedstring.m new file mode 100644 index 000000000..938f77839 --- /dev/null +++ b/Testing/nsattributedstring.m @@ -0,0 +1,142 @@ +/* + test.m + + Test NSAttributedString and NSMutableAttributedString classes + + Copyright (C) 1997 Free Software Foundation, Inc. + + Written by: ANOQ of the sun + Date: June 1997 + + This file is part of ... + + This library 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 2 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +*/ + +#include +#include +#include +#include +#include +#include + +// These are normally defined in the AppKit +NSString *NSFontAttributeName = @"NSFont"; +NSString *NSForegroundColorAttributeName = @"NSForegroundColor"; +NSString *NSBackgroundColorAttributeName = @"NSBackgroundColor"; + +void printAttrString(NSAttributedString *attrStr) +{ +#if 0 + NSDictionary *tmpAttrDict; + NSEnumerator *keyEnumerator; + NSString *tmpStr; + NSRange effectiveRange; + unsigned int tmpLength; + + effectiveRange = NSMakeRange(0,0); + tmpLength = [attrStr length]; + puts("Attributed string looks like this:"); + while (NSMaxRange(effectiveRange) < tmpLength) + { + tmpAttrDict = [attrStr attributesAtIndex:NSMaxRange(effectiveRange) + effectiveRange:&effectiveRange]; + printf("String: %s attributes: ",[[attrStr string] cString]); + keyEnumerator = [tmpAttrDict keyEnumerator]; + while ((tmpStr = [keyEnumerator nextObject])) + printf("%s ",[tmpStr cString]); + printf("location: %ld length: %ld\n", + (long)effectiveRange.location, + (long)effectiveRange.length); + } +#else + printf("%s\n", [[attrStr description] cString]); +#endif +} + +void testAttributedString(void) +{ + NSAttributedString *attrString; + NSMutableAttributedString *muAttrString,*muAttrString2; + NSMutableDictionary *attributes,*colorAttributes,*twoAttributes; + NSMutableAttributedString *text; + + text = [[NSMutableAttributedString alloc] initWithString: @"this is a bug"]; + [text addAttribute: @"foo" value: @"bar" range: NSMakeRange(0,4)]; + [text deleteCharactersInRange: NSMakeRange(0,1)]; + [text attribute: @"foo" atIndex: 0 effectiveRange: 0]; + + attributes = [[[NSMutableDictionary alloc] init] autorelease]; + [attributes setObject:@"Helvetica 12-point" + forKey:NSFontAttributeName]; + colorAttributes = [[[NSMutableDictionary alloc] init] autorelease]; + [colorAttributes setObject:@"black NSColor" + forKey:NSForegroundColorAttributeName]; + twoAttributes = [[[NSMutableDictionary alloc] init] autorelease]; + [twoAttributes addEntriesFromDictionary:attributes]; + [twoAttributes setObject:@"red NSColor" + forKey:NSBackgroundColorAttributeName]; + + attrString = [[NSAttributedString alloc] + initWithString:@"Attributed string test" + attributes:twoAttributes]; + [attrString autorelease]; + printAttrString(attrString); + + muAttrString = [[NSMutableAttributedString alloc] + initWithString:@"Testing the Mutable version" + attributes:colorAttributes]; + [muAttrString autorelease]; + printAttrString(muAttrString); + + [muAttrString addAttribute:NSFontAttributeName value: @"Helvetica 12-point" + range:NSMakeRange(2,4)]; + printAttrString(muAttrString); +/* + [muAttrString setAttributes:attributes + range:NSMakeRange(2,4)]; + printAttrString(muAttrString); +*/ + + [muAttrString setAttributes:attributes + range:NSMakeRange(8,16)]; + printAttrString(muAttrString); + + [muAttrString addAttributes:colorAttributes + range:NSMakeRange(5,12)]; + printAttrString(muAttrString); + + muAttrString2 = [muAttrString mutableCopy]; + printAttrString(muAttrString2); + + [muAttrString replaceCharactersInRange:NSMakeRange(5,15) + withAttributedString:attrString]; + printAttrString(muAttrString); + + [muAttrString2 replaceCharactersInRange:NSMakeRange(15,5) + withAttributedString:attrString]; + printAttrString(muAttrString2); + + printAttrString([muAttrString2 attributedSubstringFromRange:NSMakeRange(10,7)]); +} + +int +main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + testAttributedString(); + [arp release]; + exit(0); +} diff --git a/Testing/nsbundle.m b/Testing/nsbundle.m new file mode 100644 index 000000000..b704dabcf --- /dev/null +++ b/Testing/nsbundle.m @@ -0,0 +1,138 @@ +/* nsbundle - Program to test out dynamic linking via NSBundle. + Copyright (C) 1993,1994,1995, 1996 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + Written by: Adam Fedor + Date: Jul 1995 + + This file is part of the GNUstep Base Library. + +*/ +#ifndef __MINGW32__ +#include +#endif +#include "Foundation/NSArray.h" +#include "Foundation/NSBundle.h" +#include "Foundation/NSException.h" +#include "Foundation/NSString.h" +#include +#include +#include "LoadMe.h" +#include "SecondClass.h" +#include "MyCategory.h" + +int +main(int argc, char *argv[], char **env) +{ + NSBundle *bundle; + NSString *path; + id object; + NSAutoreleasePool *arp; + +#if LIB_FOUNDATION_LIBRARY || defined(GS_PASS_ARGUMENTS) + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; +#endif + arp = [NSAutoreleasePool new]; + + setbuf(stdout, 0); + /* Test bundle version and info files */ + bundle = [NSBundle bundleForLibrary: @"gnustep-base"]; + GSPrintf(stdout, @" GNUstep Base Resources: %@\n", [bundle bundlePath]); + object = [bundle infoDictionary]; + GSPrintf(stdout, @" gnustep-base version string = %@\n", + [object objectForKey: @"GSBundleShortVersionString"]); + GSPrintf(stdout, @" gnustep-base version number = %g\n\n", + [[object objectForKey: @"GSBundleVersion"] doubleValue]); + + + path = [[[NSProcessInfo processInfo] arguments] objectAtIndex: 0]; + printf(" Executable is in %s\n", [path cString]); + path = [NSBundle _absolutePathOfExecutable: path]; + if (!path) { + fprintf(stdout, "* ERROR: Can't find executable\n"); + exit(1); + } + printf(" Full directory is %s\n", [path cString]); + + printf("Looking for LoadMe bundle...\n"); + path = [path stringByDeletingLastPathComponent]; + path = [path stringByDeletingLastPathComponent]; + if ([[path lastPathComponent] isEqualToString:@"Testing"] == NO) + { + /* Delete library combo */ + path = [path stringByDeletingLastPathComponent]; + path = [path stringByDeletingLastPathComponent]; + path = [path stringByDeletingLastPathComponent]; + } + printf(" Bundle directory is %s\n", [path cString]); + path = [NSBundle pathForResource:@"LoadMe" ofType:@"bundle" + inDirectory: path]; + if (!path) { + fprintf(stdout, "* ERROR: Can't find LoadMe bundle\n"); + exit(1); + } + printf(" Found LoadMe in: %s\n\n", [path cString]); + + printf("Initializing LoadMe bundle...\n"); + bundle = [[NSBundle alloc] initWithPath:path]; + if (!bundle) { + fprintf(stdout, "* ERROR: Can't init LoadMe bundle\n"); + exit(1); + } + path = [bundle pathForResource:@"NXStringTable" ofType:@"example"]; + if (!path) { + fprintf(stdout, "* ERROR: Can't find example in LoadMe bundle\n"); + exit(1); + } + printf(" Found example file: %s\n\n", [path cString]); + + printf("Retreiving principal class...\n"); + NS_DURING + object = [bundle principalClass]; + NS_HANDLER + object = nil; + fprintf(stdout, " ERROR: %s\n", [[localException reason] cString]); + fprintf(stdout, " Either there is a problem with dynamic loading,\n"); + fprintf(stdout, " or there is no dynamic loader on your system\n"); + exit(1); + NS_ENDHANDLER + if (!object) + { + printf("* ERROR: Can't find principal class\n"); + } + else + printf(" Principal class is: %s\n", GSClassNameFromObject(object)); + + printf("Testing LoadMe bundle classes...\n"); + printf(" This is LoadMe:\n"); + object = [[[bundle classNamed:@"LoadMe"] alloc] init]; + if (!object) + { + printf("* ERROR: Can't find LoadMe class\n"); + } + else + { + [object afterLoad]; + [object release]; + } + + printf("\n This is SecondClass:\n"); + object = [[[bundle classNamed:@"SecondClass"] alloc] init]; + if (!object) + { + printf("* ERROR: Can't find SecondClass class\n"); + } + else + { + [object printName]; + [object printMyName]; + [object release]; + } + + + [arp release]; + return 0; +} diff --git a/Testing/nscharacterset.m b/Testing/nscharacterset.m new file mode 100644 index 000000000..b71162718 --- /dev/null +++ b/Testing/nscharacterset.m @@ -0,0 +1,26 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSCharacterSet *alpha = [NSCharacterSet alphanumericCharacterSet]; + + if (alpha) + printf("obtained alphanumeric character set\n"); + else + printf("unable to obtain alphanumeric character set\n"); + + [arp release]; + exit(0); +} diff --git a/Examples/nsconnection.m b/Testing/nsconnection.m similarity index 98% rename from Examples/nsconnection.m rename to Testing/nsconnection.m index d4beb5f36..591a6afde 100644 --- a/Examples/nsconnection.m +++ b/Testing/nsconnection.m @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. */ - +#define STRICT_OPENSTEP 1 #include id myServer; @@ -103,7 +103,6 @@ main(int argc, char *argv[], char **env) #endif pool = [[NSAutoreleasePool alloc] init]; - [NSConnection setDebug: YES]; [Tester startup]; [[NSRunLoop currentRunLoop] run]; [pool release]; diff --git a/Examples/nsconnection_client.m b/Testing/nsconnection_client.m similarity index 93% rename from Examples/nsconnection_client.m rename to Testing/nsconnection_client.m index e2b33af45..24c37f30d 100644 --- a/Examples/nsconnection_client.m +++ b/Testing/nsconnection_client.m @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include #include @@ -91,9 +89,10 @@ int con_data (id prx) double dbl, dblr; char *str; id obj; - small_struct ss = {12}; + small_struct small = {12}; foo ffoo = {'Z', 1234.5678, 99, "cow", 9876543}; - foo bck; + int a3[3] = {66,77,88}; + struct myarray ma = {{55,66,77}}; printf("Testing data sending\n"); @@ -204,24 +203,22 @@ int con_data (id prx) pool = [NSAutoreleasePool new]; printf("Small Struct:\n"); - //printf(" sending %x", ss.z); - //ss = [prx sendSmallStruct: ss]; - //printf(" got %x\n", ss.z); - printf(" sending ptr to %x", ss.z); - [prx getSmallStruct: &ss]; - printf(" got %x\n", ss.z); + //printf(" sending %x", small.z); + //small = [prx sendSmallStruct: small]; + //printf(" got %x\n", small.z); + printf(" sending ptr to %x", small.z); + [prx getSmallStruct: &small]; + printf(" got %x\n", small.z); [pool release]; -#if 1 || !defined(__MINGW__) +#if 1 || !defined(__MINGW32__) pool = [NSAutoreleasePool new]; printf("Struct:\n"); - memcpy(&bck, &ffoo, sizeof(bck)); printf(" sending c='%c',d=%g,i=%d,s=%s,l=%ld", ffoo.c, ffoo.d, ffoo.i, ffoo.s, ffoo.l); ffoo = [prx sendStruct: ffoo]; printf(" got c='%c',d=%g,i=%d,s=%s,l=%ld\n", ffoo.c, ffoo.d, ffoo.i, ffoo.s, ffoo.l); - memcpy(&ffoo, &bck, sizeof(bck)); printf(" sending ptr to c='%c',d=%g,i=%d,s=%s,l=%ld", ffoo.c, ffoo.d, ffoo.i, ffoo.s, ffoo.l); [prx getStruct: &ffoo]; @@ -317,7 +314,7 @@ con_messages (id prx) printf(" ok\n"); printf("performSelector:\n"); - if (prx != [prx performSelector: GSSelectorFromName("self")]) + if (prx != [prx performSelector:sel_get_any_uid("self")]) printf(" ERROR\n"); else printf(" ok\n"); @@ -505,9 +502,8 @@ int main (int argc, char *argv[], char **env) id cobj, prx; unsigned connect_attempts; NSAutoreleasePool *arp; - NSPortNameServer *ns; Auth *auth; -#if !defined(__MINGW__) +#ifndef __MINGW32__ extern int optind; extern char *optarg; #endif @@ -521,7 +517,7 @@ int main (int argc, char *argv[], char **env) debug = 0; type_test = 0; stats = 0; - while ((c = wgetopt(argc, argv, "hdtbmslocr")) != EOF) + while ((c = getopt(argc, argv, "hdtbmslocr")) != EOF) switch (c) { case 'd': @@ -577,7 +573,6 @@ int main (int argc, char *argv[], char **env) [NSObject enableDoubleReleaseCheck: YES]; } - ns = [NSSocketPortNameServer sharedInstance]; while (connect_attempts-- > 0) { if (optind < argc) @@ -585,18 +580,15 @@ int main (int argc, char *argv[], char **env) if (optind+1 < argc) prx = [NSConnection rootProxyForConnectionWithRegisteredName: [NSString stringWithCString: argv[optind+1]] - host: [NSString stringWithCString:argv[optind]] - usingNameServer: ns]; + host: [NSString stringWithCString:argv[optind]]]; else prx = [NSConnection rootProxyForConnectionWithRegisteredName: @"test2server" - host:[NSString stringWithCString:argv[optind]] - usingNameServer: ns]; + host:[NSString stringWithCString:argv[optind]]]; } else prx = [NSConnection rootProxyForConnectionWithRegisteredName: - @"test2server" host: @"" - usingNameServer: ns]; + @"test2server" host: @"*"]; if (prx == nil) { printf("ERROR: Failed to connect to server\n"); @@ -613,19 +605,7 @@ int main (int argc, char *argv[], char **env) } } -#if 1 - /* Check that we can retain the connection, release the proxy, - * and then regain the proxy from the connection. - */ - cobj = RETAIN([prx connectionForProxy]); - RELEASE(arp); - arp = [NSAutoreleasePool new]; - prx = [cobj rootProxy]; - AUTORELEASE(cobj); -#else cobj = [prx connectionForProxy]; -#endif - [cobj setDelegate:auth]; [cobj setRequestTimeout:180.0]; [cobj setReplyTimeout:180.0]; diff --git a/Examples/nsconnection_server.m b/Testing/nsconnection_server.m similarity index 95% rename from Examples/nsconnection_server.m rename to Testing/nsconnection_server.m index 78a177712..e4e04f778 100644 --- a/Examples/nsconnection_server.m +++ b/Testing/nsconnection_server.m @@ -10,8 +10,6 @@ */ #include #include -#include -#include #include #include #include @@ -291,11 +289,8 @@ - (void) getObject: (id *)str { - static NSString *ret = @"hello"; printf ("(%s) got object (%s)\n", GSNameFromSelector(_cmd), GSClassNameFromObject(*str)); - *str = ret; - printf(" returning (%s)\n", [*str cString]); fflush(stdout); } @@ -310,9 +305,8 @@ - (void) getString: (char **)str { - static char *ret = "hello"; printf ("(%s) got string (%s)", GSNameFromSelector(_cmd), *str); - *str = ret; + (*str)[0] = 'N'; printf(" returning (%s)\n", *str); fflush(stdout); } @@ -481,10 +475,8 @@ int main(int argc, char *argv[], char **env) id l; id o = [[NSObject alloc] init]; NSConnection *c; - NSPortNameServer *ns; - NSPort *port; NSAutoreleasePool *arp = [NSAutoreleasePool new]; -#if !defined(__MINGW__) +#ifndef __MINGW32__ extern int optind; extern char *optarg; #endif @@ -495,7 +487,7 @@ int main(int argc, char *argv[], char **env) [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; debug = 0; timeout = 0; - while ((i = wgetopt(argc, argv, "hdt:")) != EOF) + while ((i = getopt(argc, argv, "hdt:")) != EOF) switch (i) { case 'd': @@ -526,16 +518,13 @@ int main(int argc, char *argv[], char **env) [NSConnection setDebug: debug]; [NSObject enableDoubleReleaseCheck: YES]; } - ns = [NSSocketPortNameServer sharedInstance]; - port = [NSSocketPort port]; - c = [NSConnection connectionWithReceivePort: port sendPort: port]; + c = [NSConnection defaultConnection]; [c setRootObject: l]; if (optind < argc) - [c registerName: [NSString stringWithUTF8String: argv[optind]] - withNameServer: ns]; + [c registerName: [NSString stringWithUTF8String: argv[optind]]]; else - [c registerName: @"test2server" withNameServer: ns]; + [c registerName: @"test2server"]; [[NSNotificationCenter defaultCenter] addObserver: s diff --git a/Testing/nsdata.m b/Testing/nsdata.m new file mode 100644 index 000000000..e926639fa --- /dev/null +++ b/Testing/nsdata.m @@ -0,0 +1,486 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include +#include +#include +#include + +/****************************************************************************** +* Module : NSMutableData(NSData) --- Black Box test module for the +* *Data classes to make sure that methods that raise exceptions +* do so, and that the exceptions are raised properly. +* +* Author : John W. M. Stevens + +............................................................................... +15 April 1997 + +******************************************************************************/ + +/* Data for stuffing into *Data objects. I like printable data, as it +* gives a quick visual check mechanism, but it has the disadvantage +* of not checking for 8 bit cleanliness. +*/ +char *testString = "Test string for mutable data and archiver classes."; +char *subString = "Sub String"; + +/*----------------------------------------------------------------------------- +| Routine : TestNSMutableData() --- Create an instance of an NSMutableData +| class, initialize it with a C string (to have something +| printable for tests) and invoke the two methods that +| should raise NSRangeException exceptions using ranges that +| cross both edges of the buffer boundary. +| +| Notes : Please see work logs for discussion. +-----------------------------------------------------------------------------*/ + +void +TestNSMutableData(void) +{ + auto NSMutableData *nsMutData; + auto char *str; + auto NSRange range; + + /* Allocate and initialize an instance of an NSMutableData + * class. + */ + nsMutData = [NSMutableData dataWithLength: strlen( testString ) + 1]; + str = (char *) [nsMutData mutableBytes]; + strcpy(str, testString); + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsMutData mutableBytes]; + printf("NSMutableData Test ---------------------------------------------" + "---------------\n" + "1) String: (%s)\n", str); + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + range = NSMakeRange(-2, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(41, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length that is less than zero? */ +NS_DURING + range = NSMakeRange(6, -3.0); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + range = NSMakeRange(-2, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(41, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length less than zero? */ +NS_DURING + range = NSMakeRange(6.0, -3.0); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsMutData mutableBytes]; + printf("2) String: (%s)\n", str); + + /* Attempt to force an out of memory exception. */ +#if 0 + for ( ; ; ) + { + /* Append. */ + [nsMutData appendBytes: testString + length : strlen( testString ) + 1]; + + /* Show current value. */ + printf("%9u\r", [nsMutData length]); + } +#endif +} + +/*----------------------------------------------------------------------------- +| Routine : TestNSData() --- Create an instance of an NSData +| class, initialize it with a C string (to have something +| printable for tests) and invoke the two methods that +| should raise NSRangeException exceptions using ranges that +| cross both edges of the buffer boundary. +| +| Notes : Please see work logs for discussion. +-----------------------------------------------------------------------------*/ + +void +TestNSData(void) +{ + auto NSData *nsData; + auto NSData *newNsData; + auto char *str; + auto char bfr[128]; + auto NSRange range; + + /* Allocate and initialize an instance of an NSData + * class. + */ + nsData = [NSData dataWithBytes: testString + length : (unsigned int) strlen( testString ) + 1]; + + /* Get contents, display. */ + str = (char *) [nsData bytes]; + printf("NSData Test ----------------------------------------------------" + "---------------\n" + "1) String: (%s)\n", str); + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(-2.0, 6.0); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[6] = '\0'; + printf(" A) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get piece. */ + range = NSMakeRange(41, strlen( subString )); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" B) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" C) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about less than zero length? */ +NS_DURING + range = NSMakeRange(5.0, -4.0); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" C) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + +/*=================== subDataWithRange ======================================*/ + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(-2.0, 6.0); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[6] = '\0'; + printf(" D) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(41, strlen( subString )); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" E) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(42, strlen( subString )); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" F) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length less than zero? */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(9.0, -6.0); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" F) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsData bytes]; + printf("2) String: (%s)\n", str); +} + +int +main() +{ + id a; + id d; + id o; + id pool; + + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + + pool = [[NSAutoreleasePool alloc] init]; + + d = [NSData dataWithContentsOfMappedFile:@"nsdata.m"]; + if (d == nil) + printf("Unable to map file"); + printf("Mapped %d bytes\n", [d length]); + + o = [d copy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + o = [d mutableCopy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + d = [NSData dataWithContentsOfFile:@"nsdata.m"]; + if (d == nil) + printf("Unable to read file"); + printf("Read %d bytes\n", [d length]); + + o = [d copy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + o = [d mutableCopy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + d = [NSData dataWithSharedBytes: [d bytes] length: [d length]]; + if (d == nil) + printf("Unable to make shared data"); + printf("Shared data of %d bytes\n", [d length]); + + o = [d copy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + o = [d mutableCopy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + d = [NSMutableData dataWithSharedBytes: [d bytes] length: [d length]]; + if (d == nil) + printf("Unable to make mutable shared data"); + printf("Mutable shared data of %d bytes\n", [d length]); + + o = [d copy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + o = [d mutableCopy]; + printf("Copied %d bytes\n", [o length]); + [o release]; + + [d appendBytes: "Hello world" length: 11]; + printf("Extended by 11 bytes to %d bytes\n", [d length]); + + d = [NSMutableData dataWithShmID: [d shmID] length: [d length]]; + if (d == nil) + printf("Unable to make mutable data with old ID\n"); + printf("data with shmID gives data length %d\n", [d length]); + + a = [[NSArchiver new] autorelease]; + [a encodeRootObject: d]; + printf("Encoded data into archive\n"); + a = [[NSUnarchiver alloc] initForReadingWithData: [a archiverData]]; + o = [a decodeObject]; + printf("Decoded data from archive - length %d\n", [o length]); + [a release]; + + [d setCapacity: 2000000]; + printf("Set capacity of shared memory item to %d\n", [d capacity]); + + /* Test NSMutableData. */ + TestNSMutableData(); + + /* Test NSData. */ + TestNSData(); + + [pool release]; + + exit(0); +} + diff --git a/Testing/nsdate.m b/Testing/nsdate.m new file mode 100644 index 000000000..ad6fd59d0 --- /dev/null +++ b/Testing/nsdate.m @@ -0,0 +1,347 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include + +#ifdef __MS_WIN32__ +int _MB_init_runtime() +{ + libobjc_init_runtime(); + gnustep_base_init_runtime(); + nsdate_init_runtime(); + return 0; +} +#endif + +#define DESCRIP(obj) [obj description] +#define DESCRIP_FORMAT(obj) [obj descriptionWithCalendarFormat: nil] + +int +main() +{ + id a, b, c, e; /* dates */ + id pool; + + //behavior_set_debug(0); + pool = [[NSAutoreleasePool alloc] init]; + + NSLog(@"%@", [NSCalendarDate distantFuture]); + NSLog(@"%@", [NSCalendarDate distantPast]); + NSLog(@"%@", [NSCalendarDate dateWithNaturalLanguageString: @"01-08-2002 00:00:00"]); + NSLog(@"%@", [NSCalendarDate dateWithNaturalLanguageString: @"31-08-2002 23:59:59"]); + +if ([(NSDate*) [NSCalendarDate date] compare: + [NSCalendarDate dateWithString:@"Feb 2 00:00:00 2001" + calendarFormat:@"%b %d %H:%M:%S %Y"]] == NSOrderedDescending) { + + NSLog(@"This version of the PostgreSQL Adaptor will expire soon.\nVisit ¬http://www.turbocat.de/ to learn how to get a new one."); + } + + // NSDate tests + printf("NSDate tests\n"); + { + // Create NSDate instances + a = [NSDate date]; + printf("+[date] -- %s\n", [DESCRIP(a) cString]); + b = [NSDate dateWithTimeIntervalSinceNow: 0]; + printf("+[dateWithTimeIntervalSinceNow: 0] -- %s\n", + [DESCRIP(b) cString]); + b = [NSDate dateWithTimeIntervalSinceNow: 600]; + printf("+[dateWithTimeIntervalSinceNow: 600] -- %s\n", + [DESCRIP(b) cString]); + b = [NSDate dateWithTimeIntervalSince1970: 0]; + printf("+[dateWithTimeIntervalSince1970: 0] -- %s\n", + [DESCRIP(b) cString]); + b = [NSDate dateWithTimeIntervalSince1970: -600]; + printf("+[dateWithTimeIntervalSince1970: -600] -- %s\n", + [DESCRIP(b) cString]); + b = [NSDate dateWithTimeIntervalSinceReferenceDate: 0]; + printf("+[dateWithTimeIntervalSinceReferenceDate: 0] -- %s\n", + [DESCRIP(b) cString]); + b = [NSDate dateWithTimeIntervalSinceReferenceDate: 300]; + printf("+[dateWithTimeIntervalSinceReferenceDate: 300] -- %s\n", + [DESCRIP(b) cString]); + b = [NSDate dateWithTimeIntervalSinceNow: 24*60*40]; + printf("+[dateWithTimeIntervalSinceNow: 0] -- %s\n", + [DESCRIP(b) cString]); + + // Comparisons + + if ([a compare: [NSDate distantFuture]] == NSOrderedAscending) + printf("Current date is before distantFuture\n"); + else + printf("ERROR: Current date is *not* before distantFuture\n"); + + if ([a compare: [NSDate distantPast]] == NSOrderedDescending) + printf("Current date is after distantPast\n"); + else + printf("ERROR: Current date is *not* after distantPast\n"); + + c = [a earlierDate: b]; + if (c == a) + printf("%s is earlier than %s\n", [DESCRIP(a) cString], + [DESCRIP(b) cString]); + else + printf("ERROR: %s is not earlier than %s\n", [DESCRIP(a) cString], + [DESCRIP(b) cString]); + + c = [a laterDate: b]; + if (c == b) + printf("%s is later than %s\n", [DESCRIP(b) cString], + [DESCRIP(a) cString]); + else + printf("ERROR: %s is not later than %s\n", [DESCRIP(b) cString], + [DESCRIP(a) cString]); + } + + // NSCalendarDate tests + printf("NSCalendarDate tests\n"); + { + NSCalendarDate *c1; + NSTimeZone *gb = [NSTimeZone timeZoneWithName: @"GB"]; + int m, y, d, a; + + // Create an NSCalendarDate with current date and time + c = [NSCalendarDate calendarDate]; + printf("+[calendarDate] -- %s\n", [DESCRIP_FORMAT(c) cString]); + printf("-[dayOfMonth] %d\n", [c dayOfMonth]); + printf("-[dayOfWeek] %d\n", [c dayOfWeek]); + printf("-[dayOfYear] %d\n", [c dayOfYear]); + printf("-[hourOfDay] %d\n", [c hourOfDay]); + printf("-[monthOfYear] %d\n", [c monthOfYear]); + printf("-[yearOfCommonEra] %d\n", [c yearOfCommonEra]); + + a = [c absoluteGregorianDay: 9 month: 10 year: 1996]; + printf("%d-%d-%d is Gregorian absolute %d\n", 9, 10, 1996, a); + printf("-[dayOfCommonEra] %d\n", [c dayOfCommonEra]); + printf("-[timeIntervalSinceReferenceDate] %f\n", + [c timeIntervalSinceReferenceDate]); + + a = [c absoluteGregorianDay: 1 month: 1 year: 2001]; + printf("%d-%d-%d is Gregorian absolute %d\n", 1, 1, 2001, a); + [c gregorianDateFromAbsolute: a day: &d month: &m year: &y]; + printf("Gregorian absolute %d is %d-%d-%d\n", a, d, m, y); + + c = [NSCalendarDate dateWithString: @"1996-10-09 0:00:01" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("calendar date %s\n", [DESCRIP_FORMAT(c) cString]); + printf("-[dayOfCommonEra] %d\n", [c dayOfCommonEra]); + printf("-[dayOfMonth] %d\n", [c dayOfMonth]); + printf("-[dayOfWeek] %d\n", [c dayOfWeek]); + printf("-[dayOfYear] %d\n", [c dayOfYear]); + printf("-[hourOfDay] %d\n", [c hourOfDay]); + printf("-[minuteOfHour] %d\n", [c minuteOfHour]); + printf("-[monthOfYear] %d\n", [c monthOfYear]); + printf("-[secondOfMinute] %d\n", [c secondOfMinute]); + printf("-[yearOfCommonEra] %d\n", [c yearOfCommonEra]); + printf("-[timeIntervalSinceReferenceDate] %f\n", + [c timeIntervalSinceReferenceDate]); + e = [NSCalendarDate dateWithString: @"1996-10-09 0:00:0" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("calendar date %s\n", [[e description] cString]); + printf("-[timeIntervalSinceReferenceDate] %f\n", + [e timeIntervalSinceReferenceDate]); + printf("NSCalendrical time tests\n"); + { + NSCalendarDate *momsBDay = [NSCalendarDate dateWithYear:1936 + month:1 day:8 hour:7 minute:30 second:0 + timeZone:[NSTimeZone timeZoneWithName:@"EST"]]; + NSCalendarDate *dob = [NSCalendarDate dateWithYear:1965 + month:12 day:7 hour:17 minute:25 second:0 + timeZone:[NSTimeZone timeZoneWithName:@"EST"]]; + int years, months, days; + + [dob years:&years months:&months days:&days hours:0 + minutes:0 seconds:0 sinceDate:momsBDay]; + printf("%d, %d, %d\n", years, months, days); + [dob years:0 months:&months days:&days hours:0 + minutes:0 seconds:0 sinceDate:momsBDay]; + printf("%d, %d\n", months, days); + } + + printf("\nY2K checks\n"); + c = [NSCalendarDate dateWithString: @"1999-12-31 23:59:59" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("Start at %s\n", [DESCRIP_FORMAT(c) cString]); + printf("YYYY-MM-DD %d-%d-%d\n", [c yearOfCommonEra], [c monthOfYear], [c dayOfMonth]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add one second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add another second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:1 minute:0 second:0]; + printf("Add an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-2 minute:0 second:0]; + printf("Subtract two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + + printf("\nY2K is a leap year checks\n"); + c = [NSCalendarDate dateWithString: @"2000-2-28 23:59:59" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("Start at %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add one second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add another second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:1 minute:0 second:0]; + printf("Add an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-2 minute:0 second:0]; + printf("Subtract two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:5 minute:0 second:0]; + printf("Add five hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:1 month:0 day:0 hour:0 minute:0 second:0]; + printf("Add one year - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:-1 hour:0 minute:0 second:0]; + printf("Subtract one day - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:1 month:0 day:1 hour:0 minute:0 second:0]; + printf("Add a year and a day - %s\n", [DESCRIP_FORMAT(c) cString]); + + printf("\n2004 is a leap year checks\n"); + c = [NSCalendarDate dateWithString: @"2004-2-28 23:59:59" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("Start at %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add one second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add another second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:1 minute:0 second:0]; + printf("Add an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-2 minute:0 second:0]; + printf("Subtract two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + + printf("\n2100 is NOT a leap year checks\n"); + c = [NSCalendarDate dateWithString: @"2100-2-28 23:59:59" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("Start at %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add one second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:0 minute:0 second:1]; + printf("Add another second - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:1 minute:0 second:0]; + printf("Add an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-2 minute:0 second:0]; + printf("Subtract two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + + c = [NSCalendarDate dateWithString: @"2002-03-31 00:30:00 GB" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"]; + printf("\nSavings time begins at %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:1 minute:0 second:0]; + printf("Add an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-1 minute:0 second:0]; + printf("Subtract an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:2 minute:0 second:0]; + printf("Add two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-2 minute:0 second:0]; + printf("Subtract two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:3 minute:0 second:0]; + printf("Add three hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-4 minute:0 second:0]; + printf("Subtract four hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:3 minute:0 second:0]; + printf("Add three hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-4 minute:0 second:0]; + printf("Subtract four hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:4 minute:0 second:0]; + printf("Add four hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-24 minute:0 second:0]; + printf("Subtract twentyfour hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:24 minute:0 second:0]; + printf("Add twentyfour hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:-1 hour:0 minute:0 second:0]; + printf("Subtract a day - %s\n", [DESCRIP_FORMAT(c) cString]); + + c = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00 GB" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"]; + printf("\nSavings time ends at %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:1 minute:0 second:0]; + printf("Add an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-1 minute:0 second:0]; + printf("Subtract an hour - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:2 minute:0 second:0]; + printf("Add two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-2 minute:0 second:0]; + printf("Subtract two hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:3 minute:0 second:0]; + printf("Add three hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-4 minute:0 second:0]; + printf("Subtract four hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:3 minute:0 second:0]; + printf("Add three hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-4 minute:0 second:0]; + printf("Subtract four hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:4 minute:0 second:0]; + printf("Add four hours - %s\n", [DESCRIP_FORMAT(c) cString]); + c = [c addYear:0 month:0 day:0 hour:-24 minute:0 second:0]; + printf("Subtract twentyfour hours - %s\n", [DESCRIP_FORMAT(c) cString]); + + c = [NSCalendarDate dateWithYear: 2002 month: 3 day: 31 hour: 1 minute: 30 second: 0 timeZone: gb]; + printf("Build at %s\n", [[c description] cString]); + + c = [NSCalendarDate dateWithString: @"2002-09-27 01:59:00" + calendarFormat: @"%Y-%m-%d %H:%M:%S"]; + printf("Start at %s\n", [DESCRIP_FORMAT(c) cString]); + c1 = [c dateByAddingYears: 0 + months: 0 + days: -180 + hours: 0 + minutes: 0 + seconds: 0]; + printf("Subtract 180 %s\n", [DESCRIP_FORMAT(c1) cString]); + + printf("Week of year tests ... "); + if ([[NSCalendarDate dateWithYear: 2002 month: 12 day: 29 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 52) + printf("Failed on 2002/12/29 is week 52\n"); + if ([[NSCalendarDate dateWithYear: 2002 month: 12 day: 30 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2002/12/30 is week 1\n"); + if ([[NSCalendarDate dateWithYear: 2002 month: 12 day: 31 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2002/12/31 is week 1\n"); + if ([[NSCalendarDate dateWithYear: 2003 month: 1 day: 1 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2003/01/01 is week 1\n"); + else if ([[NSCalendarDate dateWithYear: 2003 month: 1 day: 2 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2003/01/02 is week 1\n"); + else if ([[NSCalendarDate dateWithYear: 2003 month: 1 day: 3 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2003/01/03 is week 1\n"); + else if ([[NSCalendarDate dateWithYear: 2003 month: 1 day: 4 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2003/01/04 is week 1\n"); + else if ([[NSCalendarDate dateWithYear: 2003 month: 1 day: 5 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 1) + printf("Failed on 2003/01/05 is week 1\n"); + else if ([[NSCalendarDate dateWithYear: 2003 month: 1 day: 6 hour: 0 + minute: 0 second: 0 timeZone: gb] weekOfYear] != 2) + printf("Failed on 2003/01/06 is week 2\n"); + else + printf("All passed\n"); + + + c = [NSCalendarDate dateWithString: @"2004-05-30 00:30:00 HPT" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"]; + c1 = [NSCalendarDate dateWithString: @"2004-05-30 00:30:00 HST" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"]; + printf("date with time zone abbr %s\n", [[c description] cString]); + if ([c isEqual: c1]) + printf("Passed date with time zone abbreviation\n"); + else + printf("Failed date with time zone abbreviation\n"); + + } + + [pool release]; + + exit(0); +} diff --git a/Testing/nsdictionary.m b/Testing/nsdictionary.m new file mode 100644 index 000000000..73e5a0ca0 --- /dev/null +++ b/Testing/nsdictionary.m @@ -0,0 +1,207 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char** argv, char** envp) +{ + NSString *strs[100000]; + NSMutableDictionary *dict; + NSDate *when; + int i, j; + NSAutoreleasePool *arp; + id a, b; /* dictionaries */ + id enumerator; + id objects, keys; + id key; + BOOL ok; + id o1, o2, o3, o4, o5, o6; + NSMutableDictionary *d1, *d2; + + arp = [NSAutoreleasePool new]; + + o1 = [[NSNumber numberWithInt:1] stringValue]; + o2 = [[NSNumber numberWithInt:2] stringValue]; + o3 = [[NSNumber numberWithInt:3] stringValue]; + o4 = [[NSNumber numberWithInt:4] stringValue]; + o5 = [[NSNumber numberWithInt:5] stringValue]; + o6 = [[NSNumber numberWithInt:6] stringValue]; + + d1 = [[NSMutableDictionary new] autorelease]; + [d1 setObject:o1 forKey:o1]; + [d1 setObject:o2 forKey:o2]; + [d1 setObject:o3 forKey:o3]; + + d2 = [[NSMutableDictionary new] autorelease]; + [d2 setObject:o4 forKey:o4]; + [d2 setObject:o5 forKey:o5]; + [d2 setObject:o6 forKey:o6]; + + [d1 addEntriesFromDictionary: d2]; + + enumerator = [d1 objectEnumerator]; + while ((b = [enumerator nextObject])) + printf("%s ", [b cString]); + printf("\n"); + + //behavior_set_debug(0); + + objects = [NSArray arrayWithObjects: + @"vache", @"poisson", @"cheval", @"poulet", nil]; + keys = [NSArray arrayWithObjects: + @"cow", @"fish", @"horse", @"chicken", nil]; + a = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; + b = [NSDictionary dictionaryWithObjectsAndKeys: + @"vache", + @"cow", + @"poisson", + @"fish", + @"cheval", + @"horse", + @"poulet", + @"chicken", nil]; + + printf("Match is %d\n", [a isEqual: b]); + + printf("NSDictionary has count %d\n", [a count]); + key = @"fish"; + printf("Object at key %s is %s\n", + [key cString], + [[a objectForKey:key] cString]); + + assert([a count] == [[a allValues] count]); + + enumerator = [a objectEnumerator]; + while ((b = [enumerator nextObject])) + printf("%s ", [b cString]); + printf("\n"); + + enumerator = [a keyEnumerator]; + while ((b = [enumerator nextObject])) + printf("%s ", [b cString]); + printf("\n"); + + b = [a mutableCopy]; + assert([b count]); + + ok = [b isEqual: a]; + assert(ok); + + [b setObject:@"formi" forKey:@"ant"]; + [b removeObjectForKey:@"horse"]; + + + when = [NSDate date]; + dict = [NSMutableDictionary dictionaryWithCapacity: 100]; + for (i = 0; i < 10; i++) + { + strs[i] = [NSString stringWithFormat: @"Dictkey-%d", i]; + [dict setObject: strs[i] forKey: strs[i]]; + } + printf(" 10 creation: %f\n", [[NSDate date] timeIntervalSinceDate: when]); +printf("%s\n", [[[dict allKeys] description] cString]); + + when = [NSDate date]; + for (i = 0; i < 100000; i++) { + for (j = 0; j < 10; j++) { + NSString *val = [dict objectForKey: strs[j]]; + } + } + printf(" 10 For: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + [arp release]; + + arp = [NSAutoreleasePool new]; + + when = [NSDate date]; + dict = [NSMutableDictionary dictionaryWithCapacity: 100]; + for (i = 0; i < 100; i++) + { + strs[i] = [NSString stringWithFormat: @"Dictkey-%d", i]; + [dict setObject: strs[i] forKey: strs[i]]; + } + printf(" 100 creation: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + + when = [NSDate date]; + for (i = 0; i < 10000; i++) { + for (j = 0; j < 100; j++) { + NSString *val = [dict objectForKey: strs[j]]; + } + } + printf(" 100 For: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + [arp release]; + + arp = [NSAutoreleasePool new]; + + when = [NSDate date]; + dict = [NSMutableDictionary dictionaryWithCapacity: 1000]; + for (i = 0; i < 1000; i++) + { + strs[i] = [NSString stringWithFormat: @"Dictkey-%d", i]; + [dict setObject: strs[i] forKey: strs[i]]; + } + printf(" 1000 creation: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + + when = [NSDate date]; + for (i = 0; i < 1000; i++) { + for (j = 0; j < 1000; j++) { + NSString *val = [dict objectForKey: strs[j]]; + } + } + printf(" 1000 For: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + [arp release]; + + arp = [NSAutoreleasePool new]; + + when = [NSDate date]; + dict = [NSMutableDictionary dictionaryWithCapacity: 10000]; + for (i = 0; i < 10000; i++) + { + strs[i] = [NSString stringWithFormat: @"Dictkey-%d", i]; + [dict setObject: strs[i] forKey: strs[i]]; + } + printf(" 10000 creation: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + + when = [NSDate date]; + for (i = 0; i < 100; i++) { + for (j = 0; j < 10000; j++) { + NSString *val = [dict objectForKey: strs[j]]; + } + } + printf(" 10000 For: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + [arp release]; + + arp = [NSAutoreleasePool new]; + + when = [NSDate date]; + dict = [NSMutableDictionary dictionaryWithCapacity: 100000]; + for (i = 0; i < 100000; i++) + { + strs[i] = [NSString stringWithFormat: @"Dictkey-%d", i]; + [dict setObject: strs[i] forKey: strs[i]]; + } + printf("100000 creation: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + + when = [NSDate date]; + for (i = 0; i < 10; i++) { + for (j = 0; j < 100000; j++) { + NSString *val = [dict objectForKey: strs[j]]; + } + } + printf("100000 For: %f\n", [[NSDate date] timeIntervalSinceDate: when]); + + exit(0); +} diff --git a/Testing/nsfilehandle.m b/Testing/nsfilehandle.m new file mode 100644 index 000000000..88c5a28e9 --- /dev/null +++ b/Testing/nsfilehandle.m @@ -0,0 +1,66 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include +#include +#include + +int +main () +{ + id pool; + id src; + id dst; + id d0; + id d1; + + pool = [[NSAutoreleasePool alloc] init]; + + src = [[NSFileHandle fileHandleForReadingAtPath:@"nsfilehandle.m"] retain]; + assert(src != nil); + dst = [[NSFileHandle fileHandleForWritingAtPath:@"nsfilehandle.dat"] retain]; + if (dst == nil) + { + creat("nsfilehandle.dat", 0644); + dst = [[NSFileHandle fileHandleForWritingAtPath:@"nsfilehandle.dat"] retain]; + } + assert(dst != nil); + + d0 = [[src readDataToEndOfFile] retain]; + [(NSFileHandle*)dst writeData: d0]; + [src release]; + [dst release]; + [pool release]; + + pool = [[NSAutoreleasePool alloc] init]; + src = [[NSFileHandle fileHandleForReadingAtPath:@"nsfilehandle.dat"] retain]; + d1 = [[src readDataToEndOfFile] retain]; + [src release]; + [pool release]; + + unlink("nsfilehandle.dat"); + + if ([d0 isEqual:d1]) + printf("Test passed (length:%d)\n", [d1 length]); + else + printf("Test failed\n"); + + pool = [[NSAutoreleasePool alloc] init]; + src = [NSURL URLWithString: @"http://www.w3.org/index.html"]; + d0 = [src resourceDataUsingCache: NO]; + NSLog(@"Data is %@", d0); + [pool release]; + + exit (0); +} diff --git a/Testing/nsfilemanager.m b/Testing/nsfilemanager.m new file mode 100644 index 000000000..5707eb9a3 --- /dev/null +++ b/Testing/nsfilemanager.m @@ -0,0 +1,86 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include + +static int errors = 0; + +@interface Handler : NSObject +- (BOOL) fileManager: (NSFileManager*)manager +shouldProceedAfterError: (NSString*)error; +- (BOOL) fileManager: (NSFileManager*)manager +willProcessPath: (NSString*)path; +@end + +@implementation Handler +- (BOOL) fileManager: (NSFileManager*)manager +shouldProceedAfterError: (NSString*)error +{ + NSLog(@"Error - %@", error); + errors++; + return NO; +} +- (BOOL) fileManager: (NSFileManager*)manager +willProcessPath: (NSString*)path +{ + NSLog(@"Processing %@", path); + errors++; + return NO; +} +@end + +int +main () +{ + CREATE_AUTORELEASE_POOL(arp); + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSFileManager *mgr = [NSFileManager defaultManager]; + NSString *src; + NSString *dst; + Handler *handler = AUTORELEASE([Handler new]); + + src = [defs stringForKey: @"CopySrc"]; + dst = [defs objectForKey: @"CopyDst"]; + if (src != nil && dst != nil) + { + if ([mgr copyPath: src toPath: dst handler: handler] == NO) + { + NSLog(@"Copy %@ to %@ failed", src, dst); + errors++; + } + } + + src = [defs stringForKey: @"LinkSrc"]; + dst = [defs objectForKey: @"LinkDst"]; + if (src != nil && dst != nil) + { + if ([mgr linkPath: src toPath: dst handler: handler] == NO) + { + NSLog(@"Link %@ to %@ failed", src, dst); + errors++; + } + } + + src = [defs stringForKey: @"Remove"]; + if (src != nil) + { + if ([mgr removeFileAtPath: src handler: handler] == NO) + { + NSLog(@"Remove %@ failed", src); + errors++; + } + + } + + RELEASE(arp); + if (errors == 0) + printf("Tests passed\n"); + exit (0); +} diff --git a/Testing/nshashtable.m b/Testing/nshashtable.m new file mode 100644 index 000000000..f0d90dab7 --- /dev/null +++ b/Testing/nshashtable.m @@ -0,0 +1,72 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include + +int main () +{ + NSHashTable *ht; + NSHashEnumerator he; + int i; + void *v; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + /* Test with ints */ + + ht = NSCreateHashTable (NSIntHashCallBacks, 0); + + for (i = 1; i < 16; i++) + NSHashInsert (ht, (void*)i); + + NSHashRemove (ht, (void*)3); + + he = NSEnumerateHashTable (ht); + while ((v = NSNextHashEnumeratorItem (&he))) + printf ("(%d) ", (int)v); + printf ("\n"); + + NSFreeHashTable (ht); + + +#if 0 + /* Test with NSNumber objects */ + + mt = NSCreateHashTable (NSObjectHashKeyCallBacks, + NSObjectHashValueCallBacks, + 0); + + for (i = 0; i < 16; i++) + NSHashInsert (mt, + [NSNumber numberWithInt: i], + [NSNumber numberWithInt: i*i]); + + o = [NSNumber numberWithInt: 3]; + printf ("value for key %s is %s\n", + [[o description] cString], + [[(id)NSHashGet (mt, o) description] cString]); + NSHashRemove (mt, o); + printf ("after removing: value for key %s is %s\n", + [[o description] cString], + [[(id)NSHashGet (mt, o) description] cString]); + + me = NSEnumerateHashTable (mt); + while (NSNextHashEnumeratorPair (&me, &k, &v)) + printf ("(%d,%d) ", [(id)k intValue], [(id)v intValue]); + printf ("\n"); + + NSFreeHashTable (mt); +#endif + + [arp release]; + exit (0); +} diff --git a/Testing/nshost.m b/Testing/nshost.m new file mode 100644 index 000000000..3c876729f --- /dev/null +++ b/Testing/nshost.m @@ -0,0 +1,71 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +// Fri Oct 23 03:02:52 MET DST 1998 dave@turbocat.de + +#include +#include +#include +#include + +void +displayHost(NSHost* h) +{ + NSArray* a; + int i; + + printf("\n"); + a = [h names]; + for (i = 0; i < [a count]; i++) + printf("%s\n", [[a objectAtIndex:i] cString]); + a = [h addresses]; + for (i = 0; i < [a count]; i++) + printf("%s\n", [[a objectAtIndex:i] cString]); +} + +int +main () +{ + NSHost* a; + NSHost* c; + NSHost* n; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + [NSAutoreleasePool enableDoubleReleaseCheck:YES]; + c = [NSHost currentHost]; + displayHost(c); + n = [NSHost hostWithName:[c name]]; + displayHost(n); + a = [NSHost hostWithAddress:[c address]]; + displayHost(a); + + printf("c:%lx, n:%lx, a:%lx\n", c, n, a); + printf("c isEqual: n ... %d\n", [c isEqual: n]); + printf("n isEqual: c ... %d\n", [n isEqual: c]); + printf("c isEqual: a ... %d\n", [c isEqual: a]); + printf("a isEqual: c ... %d\n", [a isEqual: c]); + printf("n isEqual: a ... %d\n", [n isEqual: a]); + printf("a isEqual: n ... %d\n", [a isEqual: n]); + + [NSHost setHostCacheEnabled:NO]; + + n = [NSHost hostWithName:[c name]]; + displayHost(n); + printf("c:%lx, n:%lx, a:%lx\n", c, n, a); + printf("c isEqual: n ... %d\n", [c isEqual: n]); + printf("n isEqual: c ... %d\n", [n isEqual: c]); + printf("c isEqual: a ... %d\n", [c isEqual: a]); + printf("a isEqual: c ... %d\n", [a isEqual: c]); + printf("n isEqual: a ... %d\n", [n isEqual: a]); + printf("a isEqual: n ... %d\n", [a isEqual: n]); + + [arp release]; + exit (0); +} diff --git a/Testing/nsindexset.m b/Testing/nsindexset.m new file mode 100644 index 000000000..c385da8a8 --- /dev/null +++ b/Testing/nsindexset.m @@ -0,0 +1,221 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include + +int +main () +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSIndexSet *s; + NSMutableIndexSet *m; + NSMutableIndexSet *o; + unsigned int buf[2]; + NSRange r; + + printf("Can create empty set ..."); + s = [NSIndexSet indexSet]; + printf(" %s\n", s != nil ? "passed" : "failed"); + + printf("Empty set count is 0 ..."); + printf(" %s\n", [s count] == 0 ? "passed" : "failed"); + + printf("Empty set does not contain index 0 ..."); + printf(" %s\n", [s containsIndex: 0] == NO ? "passed" : "failed"); + + printf("Empty set does not intersect indexes in range 0->NSNotFound-1 ..."); + printf(" %s\n", [s intersectsIndexesInRange: NSMakeRange(0,NSNotFound-1)] == NO ? "passed" : "failed"); + + printf("Empty set first index is NSNotFound..."); + printf(" %s\n", [s firstIndex] == NSNotFound ? "passed" : "failed"); + + printf("Empty set last index is NSNotFound..."); + printf(" %s\n", [s lastIndex] == NSNotFound ? "passed" : "failed"); + + printf("Empty set index less than 1 is NSNotFound..."); + printf(" %s\n", [s indexLessThanIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Empty set index less than or equal to 1 is NSNotFound..."); + printf(" %s\n", [s indexLessThanOrEqualToIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Empty set index greater than 1 is NSNotFound..."); + printf(" %s\n", [s indexGreaterThanIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Empty set index greater than or equal to 1 is NSNotFound..."); + printf(" %s\n", [s indexGreaterThanOrEqualToIndex: 1] == NSNotFound ? "passed" : "failed"); + + printf("Empty set getIndexes gives 0..."); + r = NSMakeRange(0, NSNotFound-1); + printf(" %s\n", [s getIndexes: buf maxCount:3 inIndexRange: &r] == 0 ? "passed" : "failed"); + + + printf("Can create single index set with 2 ..."); + s = [NSIndexSet indexSetWithIndex: 2]; + printf(" %s\n", s != nil ? "passed" : "failed"); + + printf("Set count is 1 ..."); + printf(" %s\n", [s count] == 1 ? "passed" : "failed"); + + printf("Set does not contain index 0 ..."); + printf(" %s\n", [s containsIndex: 0] == NO ? "passed" : "failed"); + + printf("Set contains index 2 ..."); + printf(" %s\n", [s containsIndex: 2] == YES ? "passed" : "failed"); + + printf("Set intersects indexes in range 0->NSNotFound-1 ..."); + printf(" %s\n", [s intersectsIndexesInRange: NSMakeRange(0,NSNotFound-1)] == YES ? "passed" : "failed"); + + printf("Set first index is 2..."); + printf(" %s\n", [s firstIndex] == 2 ? "passed" : "failed"); + + printf("Set last index is 2..."); + printf(" %s\n", [s lastIndex] == 2 ? "passed" : "failed"); + + printf("Set index less than 1 is NSNotFound..."); + printf(" %s\n", [s indexLessThanIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Set index less than or equal to 1 is NSNotFound..."); + printf(" %s\n", [s indexLessThanOrEqualToIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Set index less than 2 is NSNotFound..."); + printf(" %s\n", [s indexLessThanIndex: 2] == NSNotFound ? "passed" : "failed"); + printf("Set index less than or equal to 2 is 2..."); + printf(" %s\n", [s indexLessThanOrEqualToIndex: 2] == 2 ? "passed" : "failed"); + printf("Set index greater than 1 is 2..."); + printf(" %s\n", [s indexGreaterThanIndex: 1] == 2 ? "passed" : "failed"); + printf("Set index greater than or equal to 1 is 2..."); + printf(" %s\n", [s indexGreaterThanOrEqualToIndex: 1] == 2 ? "passed" : "failed"); + printf("Set index greater than 2 is NSNotFound..."); + printf(" %s\n", [s indexGreaterThanIndex: 2] == NSNotFound ? "passed" : "failed"); + printf("Set index greater than or equal to 2 is 2..."); + printf(" %s\n", [s indexGreaterThanOrEqualToIndex: 2] == 2 ? "passed" : "failed"); + + printf("Set getIndexes gives 1..."); + r = NSMakeRange(0, NSNotFound-1); + printf(" %s\n", [s getIndexes: buf maxCount:3 inIndexRange: &r] == 1 ? "passed" : "failed"); + + + printf("Can create multipe index set with range 2...5 ..."); + s = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(2,4)]; + printf(" %s\n", s != nil ? "passed" : "failed"); + + printf("Set count is 4 ..."); + printf(" %s\n", [s count] == 4 ? "passed" : "failed"); + + printf("Set does not contain index 0 ..."); + printf(" %s\n", [s containsIndex: 0] == NO ? "passed" : "failed"); + + printf("Set contains index 2 ..."); + printf(" %s\n", [s containsIndex: 2] == YES ? "passed" : "failed"); + + printf("Set contains index 5 ..."); + printf(" %s\n", [s containsIndex: 5] == YES ? "passed" : "failed"); + + printf("Set intersects indexes in range 0->NSNotFound-1 ..."); + printf(" %s\n", [s intersectsIndexesInRange: NSMakeRange(0,NSNotFound-1)] == YES ? "passed" : "failed"); + + printf("Set first index is 2..."); + printf(" %s\n", [s firstIndex] == 2 ? "passed" : "failed"); + + printf("Set last index is 5..."); + printf(" %s\n", [s lastIndex] == 5 ? "passed" : "failed"); + + printf("Set index less than 1 is NSNotFound..."); + printf(" %s\n", [s indexLessThanIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Set index less than or equal to 1 is NSNotFound..."); + printf(" %s\n", [s indexLessThanOrEqualToIndex: 1] == NSNotFound ? "passed" : "failed"); + printf("Set index less than 2 is NSNotFound..."); + printf(" %s\n", [s indexLessThanIndex: 2] == NSNotFound ? "passed" : "failed"); + printf("Set index less than or equal to 2 is 2..."); + printf(" %s\n", [s indexLessThanOrEqualToIndex: 2] == 2 ? "passed" : "failed"); + printf("Set index greater than 1 is 2..."); + printf(" %s\n", [s indexGreaterThanIndex: 1] == 2 ? "passed" : "failed"); + printf("Set index greater than or equal to 1 is 2..."); + printf(" %s\n", [s indexGreaterThanOrEqualToIndex: 1] == 2 ? "passed" : "failed"); + printf("Set index greater than 2 is 3..."); + printf(" %s\n", [s indexGreaterThanIndex: 2] == 3 ? "passed" : "failed"); + printf("Set index greater than or equal to 2 is 2..."); + printf(" %s\n", [s indexGreaterThanOrEqualToIndex: 2] == 2 ? "passed" : "failed"); + + printf("Set getIndexes gives 3..."); + r = NSMakeRange(0, NSNotFound-1); + printf(" %s\n", [s getIndexes: buf maxCount:3 inIndexRange: &r] == 3 ? "passed" : "failed"); + + printf("Set getIndexes gives 1..."); + printf(" %s\n", [s getIndexes: buf maxCount:3 inIndexRange: &r] == 1 ? "passed" : "failed"); + + + printf("Set mutableCopy works..."); + m = [[s mutableCopy] autorelease]; + printf(" %s\n", m != nil ? "passed" : "failed"); + + printf("Copy equals originals..."); + printf(" %s\n", [m isEqual: s] == YES ? "passed" : "failed"); + + printf("Can add index 10 to mutable set..."); + [m addIndex: 10]; + printf(" %s\n", [m containsIndex: 10] == YES && [m containsIndex: 9] == NO && [m containsIndex: 11] == NO ? "passed" : "failed"); + + printf("Can add index 7 to mutable set..."); + [m addIndex: 7]; + printf(" %s\n", [m containsIndex: 7] == YES && [m containsIndex: 6] == NO && [m containsIndex: 8] == NO ? "passed" : "failed"); + + printf("Can add index 8 to mutable set..."); + [m addIndex: 8]; + printf(" %s\n", [m containsIndex: 7] == YES && [m containsIndex: 8] == YES && [m containsIndex: 9] == NO ? "passed" : "failed"); + + printf("Can add index 9 to mutable set..."); + [m addIndex: 9]; + printf(" %s\n", [m containsIndex: 8] == YES && [m containsIndex: 9] == YES && [m containsIndex: 10] == YES ? "passed" : "failed"); + + printf("Can remove index 9 from mutable set..."); + [m removeIndex: 9]; + printf(" %s\n", [m containsIndex: 8] == YES && [m containsIndex: 9] == NO && [m containsIndex: 10] == YES ? "passed" : "failed"); + + printf("Can shift right by 5 from 7..."); + [m shiftIndexesStartingAtIndex: 7 by: 5]; + printf(" %s\n", [m containsIndex: 7] == NO && [m containsIndex: 12] == YES ? "passed" : "failed"); + + printf("Can shift left by 5 from 12..."); + [m shiftIndexesStartingAtIndex: 12 by: -5]; + printf(" %s\n", [m containsIndex: 7] == YES && [m containsIndex: 12] == NO ? "passed" : "failed"); + + printf("Can remove range 5-7 from mutable set..."); + [m removeIndexesInRange: NSMakeRange(5, 3)]; + printf(" %s\n", [m containsIndex: 4] == YES && [m containsIndex: 5] == NO && [m containsIndex: 8] == YES ? "passed" : "failed"); + + printf("Can remove range 0-10 from mutable set..."); + [m removeIndexesInRange: NSMakeRange(0, 11)]; + printf(" %s\n", [m isEqual: [NSIndexSet indexSet]] == YES ? "passed" : "failed"); + + o = [NSMutableIndexSet indexSet]; + [m addIndex: 3]; + [m addIndex: 4]; + [m addIndex: 6]; + [m addIndex: 7]; + [o addIndex: 3]; + [o addIndex: 7]; + printf("Can remove range 4-6 from mutable set containing 3,4,6,7 ..."); + [m removeIndexesInRange: NSMakeRange(4, 3)]; + printf(" %s\n", [m isEqual: o] == YES ? "passed" : "failed"); + + [m addIndex: 3]; + [m addIndex: 4]; + [m addIndex: 6]; + [m addIndex: 7]; + [m addIndex: 8]; + [m addIndex: 9]; + [o addIndex: 3]; + [o removeIndex: 7]; + [o addIndex: 9]; + printf("Can remove range 4-8 from mutable set containing 3,4,6,7,8,9 ..."); + [m removeIndexesInRange: NSMakeRange(4, 5)]; + printf(" %s\n", [m isEqual: o] == YES ? "passed" : "failed"); + +// NSLog(@"%@", m); + [arp release]; + exit (0); +} + diff --git a/Testing/nsinvocation.m b/Testing/nsinvocation.m new file mode 100644 index 000000000..a608ae4b2 --- /dev/null +++ b/Testing/nsinvocation.m @@ -0,0 +1,464 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include + +typedef struct { + char c; + int i; +} small; + +typedef struct { + int i; + char *s; + float f; +} large; + +@interface Target: NSObject +- (char) loopChar: (char)v; +- (double) loopDouble: (double)v; +- (float) loopFloat: (float)v; +- (int) loopInt: (int)v; +- (large) loopLarge: (large)v; +- (long) loopLong: (long)v; +- (large) loopLargePtr: (large*)v; +- (id) loopObject: (id)v; +- (short) loopShort: (short)v; +- (small) loopSmall: (small)v; +- (small) loopSmallPtr: (small*)v; +- (char*) loopString: (char*)v; + +- (double) loopMulti: (float)f int: (float)v ch: (char)c; + +- (char) retChar; +- (double) retDouble; +- (float) retFloat; +- (int) retInt; +- (large) retLarge; +- (long) retLong; +- (id) retObject; +- (short) retShort; +- (small) retSmall; +- (char*) retString; +@end + +@implementation Target +- (char) loopChar: (char)v +{ + return v+1; +} +- (double) loopDouble: (double)v +{ + return v+1.0; +} +- (float) loopFloat: (float)v +{ + return v+1.0; +} +- (int) loopInt: (int)v +{ + return v+1; +} +- (large) loopLarge: (large)v +{ + return v; +} +- (long) loopLong: (long)v +{ + return v+1; +} +- (large) loopLargePtr: (large*)v +{ + return *v; +} +- (id) loopObject: (id)v +{ + return v; +} +- (short) loopShort: (short)v +{ + return v+1; +} +- (small) loopSmall: (small)v +{ + return v; +} +- (small) loopSmallPtr: (small*)v +{ + return *v; +} +- (char*) loopString: (char*)v +{ + return v; +} + +- (double) loopMulti: (float)f int: (float)v ch: (char)c +{ + return v+1.0; +} + +- (char) retChar +{ + return (char)99; +} +- (double) retDouble +{ + return 123.456; +} +- (float) retFloat +{ + return 123.456; +} +- (int) retInt +{ + return 123456; +} +- (large) retLarge +{ + static large l = { + 99, "large", 99.99 + }; + return l; +} +- (long) retLong +{ + return 123456; +} +- (id) retObject +{ + return self; +} +- (short) retShort +{ + return 12345; +} +- (small) retSmall +{ + static small s = { + 11, 22 + }; + return s; +} +- (char*) retString +{ + return "string"; +} +@end + +@interface MyProxy : NSObject +{ + id obj; +} +- (void) forwardInvocation: (NSInvocation*)inv; +- (id) initWithTarget: (id)target; +- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector; +@end + +@implementation MyProxy +- (id) initWithTarget: (id)target +{ + obj = target; + return self; +} +- (void) forwardInvocation: (NSInvocation*)inv +{ + NSData *d = [NSArchiver archivedDataWithRootObject: inv]; + NSInvocation *i = [NSUnarchiver unarchiveObjectWithData: d]; + unsigned l; + void *b; + + [i invokeWithTarget: obj]; + d = [NSArchiver archivedDataWithRootObject: i]; + i = [NSUnarchiver unarchiveObjectWithData: d]; + l = [[i methodSignature] methodReturnLength]; + if (l < sizeof(void *)) + l = sizeof(void *); + b = (void *)objc_malloc(l); + [i getReturnValue: b]; + [inv setReturnValue: b]; + objc_free(b); +} +- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector +{ + return [obj methodSignatureForSelector: aSelector]; +} +@end + +int +main () +{ + large la; + small sm; + large tmpla; + large *laptr = &tmpla; + small tmpsm; + small *smptr = &tmpsm; + int i; + char c; + short s; + long l; + float f; + double d; + id o; + char *str; + NSInvocation *inv; + NSMethodSignature *sig; + Target *t; + id p; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + +printf("Starting\n"); + t = [Target new]; + p = [[MyProxy alloc] initWithTarget: t]; +printf("Calling proxy\n"); +[p loopInt: 1]; + + printf("Testing NS_MESSAGE ... "); + inv = NS_MESSAGE(t, loopInt: 5); + [inv invoke]; + [inv getReturnValue: &i]; + if (i == 6) + printf("OK\n"); + else + printf("ERROR ... expecting 6 and got %d\n", i); + + printf("Testing NS_INVOCATION ... "); + inv = NS_INVOCATION([Target class], loopInt: 7); + [inv setTarget: t]; + [inv invoke]; + [inv getReturnValue: &i]; + if (i == 8) + printf("OK\n"); + else + printf("ERROR ... expecting 8 and got %d\n", i); + +#define SETUP(X) \ + sig = [t methodSignatureForSelector: @selector(X)]; \ + inv = [NSInvocation invocationWithMethodSignature: sig]; \ + [inv setSelector: @selector(X)]; + + tmpsm.c = 8; + tmpsm.i = 9; + + tmpla.i = 1; + tmpla.s = "hello"; + tmpla.f = 1.23; + + SETUP(retChar); + [inv invokeWithTarget: t]; + printf("Expect: 99, "); + [inv getReturnValue: &c]; + printf("invoke: %d ", c); + c = [p retChar]; + printf("forward: %d\n", c); + + SETUP(retShort); + [inv invokeWithTarget: t]; + printf("Expect: 12345, "); + [inv getReturnValue: &s]; + printf("invoke: %d ", s); + s = [p retShort]; + printf("forward: %d\n", s); + + SETUP(retInt); + [inv invokeWithTarget: t]; + printf("Expect: 123456, "); + [inv getReturnValue: &i]; + printf("invoke: %d ", i); + i = [p retInt]; + printf("forward: %d\n", i); + + SETUP(retLong); + [inv invokeWithTarget: t]; + printf("Expect: 123456, "); + [inv getReturnValue: &l]; + printf("invoke: %ld ", l); + l = [p retLong]; + printf("forward: %ld\n", l); + + SETUP(retFloat); + [inv invokeWithTarget: t]; + printf("Expect: 123.456, "); + [inv getReturnValue: &f]; + printf("invoke: %.3f ", f); + f = [p retFloat]; + printf("forward: %.3f\n", f); + + SETUP(retDouble); + [inv invokeWithTarget: t]; + printf("Expect: 123.456, "); + [inv getReturnValue: &d]; + printf("invoke: %.3f ", d); + d = [p retDouble]; + printf("forward: %.3f\n", d); + + SETUP(retObject); + [inv invokeWithTarget: t]; + printf("Expect: %x, ", t); + [inv getReturnValue: &o]; + printf("invoke: %x ", o); + o = [p retObject]; + printf("forward: %x\n", o); + + SETUP(retString); + [inv invokeWithTarget: t]; + printf("Expect: 'string', "); + [inv getReturnValue: &str]; + printf("invoke: '%s' ", str); + str = [p retString]; + printf("forward: '%s'\n", str); + + SETUP(retSmall); + [inv invokeWithTarget: t]; + printf("Expect: {11,22}, "); + [inv getReturnValue: &sm]; + printf("invoke: {%d,%d} ", sm.c, sm.i); + sm = [p retSmall]; + printf("forward: {%d,%d}\n", sm.c, sm.i); + + SETUP(retLarge); + [inv invokeWithTarget: t]; + printf("Expect: {99,large,99.99}, "); + [inv getReturnValue: &la]; + printf("invoke: {%d,%s,%.2f} ", la.i, la.s, la.f); + la = [p retLarge]; + printf("forward: {%d,%s,%.2f}\n", la.i, la.s, la.f); + + + + + SETUP(loopChar:); + c = 0; + [inv setArgument: &c atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 1, "); + [inv getReturnValue: &c]; + printf("invoke: %d ", c); + c = [p loopChar: 0]; + printf("forward: %d\n", c); + + SETUP(loopShort:); + s = 1; + [inv setArgument: &s atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 2, "); + [inv getReturnValue: &s]; + printf("invoke: %d ", s); + s = [p loopShort: 1]; + printf("forward: %d\n", s); + + SETUP(loopInt:); + i = 2; + [inv setArgument: &i atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 3, "); + [inv getReturnValue: &i]; + printf("invoke: %d ", i); + i = [p loopInt: 2]; + printf("forward: %d\n", i); + + SETUP(loopLong:); + l = 3; + [inv setArgument: &l atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 4, "); + [inv getReturnValue: &l]; + printf("invoke: %d ", l); + l = [p loopLong: 3]; + printf("forward: %d\n", l); + + SETUP(loopFloat:); + f = 4.0; + [inv setArgument: &f atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 5.0, "); + [inv getReturnValue: &f]; + printf("invoke: %.1f ", f); + f = [p loopFloat: 4.0]; + printf("forward: %.1f\n", f); + + SETUP(loopDouble:); + d = 5.0; + [inv setArgument: &d atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 6.0, "); + [inv getReturnValue: &d]; + printf("invoke: %.1f ", d); + d = [p loopDouble: 5.0]; + printf("forward: %.1f\n", d); + + SETUP(loopMulti:int:ch:); + printf("Expect: 6.0, "); + f = [p loopMulti: 3.0 int: 5.0 ch: 'a']; + printf("forward: %.1f\n", f); + + SETUP(loopObject:); + [inv setArgument: &p atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: %x, ", p); + [inv getReturnValue: &o]; + printf("invoke: %x ", o); + o = [p loopObject: p]; + printf("forward: %x\n", o); + + SETUP(loopString:); + str = "Hello"; + [inv setArgument: &str atIndex: 2]; + [inv invokeWithTarget: t]; + printf("Expect: 'Hello', "); + [inv getReturnValue: &str]; + printf("invoke: '%s' ", str); + str = [p loopString: str]; + printf("forward: '%s'\n", str); + + SETUP(loopSmall:); + printf("Expect: {8,9}, "); + [inv setArgument: &tmpsm atIndex: 2]; + [inv invokeWithTarget: t]; + [inv getReturnValue: &sm]; + printf("invoke: {%d,%d} ", sm.c, sm.i); + sm = [p loopSmall: tmpsm]; + printf("forward: {%d,%d}\n", sm.c, sm.i); + + SETUP(loopLarge:); + printf("Expect: {1,hello,1.23}, "); + [inv setArgument: &tmpla atIndex: 2]; + [inv invokeWithTarget: t]; + [inv getReturnValue: &la]; + printf("invoke: {%d,%s,%.2f} ", la.i, la.s, la.f); + la = [p loopLarge: tmpla]; + printf("forward: {%d,%s,%.2f}\n", la.i, la.s, la.f); + + SETUP(loopSmallPtr:); + printf("Expect: {8,9}, "); + [inv setArgument: &smptr atIndex: 2]; + [inv invokeWithTarget: t]; + [inv getReturnValue: &sm]; + printf("invoke: {%d,%d} ", sm.c, sm.i); + sm = [p loopSmallPtr: smptr]; + printf("forward: {%d,%d}\n", sm.c, sm.i); + + SETUP(loopLargePtr:); + printf("Expect: {1,hello,1.23}, "); + [inv setArgument: &laptr atIndex: 2]; + [inv invokeWithTarget: t]; + [inv getReturnValue: &la]; + printf("invoke: {%d,%s,%.2f} ", la.i, la.s, la.f); + la = [p loopLargePtr: laptr]; + printf("forward: {%d,%s,%.2f}\n", la.i, la.s, la.f); + + [arp release]; + return 0; +} + diff --git a/Testing/nsmaptable.m b/Testing/nsmaptable.m new file mode 100644 index 000000000..02b79db53 --- /dev/null +++ b/Testing/nsmaptable.m @@ -0,0 +1,82 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include + +int main () +{ + NSMapTable *mt; + NSMapEnumerator me; + int i; + void *k; + void *v; + id o; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + /* Test with ints */ + + mt = NSCreateMapTable (NSIntMapKeyCallBacks, + NSIntMapValueCallBacks, + 0); + + for (i = 0; i < 16; i++) + NSMapInsert (mt, (void*)i, (void*)(i*2)); + + printf ("value for key %d is %d\n", + 3, (int)NSMapGet (mt, (void*)3)); + NSMapRemove (mt, (void*)3); + printf ("after removing: value for key %d is %d\n", + 3, (int)NSMapGet (mt, (void*)3)); + + me = NSEnumerateMapTable (mt); + while (NSNextMapEnumeratorPair (&me, &k, &v)) + printf ("(%d,%d) ", (int)k, (int)v); + printf ("\n"); + + NSFreeMapTable (mt); + + + /* Test with NSNumber objects */ + + mt = NSCreateMapTable (NSObjectMapKeyCallBacks, + NSObjectMapValueCallBacks, + 0); + + for (i = 0; i < 16; i++) + NSMapInsert (mt, + [NSNumber numberWithInt: i], + [NSNumber numberWithInt: i*i]); + + o = [NSNumber numberWithInt: 3]; + printf ("value for key %s is %s\n", + [[o description] cString], + [[(id)NSMapGet (mt, o) description] cString]); + NSMapRemove (mt, o); + if (NSMapGet (mt, o)) + printf ("after removing: value for key %s is %s\n", + [[o description] cString], + [[(id)NSMapGet (mt, o) description] cString]); + else + printf ("after removing: no value for key %s\n", + [[o description] cString]); + + me = NSEnumerateMapTable (mt); + while (NSNextMapEnumeratorPair (&me, &k, &v)) + printf ("(%d,%d) ", [(id)k intValue], [(id)v intValue]); + printf ("\n"); + + NSFreeMapTable (mt); + + [arp release]; + exit (0); +} diff --git a/Testing/nsmethodsignature.m b/Testing/nsmethodsignature.m new file mode 100644 index 000000000..086dd4ba8 --- /dev/null +++ b/Testing/nsmethodsignature.m @@ -0,0 +1,430 @@ +/** nsmethodsignature - Program to test NSMethodSignature. + Copyright (C) 2004 Free Software Foundation, Inc. + + Written by: David Ayers + + This file is part of the GNUstep Base Library. + + This library 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 2 of the License, or (at your option) any later version. + + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +*/ + +#include +#include +#include +#include +#include +#include + +#include + + +#define SRV_NAME @"nsmethodsignaturetest" + +struct _MyLargeStruct +{ + double first; + double second; +}; +typedef struct _MyLargeStruct MyLargeStruct; + +struct _MySmallStruct +{ + char first; +}; +typedef struct _MySmallStruct MySmallStruct; + +/*------------------------------------*/ +@interface MyClass : NSObject +-(void)void_void; +-(id)id_void; + +-(char)char_void; +-(unsigned char)uchar_void; +-(signed char)schar_void; + +-(short)short_void; +-(unsigned short)ushort_void; +-(signed short)sshort_void; + +-(int)int_void; +-(unsigned int)uint_void; +-(signed int)sint_void; + +-(long)long_void; +-(unsigned long)ulong_void; +-(signed long)slong_void; + +-(float)float_void; +-(double)double_void; + +-(MyLargeStruct)largeStruct_void; +-(MySmallStruct)smallStruct_void; + + + +-(void)void_id:(id)_id; + +-(void)void_char:(char)_char; +-(void)void_uchar:(unsigned char)_char; +-(void)void_schar:(signed char)_char; + +-(void)void_short:(short)_short; +-(void)void_ushort:(unsigned short)_short; +-(void)void_sshort:(signed short)_short; + +-(void)void_int:(int)_int; +-(void)void_uint:(unsigned int)_int; +-(void)void_sint:(signed int)_int; + +-(void)void_long:(long)_long; +-(void)void_ulong:(unsigned long)_long; +-(void)void_slong:(signed long)_long; + +-(void)void_float:(float)_float; +-(void)void_double:(double)_double; + +-(void)void_largeStruct:(MyLargeStruct)_str; +-(void)void_smallStruct:(MySmallStruct)_str; + +-(void)void_float:(float)_float double:(double)_double; +-(void)void_double:(double)_double float:(float)_float; + +-(MyLargeStruct)largeStruct_id:(id)_id + char:(char)_char + short:(short)_short + int:(int)_int + long:(long)_long + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr; +-(MySmallStruct)smallStruct_id:(id)_id + uchar:(unsigned char)_uchar + ushort:(unsigned short)_ushort + uint:(unsigned int)_uint + ulong:(unsigned long)_ulong + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr; + +-(const char *)runtimeSignatureForSelector:(SEL)selector; +-(const char *)mframeSignatureForSelector:(SEL)selector; +@end + +@implementation MyClass +-(void)void_void {} +-(id)id_void { return 0; } + +-(char)char_void { return 0; } +-(unsigned char)uchar_void { return 0; } +-(signed char)schar_void { return 0; } + +-(short)short_void { return 0; } +-(unsigned short)ushort_void { return 0; } +-(signed short)sshort_void { return 0; } + +-(int)int_void { return 0; } +-(unsigned int)uint_void { return 0; } +-(signed int)sint_void { return 0; } + +-(long)long_void { return 0; } +-(unsigned long)ulong_void { return 0; } +-(signed long)slong_void { return 0; } + +-(float)float_void { return 0; } +-(double)double_void { return 0; } + +-(MyLargeStruct)largeStruct_void { MyLargeStruct str; return str; } +-(MySmallStruct)smallStruct_void { MySmallStruct str; return str; } + + + +-(void)void_id:(id)_id {} + +-(void)void_char:(char)_char {} +-(void)void_uchar:(unsigned char)_char {} +-(void)void_schar:(signed char)_char {} + +-(void)void_short:(short)_short {} +-(void)void_ushort:(unsigned short)_short {} +-(void)void_sshort:(signed short)_short {} + +-(void)void_int:(int)_int {} +-(void)void_uint:(unsigned int)_int {} +-(void)void_sint:(signed int)_int {} + +-(void)void_long:(long)_long {} +-(void)void_ulong:(unsigned long)_long {} +-(void)void_slong:(signed long)_long {} + +-(void)void_float:(float)_float {} +-(void)void_double:(double)_double {} + +-(void)void_largeStruct:(MyLargeStruct)_str {} +-(void)void_smallStruct:(MySmallStruct)_str {} + +-(void)void_float:(float)_float double:(double)_double {} +-(void)void_double:(double)_double float:(float)_float {} + + +-(MyLargeStruct)largeStruct_id:(id)_id + char:(char)_char + short:(short)_short + int:(int)_int + long:(long)_long + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr { return _lstr; } + +-(MySmallStruct)smallStruct_id:(id)_id + uchar:(unsigned char)_uchar + ushort:(unsigned short)_ushort + uint:(unsigned int)_uint + ulong:(unsigned long)_ulong + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr { return _sstr; } + +-(const char *)runtimeSignatureForSelector:(SEL)selector +{ + GSMethod meth = GSGetMethod(isa, selector, YES, YES); + return meth->method_types; +} + +-(const char *)mframeSignatureForSelector:(SEL)selector +{ + const char *types = [self runtimeSignatureForSelector: selector]; + NSMethodSignature *sig = [NSMethodSignature signatureWithObjCTypes: types]; + return [sig methodType]; +} +@end + +/*------------------------------------*/ + +int failed = 0; + +void +test_mframe_build_signature(void) +{ + const char *mf_types; + void *it = 0; + GSMethod meth; + GSMethodList list; + Class cls = [MyClass class]; + NSMethodSignature *sig; + unsigned int i; + + for (it = 0, list = class_nextMethodList(cls, &it); + list != 0; + list = class_nextMethodList(cls, &it)) + { + id pool = [NSAutoreleasePool new]; + + for (i = 0; i < list->method_count; i++) + { + meth = &list->method_list[i]; + sig = [NSMethodSignature signatureWithObjCTypes: meth->method_types]; + mf_types = [sig methodType]; + if (strcmp(meth->method_types, mf_types)) + { + NSLog(@"sel: %s\nrts:%s\nmfs:%s", + GSNameFromSelector(meth->method_name), + meth->method_types, mf_types); + failed = 1; + } + } + + [pool release]; + } + +} + +/* + This test is useful if the nsmethodsignatureserver is running which + was compiled with either a different GNUstep-base version or a different + version of gcc. It the server isn't found the test is skipped. +*/ +void +test_compare_server_signature(void) +{ + id objct = [MyClass new]; + id proxy = [NSConnection rootProxyForConnectionWithRegisteredName: SRV_NAME + host: @"*"]; + if (proxy) + { + const char *rmtSig; + const char *lclSig; + +#define TEST_SEL(SELNAME) { \ + lclSig = [objct runtimeSignatureForSelector: @selector(SELNAME)]; \ + rmtSig = [proxy runtimeSignatureForSelector: @selector(SELNAME)]; \ + if (!GSSelectorTypesMatch(lclSig, rmtSig)) \ + NSLog(@"runtime: sel:%s\nlcl:%s\nrmt:%s", \ + GSNameFromSelector(@selector(SELNAME)), \ + lclSig, rmtSig); \ + lclSig = [objct mframeSignatureForSelector: @selector(SELNAME)]; \ + rmtSig = [proxy mframeSignatureForSelector: @selector(SELNAME)]; \ + if (!GSSelectorTypesMatch(lclSig, rmtSig)) \ + NSLog(@"mframe : sel:%s\nlcl:%s\nrmt:%s", \ + GSNameFromSelector(@selector(SELNAME)), \ + lclSig, rmtSig); \ + } + + TEST_SEL(void_void); + TEST_SEL(id_void); + TEST_SEL(char_void); + TEST_SEL(uchar_void); + TEST_SEL(schar_void); + TEST_SEL(short_void); + TEST_SEL(ushort_void); + TEST_SEL(sshort_void); + TEST_SEL(int_void); + TEST_SEL(uint_void); + TEST_SEL(sint_void); + TEST_SEL(long_void); + TEST_SEL(ulong_void); + TEST_SEL(slong_void); + TEST_SEL(float_void); + TEST_SEL(double_void); + TEST_SEL(largeStruct_void); + TEST_SEL(smallStruct_void); + + TEST_SEL(void_id:); + TEST_SEL(void_char:); + TEST_SEL(void_uchar:); + TEST_SEL(void_schar:); + TEST_SEL(void_short:); + TEST_SEL(void_ushort:); + TEST_SEL(void_sshort:); + TEST_SEL(void_int:); + TEST_SEL(void_uint:); + TEST_SEL(void_sint:); + TEST_SEL(void_long:); + TEST_SEL(void_ulong:); + TEST_SEL(void_slong:); + TEST_SEL(void_float:); + TEST_SEL(void_double:); + TEST_SEL(void_largeStruct:); + TEST_SEL(void_smallStruct:); + TEST_SEL(void_float:double:); + TEST_SEL(void_double:float:); + TEST_SEL(largeStruct_id:char:short:int:long:float:double:largeStruct:smallStruct:); + TEST_SEL(smallStruct_id:uchar:ushort:uint:ulong:float:double:largeStruct:smallStruct:); + + } + else + { + NSLog(@"Skipping test_compare_server_signature: proxy not found."); + } +} + +void +test_GSSelectorTypesMatch(void) +{ + const char *pairs[][2] = { {"@@::", "@12@0:4:8"}, + {"@@::", "@12@+0:+4:+8"}, + {"@@::", "@12@-0:-4:-8"}, + {"@12@0:4:8", "@@::"}, + {"@12@+0:+4:+8", "@@::"}, + {"@12@-0:-4:-8", "@@::"}, + + {"@12@0:4:8", "@12@+0:+4:+8"}, + {"@12@0:4:8", "@12@-0:-4:-8"}, + {"@12@+0:+4:+8", "@12@0:4:8"}, + {"@12@-0:-4:-8", "@12@0:4:8"}, + + {"@12@0:4:8", "@16@+4:+8:+12"}, + {"@12@0:4:8", "@16@-4:-8:-12"}, + {"@12@+0:+4:+8", "@16@4:8:12"}, + {"@12@-0:-4:-8", "@16@4:8:12"}, + + {"{_MyLargeStruct2={_MyLargeStruct=dd}dd}@:", + "{??={??=dd}dd}16@0:4"}, + + {"{_MyLargeStruct=dd}56@+8:+12@+16c+23s+26i+28l24f28d32{_MyLargeStruct=dd}40{_MySmallStruct=c}44", + "{_MyLargeStruct=dd}46@+8:+12@+16c+17s+16i+20l+24f+28d24{_MyLargeStruct=dd}32{_MySmallStruct=c}45"}, + {"{_MyLargeStruct=dd}56@+8:+12@+16c+23s+26i+28l24f28d32{_MyLargeStruct=dd}40{_MySmallStruct=c}44", + "{??=dd}46@+8:+12@+16c+17s+16i+20l+24f+28d24{??=dd}32{??=c}45"}, + {0, 0} }; + unsigned int i = 0; + + while (pairs[i][0]) + { + if (GSSelectorTypesMatch(pairs[i][0], pairs[i][1]) == NO) + { + NSLog(@"pair %d does not match:\n%s\n%s", + i, pairs[i][0], pairs[i][1]); + failed = 1; + } + i++; + } +} + +void +run_server(void) +{ + id obj = [MyClass new]; + NSConnection *conn = [NSConnection defaultConnection]; + + [conn setRootObject: obj]; + if ([conn registerName: SRV_NAME] == NO) + { + NSLog(@"Failed to register name: " SRV_NAME ); + abort(); + } + [[NSRunLoop currentRunLoop] run]; +} + +int +main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool; + pool = [[NSAutoreleasePool alloc] init]; + + if ([[[[NSProcessInfo processInfo] arguments] lastObject] isEqual: @"srv"]) + { + run_server(); + abort(); + } + + NS_DURING + { + test_mframe_build_signature(); + test_compare_server_signature(); + test_GSSelectorTypesMatch(); + if (failed) + [NSException raise: NSInternalInconsistencyException + format: @"discrepancies between gcc/mframe signatures"]; + + NSLog(@"MethodSignature Test Succeeded."); + } + NS_HANDLER + { + NSLog(@"MethodSignature Test Failed:"); + NSLog(@"%@ %@ %@", + [localException name], + [localException reason], + [localException userInfo]); + } + NS_ENDHANDLER + + [pool release]; + + exit(0); +} + diff --git a/Testing/nsnotification.m b/Testing/nsnotification.m new file mode 100644 index 000000000..58db5f895 --- /dev/null +++ b/Testing/nsnotification.m @@ -0,0 +1,138 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* The simplest of tests for the NSNotification and NSNotificationCenter + classes. These tests should be expanded. + + (The Tcp*Port classes, however, do test the notification mechanism + further.) */ + +#include + +@interface Observer : NSObject +- (void) gotNotificationFoo: not; +@end + +@implementation Observer + +- (void) gotNotificationFoo: (NSNotification*)not +{ + printf ("Got %s\n", [[not name] cString]); +} + +- (void) gotNotificationFooNoObject: (NSNotification*)not +{ + printf ("Got %s without object\n", [[not name] cString]); +} + +@end + +id foo = @"NotificationTestFoo"; + +int main () +{ + id o1; + id observer1; + id arp; + + arp = [NSAutoreleasePool new]; +NSLog(@"Make string object"); + o1 = [NSString new]; +NSLog(@"Make Observer object"); + observer1 = [Observer new]; + +NSLog(@"Add observer to process centre"); + + [[NSNotificationCenter defaultCenter] + addObserver: observer1 + selector: @selector(gotNotificationFoo:) + name: foo + object: o1]; + +NSLog(@"Add observer to distributed centre"); + [[NSDistributedNotificationCenter defaultCenter] + addObserver: observer1 + selector: @selector(gotNotificationFoo:) + name: foo + object: o1]; + +NSLog(@"Add observer to process centre"); + [[NSNotificationCenter defaultCenter] + addObserver: observer1 + selector: @selector(gotNotificationFooNoObject:) + name: foo + object: nil]; + +NSLog(@"Add observer to distributed centre"); + [[NSDistributedNotificationCenter defaultCenter] + addObserver: observer1 + selector: @selector(gotNotificationFooNoObject:) + name: foo + object: nil]; + + +NSLog(@"Post to process centre"); + /* This will cause two messages to be printed, one for each request above. */ + [[NSNotificationCenter defaultCenter] + postNotificationName: foo + object: o1]; + +NSLog(@"Post to distributed centre"); + /* This will cause two messages to be printed, one for each request above. */ + [[NSDistributedNotificationCenter defaultCenter] + postNotificationName: foo + object: o1]; + +NSLog(@"Post to process centre"); + /* This will cause one message to be printed. */ + [[NSNotificationCenter defaultCenter] + postNotificationName: foo + object: nil]; + +NSLog(@"Post to distributed centre"); + /* This will cause one message to be printed. */ + [[NSDistributedNotificationCenter defaultCenter] + postNotificationName: foo + object: nil]; + + +NSLog(@"Remove observer from process centre"); + [[NSNotificationCenter defaultCenter] + removeObserver: observer1 + name: nil + object: o1]; + + /* This will cause message to be printed. */ + [[NSNotificationCenter defaultCenter] + postNotificationName: foo + object: o1]; + + [[NSNotificationCenter defaultCenter] + removeObserver: observer1]; + + /* This will cause no messages to be printed. */ + [[NSNotificationCenter defaultCenter] + postNotificationName: foo + object: o1]; + + [[NSDistributedNotificationCenter defaultCenter] + addObserver: observer1 + selector: @selector(gotNotificationFooNoObject:) + name: foo + object: nil]; + + [[NSDistributedNotificationCenter defaultCenter] + postNotificationName: foo + object: @"hello"]; + + [arp release]; + + exit (0); +} diff --git a/Testing/nspathutilities.m b/Testing/nspathutilities.m new file mode 100644 index 000000000..f69dd5ebb --- /dev/null +++ b/Testing/nspathutilities.m @@ -0,0 +1,175 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* TESTING: NSPathUtilities.h ************************************************ +* * +* Author: Sheldon Gill * +* Date: 20-Dec-2003 * +* * +* Lists all search paths * +* * +**************************************************************************** */ + +#include +#include +#include +#include +#include +#include + +/* Define any unknown directory keys */ +#ifndef NSDocumentDirectory +#define NSDocumentDirectory 155 +#endif +#ifndef GSFrameworksDirectory +#define GSFrameworksDirectory 153 +#endif +#ifndef GSFontsDirectory +#define GSFontsDirectory 154 +#endif + +void print_paths(NSArray *paths) +{ + int i, count; + + count = [paths count]; + if (count==1) + { + printf("%s\n", [[paths objectAtIndex:0] cString]); + } + else + { + printf("\n"); + for ( i = 0; i < count; i++ ) + { + printf(" %s\n", [[paths objectAtIndex:i] cString]); + } + } +} + + +int main( int argc, char *argv[] ) +{ + NSAutoreleasePool *arp; + + NSArray *domain_names; + NSArray *directory_key_names; + NSArray *paths; + int i, j, k; + + BOOL tilde_expansion = YES; + +#define DIR_KEYS 16 +#define DOMAIN_MASKS 5 + + NSSearchPathDomainMask domain_masks[DOMAIN_MASKS] = { + NSUserDomainMask, + NSLocalDomainMask, + NSNetworkDomainMask, + NSSystemDomainMask, + NSAllDomainsMask + }; + + NSSearchPathDirectory directory_keys[DIR_KEYS] = { + NSApplicationDirectory, + NSDemoApplicationDirectory, + NSDeveloperApplicationDirectory, + NSAdminApplicationDirectory, + NSLibraryDirectory, + NSDeveloperDirectory, + NSUserDirectory, + NSDocumentationDirectory, + NSDocumentDirectory, + NSAllApplicationsDirectory, + NSAllLibrariesDirectory, + GSLibrariesDirectory, + GSToolsDirectory, + GSApplicationSupportDirectory, + GSFrameworksDirectory, + GSFontsDirectory + }; + + NSSearchPathDirectory key; + NSSearchPathDomainMask domain; + + printf("TESTING: NSPathUtilities.h\n"); + + arp = [NSAutoreleasePool new]; + + if (argc > 1) + tilde_expansion = NO; + + printf("Begin...\n"); + + domain_names = [NSArray arrayWithObjects: + @"NSUserDomainMask", + @"NSLocalDomainMask", + @"NSNetworkDomainMask", + @"NSSystemDomainMask", + @"NSAllDomainsMask", + nil + ]; + + directory_key_names = [NSArray arrayWithObjects: + @"NSApplicationDirectory", + @"NSDemoApplicationDirectory", + @"NSDeveloperApplicationDirectory", + @"NSAdminApplicationDirectory", + @"NSLibraryDirectory", + @"NSDeveloperDirectory", + @"NSUserDirectory", + @"NSDocumentationDirectory", + @"NSDocumentDirectory", + @"NSAllApplicationsDirectory", + @"NSAllLibrariesDirectory", + @"GSLibrariesDirectory", + @"GSToolsDirectory", + @"GSApplicationSupportDirectory", + @"GSFrameworksDirectory", + @"GSFontsDirectory", + nil + ]; + + printf("NSSearchPathForDirectoriesInDomains()\n"); + for ( i = 0 ; i < DOMAIN_MASKS ; i++ ) + { + printf("Domain: %s\n",[[domain_names objectAtIndex: i] cString]); + domain = domain_masks[i]; + + for ( j = 0 ; j < DIR_KEYS ; j++ ) + { + printf(" %s = ",[[directory_key_names objectAtIndex: j] cString]); + key = directory_keys[j]; + + paths = NSSearchPathForDirectoriesInDomains( key, domain, tilde_expansion ); + if ([paths count] == 0) + { + printf("\n"); + } + else + { + print_paths(paths); + } + } + } + printf("End NSSearchPathForDirectoriesInDomains\n\n"); + + printf("Begin NSUser functions...\n"); + GSPrintf(stdout,@"User name is '%@'\n",NSUserName()); + GSPrintf(stdout,@"Home directory is '%@'\n",NSHomeDirectory()); + GSPrintf(stdout,@"GSDefaultsRoot for user is '%@'\n",GSDefaultsRootForUser(NSUserName())); + GSPrintf(stdout,@"Temp for user is '%@'\n",NSTemporaryDirectory()); + printf("End NSUser functions\n\n"); + + [arp release]; + + printf("End Testing!\n"); + return 0; +} diff --git a/Testing/nsprocessinfo.m b/Testing/nsprocessinfo.m new file mode 100644 index 000000000..e3aeac72f --- /dev/null +++ b/Testing/nsprocessinfo.m @@ -0,0 +1,48 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSProcessInfo *pi = [NSProcessInfo processInfo]; + NSString* aString; + NSString* aKey; + NSEnumerator* enumerator; + + printf("Host name: %s\n",[[pi hostName] UTF8String]); + printf("Operating system: %d\n",[pi operatingSystem]); + printf("Operating system name: %s\n",[[pi operatingSystemName] UTF8String]); + printf("Operating system version: %s\n",[[pi operatingSystemVersionString] UTF8String]); + printf("Process Name: %s\n",[[pi processName] UTF8String]); + printf("Globally Unique String: %s\n",[[pi globallyUniqueString] UTF8String]); + + printf("\nProcess arguments\n"); + printf("%d argument(s)\n", [[pi arguments] count]); + enumerator = [[pi arguments] objectEnumerator]; + while ((aString = [enumerator nextObject])) + printf("-->%s\n",[aString UTF8String]); + + printf("\nProcess environment\n"); + printf("%d environment variables(s)\n", [[pi environment] count]); + enumerator = [[pi environment] keyEnumerator]; + while ((aKey = [enumerator nextObject])) + printf("++>%s=%s\n",[aKey UTF8String],[[[pi environment] + objectForKey:aKey] UTF8String]); + + [arp release]; + exit(0); +} diff --git a/Testing/nsscanner.m b/Testing/nsscanner.m new file mode 100644 index 000000000..0a47b7391 --- /dev/null +++ b/Testing/nsscanner.m @@ -0,0 +1,968 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* + * Test the operation of the NSScanner class. + * All is well if this program produces no output. + * + * By default, double values differing by one least-significant-bit or + * less are assumed to be equal. This behaviour can be changed with + * the `-e' flag. For example, if you want only doubles that are exactly + * equal to be treated as equal, use `-e0'. + * + * Eric Norum + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "wgetopt.h" + +/* + * Doubles differing by this many least-significant-bits + * or less are assumed to be `equal'. + */ +int DoubleCompareEqual = 1; + +/* + * Check that scan completely consumed string + */ +void +testFullScan (const char *message, NSString *string, NSScanner *scanner) +{ + unsigned int scanLocation; + + scanLocation = [scanner scanLocation]; + if (scanLocation != [string length]) + printf ("%s of `%s' moves scan location to %u.\n", message, + [string cString], scanLocation); +} + +/* + ************************************************************************ + * scanInt: * + ************************************************************************ + */ + +/* + * Test a valid scanInt operation + */ +void +testScanIntGood (int i) +{ + NSString *string; + NSScanner *scanner; + int value; + + string = [NSString stringWithFormat:@"%d", i]; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanInt:&value]) + printf ("scanInt of `%s' failed.\n", [string cString]); + else if (value != i) + printf ("scanInt of `%s' returned value %d.\n", [string cString], value); + testFullScan ("scanInt", string, scanner); +} + +/* + * Verify that scanInt handles overflow + */ +void +testScanIntOverflow (double d) +{ + NSString *string; + NSScanner *scanner; + int value; + + string = [NSString stringWithFormat:@"%.0f", d]; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanInt:&value]) + printf ("scanInt of `%s' failed.\n", [string cString]); + else if (value != ((d < 0) ? INT_MIN : INT_MAX)) + printf ("scanInt of `%s' didn't overflow, returned %d.\n", [string cString], value); + testFullScan ("scanInt", string, scanner); +} + +/* + * Test scanInt operation + */ +void +testScanInt (void) +{ + NSString *string; + NSScanner *scanner; + int i; + int value; + unsigned int scanLocation; + + /* + * Check values within range + */ + i = INT_MAX-20; + for (;;) { + testScanIntGood (i); + if (i == INT_MAX) + break; + i++; + } + i = INT_MIN+20; + for (;;) { + testScanIntGood (i); + if (i == INT_MIN) + break; + i--; + } + for (i = -20 ; i <= 20 ; i++) + testScanIntGood (i); + + + /* + * Check overflow values + */ + for (i = 1 ; i <= 20 ; i++) { + testScanIntOverflow ((double)INT_MAX + i); + testScanIntOverflow ((double)INT_MIN - i); + testScanIntOverflow ((2.0 * (double)INT_MAX) + i); + testScanIntOverflow ((2.0 * (double)INT_MIN) - i); + testScanIntOverflow ((10.0 * (double)INT_MAX) + i); + testScanIntOverflow ((10.0 * (double)INT_MIN) - i); + } + + /* + * Check that non-digits terminate the scan + */ + string = @"1234FOO"; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanInt:&value]) + printf ("scanInt of `%s' failed.\n", [string cString]); + scanLocation = [scanner scanLocation]; + if (scanLocation != 4) + printf ("scanInt of `%s' moves scan location to %u.\n", [string cString], scanLocation); + + /* + * Check that non-digits don't move the scan location + */ + string = @"junk"; + scanner = [NSScanner scannerWithString:string]; + if ([scanner scanInt:&value]) + printf ("scanInt of `%s' succeeded with value %d.\n", [string cString], value); + scanLocation = [scanner scanLocation]; + if (scanLocation != 0) + printf ("scanInt of `%s' moves scan location to %u.\n", [string cString], scanLocation); + + /* + * Check that non-digits don't consume characters to be skipped + */ + string = @" junk"; + scanner = [NSScanner scannerWithString:string]; + if ([scanner scanInt:&value]) + printf ("scanInt of `%s' succeeded with value %d.\n", [string cString], value); + scanLocation = [scanner scanLocation]; + if (scanLocation != 0) + printf ("scanInt of `%s' moves scan location to %u.\n", [string cString], scanLocation); +} + +/* + ************************************************************************ + * scanRadixUnsignedInt: * + ************************************************************************ + */ + +/* + * Test a valid scanRadixUnsignedInt operation + */ +void +testScanRadixUnsignedIntFinish (NSString *string, BOOL expectValue, unsigned int expectedValue, unsigned int expectedScanLocation) +{ + NSScanner *scanner; + unsigned int value; + + scanner = [NSScanner scannerWithString:string]; + if ([scanner scanRadixUnsignedInt:&value]) { + if (!expectValue) + printf ("scanRadixUnsignedInt of `%s' succeeded.\n", [string cString]); + else if (value != expectedValue) + printf ("scanRadixUnsignedInt of `%s' returned value %u (%#x).\n", [string cString], value, value); + } + else { + if (expectValue) + printf ("scanRadixUnsignedInt of `%s' failed.\n", [string cString]); + } + if (expectedScanLocation != [scanner scanLocation]) + printf ("scanRadixUnsignedInt of `%s' moved scan location to %u (expected %u)\n", [string cString], [scanner scanLocation], expectedScanLocation); +} + +/* + * Test a valid scanRadixUnsignedInt operation + */ +void +testScanRadixUnsignedIntGood (NSString *format, unsigned int i) +{ + NSString *string; + + if (format == nil) { + testScanRadixUnsignedIntGood (@"%u", i); + testScanRadixUnsignedIntGood (@"0%o", i); + testScanRadixUnsignedIntGood (@"0x%x", i); + testScanRadixUnsignedIntGood (@"0X%X", i); + return; + } + string = [NSString stringWithFormat:format, i]; + testScanRadixUnsignedIntFinish (string, YES, i, [string length]); +} + +/* + * Verify that scanRadixUnsignedInt handles overflow + */ +void +testScanRadixUnsignedIntOverflow (double d) +{ + NSString *string; + NSScanner *scanner; + unsigned int value; + + string = [NSString stringWithFormat:@"%.0f", d]; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanRadixUnsignedInt:&value]) + printf ("scanRadixUnsignedInt of `%s' failed.\n", [string cString]); + else if (value != UINT_MAX) + printf ("scanRadixUnsignedInt of `%s' didn't overflow, returned %u (%#x).\n", [string cString], value, value); + testFullScan ("scanRadixUnsignedInt", string, scanner); +} + +/* + * Test scanRadixUnsignedInt operation + */ +void +testScanRadixUnsignedInt (void) +{ + unsigned int i; + + /* + * I added this check so I can use the same test program on + * NEXTSTEP/OPENSTEP which doesn't have the scanRadixUnsignedInt: + * method. + */ + if (![NSScanner instancesRespondTo:@selector(scanRadixUnsignedInt:)]) { + printf ("NSScanner objects do not respond to scanRadixUnsignedInt:\n"); + return; + } + + /* + * Check values within range + */ + i = UINT_MAX-32; + for (;;) { + testScanRadixUnsignedIntGood (nil, i); + if (i == UINT_MAX) + break; + i++; + } + for (i = 0 ; i <= 32 ; i++) + testScanRadixUnsignedIntGood (nil, i); + + /* + * Check overflow values + */ + for (i = 1 ; i <= 32 ; i++) { + testScanRadixUnsignedIntOverflow ((double)UINT_MAX + i); + testScanRadixUnsignedIntOverflow ((2.0 * (double)UINT_MAX) + i); + testScanRadixUnsignedIntOverflow ((2.0 * (double)UINT_MAX) - i); + testScanRadixUnsignedIntOverflow ((10.0 * (double)UINT_MAX) + i); + testScanRadixUnsignedIntOverflow ((10.0 * (double)UINT_MAX) - i); + } + + /* + * Check that non-digits terminate the scan + */ + testScanRadixUnsignedIntFinish (@"1234FOO", YES, 1234, 4); + testScanRadixUnsignedIntFinish (@"01234FOO", YES, 01234, 5); + testScanRadixUnsignedIntFinish (@"0x1234FOO", YES, 0x1234F, 7); + testScanRadixUnsignedIntFinish (@"0X1234FOO", YES, 0x1234F, 7); + testScanRadixUnsignedIntFinish (@"012348FOO", YES, 01234, 5); + testScanRadixUnsignedIntFinish (@"012349FOO", YES, 01234, 5); + + /* + * Check that non-digits don't move the scan location + */ + testScanRadixUnsignedIntFinish (@"FOO", NO, 0, 0); + testScanRadixUnsignedIntFinish (@" FOO", NO, 0, 0); + testScanRadixUnsignedIntFinish (@" 0x ", NO, 0, 0); +} + +/* + ************************************************************************ + * scanHexInt: * + ************************************************************************ + */ + +/* + * Test a valid scanHexInt operation + */ +void +testScanHexIntFinish (NSString *string, BOOL expectValue, unsigned int expectedValue, unsigned int expectedScanLocation) +{ + NSScanner *scanner; + unsigned int value; + + scanner = [NSScanner scannerWithString:string]; + if ([scanner scanHexInt:&value]) { + if (!expectValue) + printf ("scanHexInt of `%s' succeeded.\n", [string cString]); + else if (value != expectedValue) + printf ("scanHexInt of `%s' returned value %u (%#x).\n", [string cString], value, value); + } + else { + if (expectValue) + printf ("scanHexInt of `%s' failed.\n", [string cString]); + } + if (expectedScanLocation != [scanner scanLocation]) + printf ("scanHexInt of `%s' moved scan location to %u (expected %u)\n", [string cString], [scanner scanLocation], expectedScanLocation); +} + +/* + * Test a valid scanHexInt operation + */ +void +testScanHexIntGood (NSString *format, unsigned int i) +{ + NSString *string; + + if (format == nil) { + testScanHexIntGood (@"%x", i); + testScanHexIntGood (@"%X", i); + return; + } + string = [NSString stringWithFormat:format, i]; + testScanHexIntFinish (string, YES, i, [string length]); +} + +/* + * Test scanHexInt operation + */ +void +testScanHexInt (void) +{ + unsigned int i; + + /* + * Check values within range + */ + i = UINT_MAX-32; + for (;;) { + testScanHexIntGood (nil, i); + if (i == UINT_MAX) + break; + i++; + } + for (i = 0 ; i <= 32 ; i++) + testScanHexIntGood (nil, i); + + /* + * Check that non-digits terminate the scan + */ + testScanHexIntFinish (@"1234FOO", YES, 0x1234F, 5); + testScanHexIntFinish (@"01234FOO", YES, 0x1234F, 6); + + /* + * Check that non-digits don't move the scan location + */ + testScanHexIntFinish (@"GOO", NO, 0, 0); + testScanHexIntFinish (@" GOO", NO, 0, 0); + testScanHexIntFinish (@" x ", NO, 0, 0); +} + +/* + ************************************************************************ + * scanLongLong: * + ************************************************************************ + */ +#if defined (LONG_LONG_MAX) +/* + * Quick hacks to convert a long long types. + */ +static char * +unsignedlonglongToString (unsigned long long n) +{ + static char cbuf[400]; /* Should be big enough! */ + char *cp = &cbuf[400]; + + *--cp = '\0'; + do { + *--cp = (n % 10) + '0'; + n /= 10; + } while (n); + return cp; +} + +static char * +longlongToString (long long i) +{ + unsigned long long n; + char *cp; + + if (i < 0) + n = -i; + else + n = i; + cp = unsignedlonglongToString (n); + if (i < 0) + *--cp = '-'; + return cp; +} + +/* + * Test a valid scanLongLong operation + */ +void +testScanLongLongGood (long long i) +{ + NSString *string; + NSScanner *scanner; + long long value; + + string = [NSString stringWithFormat:@"%s", longlongToString (i)]; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanLongLong:&value]) + printf ("scanLongLong of `%s' failed.\n", [string cString]); + else if (value != i) + printf ("scanLongLong of `%s' returned value %s.\n", [string cString], + longlongToString (value)); + testFullScan ("scanLongLong", string, scanner); +} + +/* + * Verify that scanLongLong handles overflow + */ +void +testScanLongLongOverflow (const char *sign, unsigned long long check, long long expect) +{ + NSString *string; + NSScanner *scanner; + long long value; + + string = [NSString stringWithFormat:@"%s%s", sign, unsignedlonglongToString (check)]; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanLongLong:&value]) + printf ("scanLongLong of `%s' failed.\n", [string cString]); + else if (value != expect) + printf ("scanLongLong of `%s' didn't overflow, returned %s.\n", [string cString], + longlongToString (value)); + testFullScan ("scanLongLong", string, scanner); +} + +/* + * Test scanLongLong operation + */ +void +testScanLongLong (void) +{ + NSString *string; + NSScanner *scanner; + long long i; + long long value; + unsigned int scanLocation; + + /* + * Check values within range + */ + i = LONG_LONG_MAX-20; + for (;;) { + testScanLongLongGood (i); + if (i == LONG_LONG_MAX) + break; + i++; + } + i = LONG_LONG_MIN+20; + for (;;) { + testScanLongLongGood (i); + if (i == LONG_LONG_MIN) + break; + i--; + } + for (i = -20 ; i <= 20 ; i++) + testScanLongLongGood (i); + + + /* + * Check overflow values + */ + for (i = 1 ; i <= 20 ; i++) { + testScanLongLongOverflow ("", LONG_LONG_MAX + i, LONG_LONG_MAX); + testScanLongLongOverflow ("", ULONG_LONG_MAX - i + 1, LONG_LONG_MAX); + if (i > 1) + testScanLongLongOverflow ("-", LONG_LONG_MAX + i, LONG_LONG_MIN); + } + + /* + * Check that non-digits terminate the scan + */ + string = @"1234FOO"; + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanLongLong:&value]) + printf ("scanLongLong of `%s' failed.\n", [string cString]); + scanLocation = [scanner scanLocation]; + if (scanLocation != 4) + printf ("scanLongLong of `%s' moves scan location to %u.\n", [string cString], scanLocation); + + /* + * Check that non-digits don't move the scan location + */ + string = @"junk"; + scanner = [NSScanner scannerWithString:string]; + if ([scanner scanLongLong:&value]) + printf ("scanLongLong of `%s' succeeded with value %s\n", [string cString], + longlongToString (value)); + scanLocation = [scanner scanLocation]; + if (scanLocation != 0) + printf ("scanLongLong of `%s' moves scan location to %u.\n", [string cString], scanLocation); +} +#endif /* defined (LONG_LONG_MAX) */ + +/* + ************************************************************************ + * scanDouble: * + ************************************************************************ + */ + +/* + * Compare two doubles for `almost' equality + */ +static double +areDoublesEqual (double d1, double d2) +{ + if (d1 == d2) + return 0; + if (d1 == 0) + return (fabs (d2) /DBL_EPSILON); + if (d2 == 0) + return (fabs (d1) /DBL_EPSILON); + d1 = fabs(d1); + d2 = fabs(d2); + if (d1 > d2) + return fabs (1.0 - (d1 / d2)) / DBL_EPSILON; + else + return fabs (1.0 - (d2 / d1)) / DBL_EPSILON; +} + +/* + * Test a scanDouble operation + */ +void +testScanDoubleGood (NSString *string, double expect) +{ + NSScanner *scanner; + double value, error; + + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanDouble:&value]) + printf ("scanDouble of `%s' failed.\n", [string cString]); + else if ((error = areDoublesEqual (value, expect)) > DoubleCompareEqual) + printf ("scanDouble of `%s' returned value %.*e (%g LSB different).\n", + [string cString], DBL_DIG + 2, value, error); + testFullScan ("scanDouble", string, scanner); +} + +static void +testScanDoubleOneDigit (NSString *format, int digit, double expect) +{ + NSString *string = [NSString stringWithFormat:format, digit]; + testScanDoubleGood (string, expect); +} + +static void +testScanDoubleShort (NSString *string, double expect, unsigned int length) +{ + NSScanner *scanner; + double value, error; + unsigned int scanLocation; + + scanner = [NSScanner scannerWithString:string]; + if (![scanner scanDouble:&value]) + printf ("scanDouble of `%s' failed.\n", [string cString]); + else if ((error = areDoublesEqual (value, expect)) > DoubleCompareEqual) + printf ("scanDouble of `%s' returned value %.*e (%g LSB different).\n", + [string cString], DBL_DIG + 2, value, error); + scanLocation = [scanner scanLocation]; + if (scanLocation != length) + printf ("scanDouble of `%s' moves scan location to %u.\n", [string cString], scanLocation); +} + +void +testScanDoubleBad (NSString *string) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + double value; + unsigned int scanLocation; + + if ([scanner scanDouble:&value]) + printf ("scanDouble of `%s' succeeded with value %g\n", [string cString], value); + scanLocation = [scanner scanLocation]; + if (scanLocation != 0) + printf ("scanDouble of `%s' moves scan location to %u.\n", [string cString], scanLocation); +} + +/* + * Test scanDouble operations + */ +void +testScanDouble (void) +{ + int i; + + /* + * Check all digits before and after decimal point + */ + for (i = 0 ; i < 10 ; i++) { + testScanDoubleOneDigit (@"%d", i, i); + testScanDoubleOneDigit (@"%d.", i, i); + testScanDoubleOneDigit (@"%d.0", i, i); + testScanDoubleOneDigit (@"0%d.0", i, i); + testScanDoubleOneDigit (@".%d", i, i / 10.0); + testScanDoubleOneDigit (@"0.%d", i, i / 10.0); + + testScanDoubleOneDigit (@"-%d", i, -i); + testScanDoubleOneDigit (@"-%d.", i, -i); + testScanDoubleOneDigit (@"-%d.0", i, -i); + testScanDoubleOneDigit (@"-0%d.0", i, -i); + testScanDoubleOneDigit (@"-.%d", i, -i / 10.0); + testScanDoubleOneDigit (@"-0.%d", i, -i / 10.0); + } + + /* + * Check exponents + */ + testScanDoubleGood (@"1e0", 1); + testScanDoubleGood (@"1e1", 10); + testScanDoubleGood (@"1e+1", 10); + testScanDoubleGood (@"1e10", 1e10); + testScanDoubleGood (@"1e+10", 1e10); + testScanDoubleGood (@"1e-0", 1); + testScanDoubleGood (@"1e-1", 1e-1); + testScanDoubleGood (@"1e-1", 1e-1); + testScanDoubleGood (@"1e-10", 1e-10); + testScanDoubleGood (@"1e-10", 1e-10); + + /* + * Check a few other values + */ + testScanDoubleGood (@"123.456", 123.456); + testScanDoubleGood (@"123.4567890123456789012345678901234567890123456789", + 123.4567890123456789012345678901234567890123456789); + testScanDoubleGood (@"1234567890123456789012345678.9", + 1234567890123456789012345678.9); + testScanDoubleGood (@"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890e-99", + 1.234567890123456789012345678901234567890123456789); + testScanDoubleGood (@"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456789e+100", + 1.23456789); + + /* + * Check some overflow values (for IEEE double-precision) + */ + testScanDoubleGood (@"12345678901234567890123456789012345678901234567890e300", HUGE_VAL); + testScanDoubleGood (@"-12345678901234567890123456789012345678901234567890e300", -HUGE_VAL); + testScanDoubleGood (@"1e999", HUGE_VAL); + testScanDoubleGood (@"-1e999", -HUGE_VAL); + + /* + * Check some underflow values + */ + testScanDoubleGood (@"0.00000000000000000000000000000123456789e-300", 0); + testScanDoubleGood (@"-0.00000000000000000000000000000123456789e-300", 0); + testScanDoubleGood (@"1e-999", 0); + testScanDoubleGood (@"-1e-999", 0); + + /* + * Check that non-digits terminate the scan + */ + testScanDoubleShort (@"1234FOO", 1234, 4); + testScanDoubleShort (@"1234.FOO", 1234, 5); + testScanDoubleShort (@"1234.0FOO", 1234, 6); + testScanDoubleShort (@"1234..FOO", 1234, 5); + testScanDoubleShort (@"1234.5.FOO", 1234.5, 6); + + /* + * Check that non-digits don't move the scan location + */ + testScanDoubleBad (@".foo"); + testScanDoubleBad (@"efoo"); + testScanDoubleBad (@".efoo"); + testScanDoubleBad (@"1234.5e.FOO"); + testScanDoubleBad (@"1234.5e.FOO"); + testScanDoubleBad (@"1234.5e 1"); +} + +/* + ************************************************************************ + * scanString: * + ************************************************************************ + */ +void +testScanStringGood (NSString *string, NSString *search, NSString *match, + BOOL caseSensitive, unsigned int goodScanLocation) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + [scanner setCaseSensitive:caseSensitive]; + if ([scanner scanString:search intoString:&s]) { + if (([scanner scanLocation] != goodScanLocation) + || ![s isEqualToString:match]) + printf ("Case-%ssensitive scanString `%s' of `%s' gives `%s', scanLocation %d.\n", + caseSensitive ? "" : "in", + [search cString], + [string cString], + [s cString], + [scanner scanLocation]); + } + else { + printf ("Case-%ssensitive scanString:`%s' of `%s' failed.\n", + caseSensitive ? "" : "in", + [search cString], + [string cString]); + } +} + +void +testScanStringBad (NSString *string, NSString *search, BOOL caseSensitive) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + [scanner setCaseSensitive:caseSensitive]; + if ([scanner scanString:search intoString:&s]) { + printf ("Case-%ssensitive scanString `%s' of `%s' gives `%s'.\n", + caseSensitive ? "" : "in", + [search cString], + [string cString], + [s cString]); + } + else { + if ([scanner scanLocation] != 0) + printf ("Case-%ssensitive scanString `%s' of `%s' moves scan location to `%d'.\n", + caseSensitive ? "" : "in", + [search cString], + [string cString], + [scanner scanLocation]); + } +} + +void +testScanString (void) +{ + testScanStringGood (@"a", @"a", @"a", NO, 1); + testScanStringGood (@"a", @"a", @"a", YES, 1); + testScanStringGood (@"a", @"A", @"a", NO, 1); + testScanStringGood (@" abcdefg", @"aBcD", @"abcd", NO, 7); + testScanStringGood (@" ABCdEFG", @"aBcD", @"ABCd", NO, 7); + testScanStringBad (@"a", @"A", YES); + testScanStringBad (@" a", @"A", YES); + testScanStringBad (@" aA", @"A", YES); + testScanStringBad (@" aAb", @"b", NO); +} + +/* + ************************************************************************ + * scanUpToString: * + ************************************************************************ + */ +void +testScanUpToStringGood (NSString *string, NSString *search, NSString *match, BOOL caseSensitive) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + [scanner setCaseSensitive:caseSensitive]; + if ([scanner scanUpToString:search intoString:&s]) { + if (![s isEqualToString:match]) + printf ("Case-%ssensitive scanUpToString `%s' of `%s' gives `%s'.\n", + caseSensitive ? "" : "in", + [search cString], + [string cString], + [s cString]); + } + else { + printf ("Case-%ssensitive scanUpToString:`%s' of `%s' failed.\n", + caseSensitive ? "" : "in", + [search cString], + [string cString]); + } +} + +void +testScanUpToString (void) +{ + testScanUpToStringGood (@"abcdefg", @"d", @"abc", NO); + testScanUpToStringGood (@"abcdefg", @"de", @"abc", NO); + testScanUpToStringGood (@"abcdefg", @"DeF", @"abcdefg", YES); + testScanUpToStringGood (@"abcdefgDeFg", @"DeF", @"abc", NO); + testScanUpToStringGood (@"abcdefgDeFg", @"DeF", @"abcdefg", YES); +} + +/* + ************************************************************************ + * scanCharactersFromSet: * + ************************************************************************ + */ +void +testScanCharactersFromSetGood (NSString *string, NSCharacterSet *set, + NSString *match, unsigned int goodScanLocation) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + if ([scanner scanCharactersFromSet:set intoString:&s]) { + if (([scanner scanLocation] != goodScanLocation) + || ![s isEqualToString:match]) + printf ("scanCharactersFromSet of `%s' gives `%s', scanLocation %d.\n", + [string cString], + [s cString], + [scanner scanLocation]); + } + else { + printf ("scanCharactersFromSet of `%s' failed.\n", [string cString]); + } +} + +void +testScanCharactersFromSetBad (NSString *string, NSCharacterSet *set) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + if ([scanner scanCharactersFromSet:set intoString:&s]) { + printf ("scanCharactersFromSet of `%s' gives `%s'.\n", + [string cString], + [s cString]); + } + else { + if ([scanner scanLocation] != 0) + printf ("scanCharactersFromSet of `%s' moves scan location to `%d'.\n", + [string cString], + [scanner scanLocation]); + } +} + +void +testScanCharactersFromSet (void) +{ + NSCharacterSet *set = [NSCharacterSet uppercaseLetterCharacterSet]; + + testScanCharactersFromSetGood (@"A", set, @"A", 1); + testScanCharactersFromSetGood (@"ABCde", set, @"ABC", 3); + testScanCharactersFromSetGood (@"ABC", set, @"ABC", 3); + testScanCharactersFromSetGood (@" AB12", set, @"AB", 4); + testScanCharactersFromSetBad (@"a", set); + testScanCharactersFromSetBad (@" abc", set); +} + +/* + ************************************************************************ + * scanUpToCharactersFromSet: * + ************************************************************************ + */ +void +testScanUpToCharactersFromSetGood (NSString *string, NSCharacterSet *set, + NSString *match, unsigned int goodScanLocation) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + if ([scanner scanUpToCharactersFromSet:set intoString:&s]) { + if (([scanner scanLocation] != goodScanLocation) + || ![s isEqualToString:match]) + printf ("scanUpToCharactersFromSet of `%s' gives `%s', scanLocation %d.\n", + [string cString], + [s cString], + [scanner scanLocation]); + } + else { + printf ("scanUpToCharactersFromSet of `%s' failed.\n", [string cString]); + } +} + +void +testScanUpToCharactersFromSetBad (NSString *string, NSCharacterSet *set) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + NSString *s; + + if ([scanner scanUpToCharactersFromSet:set intoString:&s]) { + printf ("scanUpToCharactersFromSet of `%s' gives `%s'.\n", + [string cString], + [s cString]); + } + else { + if ([scanner scanLocation] != 0) + printf ("scanUpToCharactersFromSet of `%s' moves scan location to `%d'.\n", + [string cString], + [scanner scanLocation]); + } +} + +void +testScanUpToCharactersFromSet (void) +{ + NSCharacterSet *set = [NSCharacterSet uppercaseLetterCharacterSet]; + + testScanUpToCharactersFromSetGood (@"aA", set, @"a", 1); + testScanUpToCharactersFromSetGood (@" aABCde", set, @"a", 3); + testScanUpToCharactersFromSetGood (@"abc", set, @"abc", 3); + testScanUpToCharactersFromSetGood (@" abAB12", set, @"ab", 4); + testScanUpToCharactersFromSetBad (@"A", set); + testScanUpToCharactersFromSetBad (@" Abc", set); +} + +/* + ************************************************************************ + * TEST DRIVER * + ************************************************************************ + */ +void +runtest (void (*test)(void)) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + (*test)(); + [arp release]; +} + +int +main (int argc, char **argv) +{ + extern char *optarg; + int c; + + while ((c = getopt (argc, argv, "e:")) != EOF) { + switch (c) { + case 'e': + DoubleCompareEqual = atoi (optarg); + break; + } + } + + runtest (testScanInt); + runtest (testScanRadixUnsignedInt); + runtest (testScanHexInt); +#if defined (LONG_LONG_MAX) + runtest (testScanLongLong); +#endif + runtest (testScanDouble); + runtest (testScanString); + runtest (testScanUpToString); + runtest (testScanCharactersFromSet); + runtest (testScanUpToCharactersFromSet); + printf("Finished Tests\n"); + return 0; +} diff --git a/Testing/nsset.m b/Testing/nsset.m new file mode 100644 index 000000000..3fcdaa52c --- /dev/null +++ b/Testing/nsset.m @@ -0,0 +1,129 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include + +void original_test (); +void intersects_set_test(); +void is_subset_of_set_test (); + +int +main () +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + original_test (); + intersects_set_test (); + is_subset_of_set_test (); + + printf("Test passed\n"); + [arp release]; + exit (0); +} + +void +original_test () +{ + id a, s1, s2; + id enumerator; + + a = [NSArray arrayWithObjects: + @"vache", @"poisson", @"cheval", @"poulet", nil]; + + s1 = [NSSet setWithArray:a]; + + assert ([s1 member:@"vache"]); + assert ([s1 containsObject:@"cheval"]); + assert ([s1 count] == 4); + + enumerator = [s1 objectEnumerator]; + while ([[enumerator nextObject] description]); + + s2 = [s1 mutableCopy]; + assert ([s1 isEqual:s2]); +} + +void +intersects_set_test() +{ + id a1 = [NSArray arrayWithObjects: @"abstract factory", @"builder", + @"factory method", @"prototype", @"singleton", nil]; + id s1 = [NSSet setWithArray: a1]; + + id a2 = [NSArray arrayWithObjects: @"adapter", @"bridge", @"composite", + @"decorator", @"facade", @"flyweight", @"Proxy", nil]; + id s2 = [NSSet setWithArray: a2]; + + id s3 = [NSSet setWithObjects: @"abstract factory", @"adapter", nil]; + id s4 = [NSSet setWithObject: @"chain of responsibility"]; + + id s5 = [NSSet set]; + assert (![s1 intersectsSet: s2]); + assert (![s2 intersectsSet: s1]); + + assert ([s1 intersectsSet: s3]); + assert ([s2 intersectsSet: s3]); + assert ([s3 intersectsSet: s1]); + assert ([s3 intersectsSet: s2]); + + assert (![s1 intersectsSet: s4]); + assert (![s2 intersectsSet: s4]); + assert (![s4 intersectsSet: s1]); + assert (![s4 intersectsSet: s2]); + + assert (![s1 intersectsSet: s5]); + assert (![s2 intersectsSet: s5]); + assert (![s3 intersectsSet: s5]); + assert (![s4 intersectsSet: s5]); + assert (![s5 intersectsSet: s5]); + + assert (![s5 intersectsSet: s1]); + assert (![s5 intersectsSet: s2]); + assert (![s5 intersectsSet: s3]); + assert (![s5 intersectsSet: s4]); + assert (![s5 intersectsSet: s5]); +} + +void +is_subset_of_set_test () +{ + id a1 = [NSArray arrayWithObjects: @"abstract factory", @"builder", + @"factory method", @"prototype", @"singleton", nil]; + id s1 = [NSSet setWithArray: a1]; + + id a2 = [NSArray arrayWithObjects: @"adapter", @"bridge", @"composite", + @"decorator", @"facade", @"flyweight", @"proxy", nil]; + id s2 = [NSSet setWithArray: a2]; + + id s3 = [NSSet setWithObjects: @"abstract factory", nil]; + id s4 = [NSSet setWithObjects: @"adapter", @"proxy", nil]; + id s5 = [NSSet setWithObject: @"chain of responsibility"]; + + id s6 = [NSSet set]; + + assert ([s3 isSubsetOfSet: s1]); + assert ([s4 isSubsetOfSet: s2]); + assert ([s6 isSubsetOfSet: s1]); + assert ([s6 isSubsetOfSet: s2]); + assert ([s6 isSubsetOfSet: s3]); + assert ([s6 isSubsetOfSet: s4]); + assert ([s6 isSubsetOfSet: s5]); + assert ([s6 isSubsetOfSet: s6]); + + assert (![s1 isSubsetOfSet: s6]); + assert (![s1 isSubsetOfSet: s5]); + assert (![s1 isSubsetOfSet: s4]); + assert (![s1 isSubsetOfSet: s3]); + assert (![s1 isSubsetOfSet: s2]); + +} diff --git a/Testing/nstask.m b/Testing/nstask.m new file mode 100644 index 000000000..66db24e5a --- /dev/null +++ b/Testing/nstask.m @@ -0,0 +1,91 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include + + +@interface TaskObs : NSObject +- (void) terminated: (NSNotification*)aNotification; +@end +@implementation TaskObs +- (void) terminated: (NSNotification*)aNotification +{ + NSLog(@"Task (%@) terminated", [aNotification object]); +} +@end + +int +main() +{ + NSAutoreleasePool *pool; + NSDictionary *env; + NSTask *task; + NSTask *t0, *t1; + NSData *d; + TaskObs *obs = [TaskObs new]; + + pool = [NSAutoreleasePool new]; + [[NSNotificationCenter defaultCenter] + addObserver: obs + selector: @selector(terminated:) + name: NSTaskDidTerminateNotification + object: nil]; + +#ifdef __MINGW32__ + task = [NSTask launchedTaskWithLaunchPath: @"C:\\windows\\system32\\mem.exe" + arguments: nil]; +#else + task = [NSTask launchedTaskWithLaunchPath: @"/bin/ls" + arguments: nil]; +#endif + [task waitUntilExit]; + printf("Exit status - %d\n", [task terminationStatus]); fflush(stdout); + + RELEASE(pool); + pool = [NSAutoreleasePool new]; + + task = [NSTask new]; + env = [[[[NSProcessInfo processInfo] environment] mutableCopy] autorelease]; + [task setEnvironment: env]; + [task setLaunchPath: @"/bin/sh"]; + [task setArguments: [NSArray arrayWithObjects: @"-c", @"echo $PATH", nil]]; + if ([task usePseudoTerminal] == NO) + printf("Argh - unable to use pseudo terminal\n"); + [task launch]; + d = [[task standardOutput] availableData]; + NSLog(@"Got PATH of '%*s'", [d length], [d bytes]); + + [task waitUntilExit]; + RELEASE(task); + + NSLog(@"Testing two tasks at the same time"); + t0 = [NSTask launchedTaskWithLaunchPath: @"/bin/sh" + arguments: + [NSArray arrayWithObjects: @"-c", @"echo task0", nil]]; + NSLog(@"Launched task0 - %@", t0); + + t1 = [NSTask launchedTaskWithLaunchPath: @"/bin/sh" + arguments: + [NSArray arrayWithObjects: @"-c", @"echo task1", nil]]; + NSLog(@"Launched task1 - %@", t1); + + while ([t0 isRunning] == YES || [t1 isRunning] == YES) + { + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: + [NSDate dateWithTimeIntervalSinceNow: 1]]; + RELEASE(arp); + } + RELEASE(pool); + + exit(0); +} + diff --git a/Testing/nstimer.m b/Testing/nstimer.m new file mode 100644 index 000000000..3d0917c2d --- /dev/null +++ b/Testing/nstimer.m @@ -0,0 +1,77 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include + +@interface TestDouble : NSObject ++ (double) testDouble; +- (double) testDoubleInstance; +@end +@implementation TestDouble ++ (void) sayCount +{ + static int count = 0; + printf ("Timer fired %d times\n", ++count); + if (count == 20) + exit(0); +} ++ (double) testDouble +{ + return 12345678912345.0; +} +- (double) testDoubleInstance +{ + return 92345678912345.0; +} +@end + +double test_double () +{ + return 92345678912345.0; +} + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + volatile double foo, bar; + id inv; + id o; + id d; + + inv = [NSInvocation invocationWithMethodSignature: + [TestDouble methodSignatureForSelector: @selector(sayCount)]]; + [inv setSelector: @selector(sayCount)]; + [inv setTarget: [TestDouble class]]; + + foo = [TestDouble testDouble]; + printf ("TestDouble is %f\n", foo); + foo = [TestDouble testDouble]; + printf ("TestDouble 2 is %f\n", foo); + o = [[TestDouble alloc] init]; + bar = [o testDoubleInstance]; + printf ("testDouble is %f\n", bar); + + foo = test_double (); + printf ("test_double is %f\n", foo); + + d = [NSDate date]; + printf ("time interval since now %f\n", [d timeIntervalSinceNow]); + + [NSTimer scheduledTimerWithTimeInterval: 3.0 + invocation: inv + repeats: YES]; + [[NSRunLoop currentRunLoop] run]; + [arp release]; + exit (0); +} diff --git a/Testing/nstimezone.m b/Testing/nstimezone.m new file mode 100644 index 000000000..8f76a6328 --- /dev/null +++ b/Testing/nstimezone.m @@ -0,0 +1,53 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* Test time zone code. */ + +#include +#include +#include +#include +#include +#include +#include + +int +main () +{ + NSTimeZone *system; + NSTimeZone *other; + NSCalendarDate *date; + CREATE_AUTORELEASE_POOL(pool); + + GSPrintf(stdout, @"GMT time zone %x\n", + [NSTimeZone timeZoneWithAbbreviation:@"GMT"]); + GSPrintf(stdout, @"System time zone\n"); + system = [NSTimeZone systemTimeZone]; + GSPrintf(stdout, @" %@\n\n", [system description]); + + GSPrintf(stdout, @"Local time zone:\n %@\n\n", + [[NSTimeZone localTimeZone] description]); + + GSPrintf(stdout, @"Time zone for PST (from dict):\n %@\n", + [[NSTimeZone abbreviationDictionary] objectForKey: @"PST"]); + GSPrintf(stdout, @"Time zones for PST (from map):\n %@\n", + [[[NSTimeZone abbreviationMap] objectForKey: @"PST"] description]); + + other = [NSTimeZone timeZoneWithAbbreviation: @"CEST"]; + GSPrintf(stdout, @"Time zone for CEST:\n %@\n", other); + + date = [[NSCalendarDate alloc] initWithString:@"09/04/2003 17:58:45 CEST" + calendarFormat:@"%m/%d/%Y %H:%M:%S %Z"]; + GSPrintf(stdout, @"Date in CEST:\n %@\n", date); + + + RELEASE(pool); + return 0; +} diff --git a/Testing/nsundomanager.m b/Testing/nsundomanager.m new file mode 100644 index 000000000..f0018e005 --- /dev/null +++ b/Testing/nsundomanager.m @@ -0,0 +1,53 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ + +#include + +@interface UndoObject: NSObject +{ + int state; +} +- (void) setState: (int)aState; +- (int) state; +@end +@implementation UndoObject +- (void) setState: (int)aState +{ + state = aState; +} +- (int) state +{ + return state; +} +@end + +int +main () +{ + CREATE_AUTORELEASE_POOL(arp); + NSUndoManager *u = [NSUndoManager new]; + UndoObject *o = [UndoObject new]; + BOOL failed = NO; + + [u registerUndoWithTarget: o selector: @selector(setState:) object: (id)1]; + [u undo]; + if ([o state] != 1) + { + NSLog(@"Failed undo"); + failed = YES; + } + RELEASE(arp); + if (failed == NO) + { + NSLog(@"Test passed"); + } + exit (0); +} diff --git a/Testing/nsxmlparser.m b/Testing/nsxmlparser.m new file mode 100644 index 000000000..c27ec24c9 --- /dev/null +++ b/Testing/nsxmlparser.m @@ -0,0 +1,131 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include + +@interface MyDelegate : NSObject +{ + BOOL problem; + unsigned startDoc; + unsigned endDoc; + unsigned startElem; + unsigned endElem; +} +- (BOOL) check; +@end + +@implementation MyDelegate +- (BOOL) check +{ + if (startDoc != 1) + { + problem = YES; + NSLog(@"Missing start doc"); + } + if (endDoc != 1) + { + problem = YES; + NSLog(@"Missing end doc"); + } + if (startElem != 1) + { + problem = YES; + NSLog(@"Missing start element"); + } + if (endElem != 1) + { + problem = YES; + NSLog(@"Missing end element"); + } + return problem; +} + +- (void) parserDidEndDocument: (NSXMLParser*)aParser +{ + endDoc++; +} +- (void) parserDidStartDocument: (NSXMLParser*)aParser +{ + startDoc++; +} + +- (void) parser: (NSXMLParser*)aParser + didStartElement: (NSString*)anElementName + namespaceURI: (NSString*)aNamespaceURI + qualifiedName: (NSString*)aQualifierName + attributes: (NSDictionary*)anAttributeDict +{ + if (startElem == 0) + { + startElem++; + if ([anElementName isEqual: @"example"] == NO) + NSLog(@"Bad start element '%@' in namespace '%@' '%@' attributes '%@'", + anElementName, aNamespaceURI, aQualifierName, anAttributeDict); + } + else + { + NSLog(@"Extra start element '%@' in namespace '%@' '%@' attributes '%@'", + anElementName, aNamespaceURI, aQualifierName, anAttributeDict); + } +} + + +- (void) parser: (NSXMLParser*)aParser + didEndElement: (NSString*)anElementName + namespaceURI: (NSString*)aNamespaceURI + qualifiedName: (NSString*)aQualifierName +{ + if (endElem == 0) + { + endElem++; + if ([anElementName isEqual: @"example"] == NO) + NSLog(@"Bad end element '%@' in namespace '%@' '%@'", + anElementName, aNamespaceURI, aQualifierName); + } + else + { + NSLog(@"Extra end element '%@' in namespace '%@' '%@'", + anElementName, aNamespaceURI, aQualifierName); + } +} + + +@end + +int main () +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSData *document; + MyDelegate *delegate; + NSXMLParser *parser; + const char *str = +"" +"" +""; + + document = [NSData dataWithBytes: str length: strlen(str)]; + parser = [[NSXMLParser alloc] initWithData: document]; + delegate = [MyDelegate new]; + [parser setDelegate: delegate]; + [parser setShouldProcessNamespaces: YES]; + + if ([parser parse] == NO) + { + NSLog(@"Failed to parse example document"); + } + else if ([delegate check] == NO) + { + NSLog(@"All correct."); + } + [parser release]; + [pool release]; + return 0; +} + diff --git a/Testing/nxst.m b/Testing/nxst.m new file mode 100644 index 000000000..87fb4bcee --- /dev/null +++ b/Testing/nxst.m @@ -0,0 +1,41 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* Test NXStringTable class. */ + +#include +#include + +int +main(int argc, char *argv[]) +{ + id table; + int i, times; + + if (argc < 2) { + fprintf(stderr, "Usage: table_test filename repeat\n"); + fprintf(stderr, " filename is a stringtable format file.\n"); + fprintf(stderr, " repeat is a number of times to loop\n"); + exit(1); + } + if (argc == 3) + times = atoi(argv[2]); + else + times = 1; + + table = [[NXStringTable alloc] init]; + + for (i=0; i < times; i++) { + [table readFromFile:argv[1]]; + printf("-----------------------------------------\n"); + [table writeToStream:stdout]; + } + return 0; +} diff --git a/Testing/oldserver.h b/Testing/oldserver.h new file mode 100644 index 000000000..f2d3bb4c2 --- /dev/null +++ b/Testing/oldserver.h @@ -0,0 +1,74 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#ifndef _server_h +#define _server_h + +#include +#include +#include + +typedef struct _small_struct { + unsigned char z; +} small_struct; + +typedef struct _foo { + int i; + char *s; + unsigned long l; +} foo; + +struct myarray { + int a[3]; +}; + +@protocol ServerProtocol +- (void) addObject: o; +- objectAt: (unsigned)i; +- (unsigned) count; +- print: (const char *)msg; +- getLong: (out unsigned long*)i; +- (oneway void) shout; +- callbackNameOn: obj; +- bounce: sender count: (int)c; +- (BOOL) doBoolean: (BOOL)b; +- getBoolean: (BOOL*)bp; +- getUCharPtr: (unsigned char *)ucp; +- (foo*) sendStructPtr: (foo*)f; +- sendStruct: (foo)f; +- sendSmallStruct: (small_struct)small; +- (foo) returnStruct; +- sendArray: (int[3])a; +- sendStructArray: (struct myarray)ma; +- sendDouble: (double)d andFloat: (float)f; +- (double*) doDoublePointer: (double*)d; +- sendCharPtrPtr: (char**)sp; +- sendBycopy: (bycopy id)o; +- manyArgs: (int)i1 : (int)i2 : (int)i3 : (int)i4 : (int)i5 : (int)i6 +: (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12; +- (float) returnFloat; +- (double) returnDouble; +@end + +#if NeXT_runtime +@protocol AllProxies +- (const char *)name; +- (unsigned) hash; +- self; +@end +#endif + +@interface Server : NSObject +{ + id the_array; +} +@end + +#endif /* _server_h */ diff --git a/Testing/prepend.m b/Testing/prepend.m new file mode 100644 index 000000000..c33779486 --- /dev/null +++ b/Testing/prepend.m @@ -0,0 +1,59 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* +From: Matthias Klose +Date: Mon, 1 Aug 1994 21:17:20 +0200 +To: mccallum@cs.rochester.edu +Subject: bug in libcoll-940725 +Reply-to: doko@cs.tu-berlin.de + +Hello, the following code core dumps on Solaris 2.3 (compiled with gcc +2.5.8 -g -O and with -g) and on NeXTstep 3.2 (gcc 2.5.8). +Any hints? +*/ + +#include +#include +#include + +int main () +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + Array *a; + CircularArray *c; + Queue *q; + + a = [Array new]; + + [a prependObject: [NSObject new]]; + [a prependObject: [NSObject new]]; + [a prependObject: [NSObject new]]; + printf("count: %d\n", [a count]); + [a insertObject: [NSObject new] atIndex: 2]; // ok! + printf("count: %d\n", [a count]); + + c = [CircularArray new]; + [c prependObject: [NSNumber numberWithInt:3]]; + [c prependObject: [NSNumber numberWithInt:2]]; + [c prependObject: [NSNumber numberWithInt:1]]; + [c insertObject:[NSNumber numberWithInt:0] atIndex:2]; // core dump! + + q = [Queue new]; + [q enqueueObject: [NSObject new]]; + [q enqueueObject: [NSObject new]]; + [q enqueueObject: [NSObject new]]; + printf("count: %d\n", [q count]); + [q insertObject: [NSObject new] atIndex: 2]; // core dump! + printf("count: %d\n", [q count]); + + [pool release]; + exit (0); +} diff --git a/Testing/randoms.m b/Testing/randoms.m new file mode 100644 index 000000000..ab90ada90 --- /dev/null +++ b/Testing/randoms.m @@ -0,0 +1,45 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ + +#include +#include +#include + +int main() +{ + id r; + id rng; + int i; + + r = [[Random alloc] init]; + printf("float\n"); + for (i = 0; i < 20; i++) + printf("%f\n", [r randomFloat]); + printf("doubles\n"); + for (i = 0; i < 20; i++) + printf("%f\n", [r randomDouble]); + + rng = [[RNGBerkeley alloc] init]; + printf("%s chi^2 = %f\n", + [rng name], [Random chiSquareOfRandomGenerator:rng]); + [r release]; + + rng = [[RNGAdditiveCongruential alloc] init]; +/* + for (i = 0; i < 50; i++) + printf("%ld\n", [r nextRandom]); +*/ + printf("%s chi^2 = %f\n", + [rng name], [Random chiSquareOfRandomGenerator:rng]); + [rng release]; + + exit(0); +} diff --git a/Testing/release.m b/Testing/release.m new file mode 100644 index 000000000..64d794e0c --- /dev/null +++ b/Testing/release.m @@ -0,0 +1,153 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include + +@interface ReleaseTester : NSObject +{ + int label; +} +@end + +@implementation ReleaseTester + +- initWithLabel: (int)l +{ + label = l; + return self; +} + +- (oneway void) release +{ + // printf ("release'ing %d\n", label); + [super release]; +} + +- (void) dealloc +{ + // printf ("dealloc'ing %d\n", label); + [super dealloc]; +} + +@end + +void +autorelease_test (int depth) +{ + int n = 2; + id os[n]; + id a = [NSMutableArray new]; + int i; + id arp; + + if (depth < 0) + return; + + arp = [[NSAutoreleasePool alloc] init]; + + for (i = 0; i < n; i++) + { + id r = [[[ReleaseTester alloc] initWithLabel: i+depth*n] autorelease]; + os[i] = r; + [a addObject: r]; + } + +#if 0 + fprintf (stderr, "totalAutoreleasedObjects %d\n", + [NSAutoreleasePool totalAutoreleasedObjects]); +#endif + autorelease_test (depth-1); + + [a release]; + + [arp release]; + + fflush (stdin); +} + +void +release_test (int depth) +{ + int n = 1000; + id os[n]; + int i; + + if (depth < 0) + return; + + for (i = 0; i < n; i++) + os[i] = [[ReleaseTester alloc] initWithLabel: i]; + for (i = 0; i < n; i++) + [os[i] retain]; + for (i = 0; i < n; i++) + [os[i] release]; + for (i = 0; i < n; i++) + [os[i] release]; + + release_test (depth-1); +} + + +#if GNU_LIBC +static void *(*old_malloc_hook) (size_t); +static void (*old_free_hook) (void *ptr); + +static void * +my_malloc_hook (size_t size) +{ + void *result; + __malloc_hook = old_malloc_hook; + result = malloc (size); + /* `printf' might call `malloc', so protect it too. */ + printf ("malloc (%u) returns %p\n", (unsigned int) size, result); + __malloc_hook = my_malloc_hook; + return result; +} + +void +my_free_hook (void *ptr) +{ + __free_hook = old_free_hook; + free (ptr); + __free_hook = my_free_hook; +} +#endif /* GNU_LIBC */ + +int +main () +{ + int i; + +#if GNU_LIBC + old_malloc_hook = __malloc_hook; + old_free_hook = __free_hook; + __malloc_hook = my_malloc_hook; + __free_hook = my_free_hook; +#endif /* GNU_LIBC */ + +#if 1 + for (i = 0; i < 10000; i++) + autorelease_test (3); +#else + /* Checking for memory leak in objc_mutex_lock() */ + _objc_mutex_t gate; + gate = objc_mutex_allocate (); + for (i = 0; i < 1000000; i++) + { + objc_mutex_lock (gate); + objc_mutex_unlock (gate); + } +#endif + + printf("Tests finished\n"); + exit (0); +} diff --git a/Examples/server.h b/Testing/server.h similarity index 95% rename from Examples/server.h rename to Testing/server.h index 90b832402..26fa20f50 100644 --- a/Examples/server.h +++ b/Testing/server.h @@ -11,15 +11,9 @@ #ifndef _server_h #define _server_h +#include #include -@interface NSConnection (Debug) -+ (void) setDebug: (BOOL)aFlag; -@end -@interface NSDistantObject (Debug) -+ (void) setDebug: (BOOL)aFlag; -@end - typedef struct _small_struct { unsigned char z; } small_struct; diff --git a/Testing/string.m b/Testing/string.m new file mode 100644 index 000000000..d62f11c9a --- /dev/null +++ b/Testing/string.m @@ -0,0 +1,153 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include + +// Fri Oct 23 02:58:47 MET DST 1998 dave@turbocat.de +// cStringNoCopy -> cString + +/* For demo of Strings as Collections of char's. */ +#include +#include + +void +print_string(NSString* s) +{ + printf("The string [%s], length %d\n", [s lossyCString], [s length]); +} + +#include +#include + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id s = @"This is a test string"; + id s2, s3; + unichar u0[5] = { 0xFE66, 'a', 'b', 'c', 'd'}; + unichar u1[6] = { '1', '2', '.', '3', '4', 0xFE66}; + unichar u2[7] = { 'a', 'b', 0xFE66, 'a', 'b', 'c', 'd'}; + NSString *us0 = [NSString stringWithCharacters: u0 length: 5]; + NSString *us1 = [NSString stringWithCharacters: u1 length: 6]; + NSString *us2 = [NSString stringWithCharacters: u2 length: 7]; + NSMutableString *fo = [NSMutableString stringWithString: @"abcdef"]; + NSMutableString *f1 = [NSMutableString stringWithString: @"ab"]; + NSStringEncoding *encs; + +{ + NSURL *currentURL; + NSData *data; + + currentURL = [NSURL URLWithString: + @"http:/www.foobar.org/PageWithAValid.plist"]; + data = [currentURL resourceDataUsingCache: NO]; + + if ( data ) + printf(" YES \n"); + printf(" NO\n"); +} +#if 0 +{ // GSM test + unichar buf[] = { 163, '[', ']', '{', '}', '\\', '^', '|', '~', '_' }; + NSString *str = [NSString stringWithCharacters: buf + length: sizeof(buf)/sizeof(unichar)]; + NSData *gsm = [str dataUsingEncoding: NSGSM0338StringEncoding]; + + NSLog(@"GSM: %*.*s", [gsm length], [gsm length], [gsm bytes]); + return 0; +} +#endif + + NS_DURING + [fo replaceCharactersInRange: [fo rangeOfString: @"xx"] withString: us1]; + NS_HANDLER + printf("Caught exception during string replacement (expected)\n"); + NS_ENDHANDLER + + [f1 appendString: us0]; + print_string(f1); + printf("%d\n", [f1 isEqual: us2]); + + print_string(s); + + s2 = NSStringFromPoint(NSMakePoint(1.374, 5.100)); + print_string(s2); + + printf("%f", [[NSString stringWithCharacters: u1 length: 5] floatValue]); + + s2 = [s copy]; + print_string(s2); + s3 = [s2 mutableCopy]; + [s2 release]; + s2 = [s3 copy]; + [s3 release]; + [s2 release]; + + s2 = [s copyWithZone: NSDefaultMallocZone ()]; + print_string(s2); + + s2 = [s stringByAppendingString:@" with something added"]; + print_string(s2); + + s2 = [s mutableCopy]; + [s2 replaceCharactersInRange:((NSRange){10,4}) + withString:@"changed"]; + print_string(s2); + +#if 0 + /* Test the use of the `%@' format directive. */ + s2 = [NSString stringWithFormat: @"foo %@ bar", + @"test"]; + print_string(s2); + + for (a = 0; a < 10; a++) + NSLog(@"A string with precision %d is :%.*@:", a, a, @"String"); +#endif + +{ + NSMutableString *base = [@"hello" mutableCopy]; + NSString *ext = [@"\"\\UFE66???\"" propertyList]; + NSString *want = [@"\"hello\\UFE66???\"" propertyList]; + int i; + + [base appendString: ext]; + printf("%u\n", [base length]); + printf("%u\n", [ext length]); + printf("%u\n", [want length]); + for (i = 0; i < 4; i++) + printf("%x\n", [ext characterAtIndex: i]); + for (i = 0; i < 9; i++) + printf("%x,%x\n", [base characterAtIndex: i], [want characterAtIndex: i]); + + printf("%u\n", [want isEqual: base]); + for (i = 0; i < 1000; i++) + [base appendString: want]; + print_string(base); + + encs = [NSString availableStringEncodings]; + while (*encs != 0) + printf("Encoding %x\n", *encs++); +} + + GSPrintf(stdout, @"\nStandardize Paths\n"); + s2 = @"../"; + GSPrintf(stdout, @"%@ becomes %@\n", + s2, [s2 stringByStandardizingPath]); + s2 = @"/usr/bin/../lib"; + GSPrintf(stdout, @"%@ becomes %@\n", + s2, [s2 stringByStandardizingPath]); + s2 = @"~/Public/../GNUstep"; + GSPrintf(stdout, @"%@ becomes %@\n", + s2, [s2 stringByStandardizingPath]); + + [arp release]; + exit(0); +} diff --git a/Testing/tcpport-client.m b/Testing/tcpport-client.m new file mode 100644 index 000000000..6188eb420 --- /dev/null +++ b/Testing/tcpport-client.m @@ -0,0 +1,67 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include +#include +#include +#include +#include + +id handle_incoming_packet (id packet) +{ + fprintf (stdout, "received >"); + fwrite ([packet streamBuffer] + [packet streamBufferPrefix], + [packet streamEofPosition], 1, stdout); + fprintf (stdout, "<\n"); + [packet release]; + return nil; +} + +int main (int argc, char *argv[]) +{ + id out_port; + id in_port; + id packet; + int i; + + if (argc > 1) + out_port = [TcpOutPort newForSendingToRegisteredName: + [NSString stringWithUTF8String: argv[1]] + onHost: @"localhost"]; + else + out_port = [TcpOutPort newForSendingToRegisteredName: @"tcpport-test" + onHost: nil]; + + in_port = [TcpInPort newForReceiving]; + + [in_port setReceivedPacketInvocation: + [[[ObjectFunctionInvocation alloc] + initWithObjectFunction: handle_incoming_packet] + autorelease]]; + + [[NSRunLoop currentRunLoop] addPort: in_port + forMode: NSDefaultRunLoopMode]; + + for (i = 0; i < 10; i++) + { + packet = [[TcpOutPacket alloc] initForSendingWithCapacity: 100 + replyInPort: in_port]; + [packet writeFormat: @"Here is message number %d", i]; + [out_port sendPacket: packet timeout: 10.0]; + [packet release]; + + [[NSRunLoop currentRunLoop] runUntilDate: + [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + } + + [out_port close]; + + exit (0); +} diff --git a/Testing/thread-except.m b/Testing/thread-except.m new file mode 100644 index 000000000..4020d1659 --- /dev/null +++ b/Testing/thread-except.m @@ -0,0 +1,105 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* Test whether each thread has their own exception handlers. */ + +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#include +#include +#include +#include +#include +#include + +#define N 10 /* Number of threads */ +#define MAX_ITER 10000.0 /* Max number of iterations. */ + +FILE *file; +int counter; + +@interface SingleThread : NSObject +{ + int ident; // Identifier +} + +- initWithInt: (int)n; +- (void)runWith: (id)thing; + +@end + +@implementation SingleThread + +- initWithInt: (int)n +{ + ident = n; + return self; +} + +- (void)runWith: (id)thing +{ + int i, n; + CREATE_AUTORELEASE_POOL(pool); + + NS_DURING + n = 1+(int)((MAX_ITER*rand())/(RAND_MAX+1.0)); + for (i = 0; i < n; i++) + { + fprintf(file, "%d ", i); + fflush(file); + } + [NSException raise: @"Some exception" format: @"thread %d", ident]; + NS_HANDLER + NSLog(@"%@ for thread %d\n", localException, ident); + NS_ENDHANDLER + DESTROY(pool); + counter--; + [NSThread exit]; +} + +@end + +int main() +{ + int i; + SingleThread *threads[N]; + CREATE_AUTORELEASE_POOL(pool); + + printf("We run %d threads.\n", N); + printf("Some of them might not raise exceptions,\n"); + printf("but the exception associated with each thread must match.\n"); + file = fopen("/dev/null", "w"); + srand(10); + + counter = N; + + for (i = 0; i < N; i++) + threads[i] = [[SingleThread alloc] initWithInt: i]; + NS_DURING + for (i = 0; i < N; i++) + [NSThread detachNewThreadSelector: @selector(runWith:) + toTarget: threads[i] withObject: nil]; + + // Hopefully this will end after all the other threads end. + for (i = 0; i < N*MAX_ITER && counter > 0; i++) + { + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + fprintf(file, "%d", i); + fflush(file); + } + NS_HANDLER + fprintf(stderr, "There's a runaway exception! Something is wrong!\n"); + NS_ENDHANDLER + fclose(file); + DESTROY(pool); + return 0; +} diff --git a/Testing/thread.m b/Testing/thread.m new file mode 100644 index 000000000..f0c93ea7e --- /dev/null +++ b/Testing/thread.m @@ -0,0 +1,125 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +#include + +NSLock *lock = nil; +unsigned retainReleaseThreads = 0; + +@interface XX : NSObject +- (void) fire; +- (void) retainRelease: (id)obj; +- (void) setup; +@end + +@implementation XX +- (void) fire +{ + NSLog(@"Got here"); +} +- (void) retainRelease: (id)obj +{ + unsigned i; + + NSLog(@"Start retain/releases in thread %@", [NSThread currentThread]); + for (i = 0; i < 1000000; i++) + { + [obj retain]; + [obj release]; + } + [lock lock]; + retainReleaseThreads++; + [lock unlock]; + NSLog(@"Done %d retain/releases in thread %@", i, [NSThread currentThread]); +} +- (void) setup +{ + CREATE_AUTORELEASE_POOL(arp); + + NSLog(@"Attempting to obtain lock to proceed"); + if ([lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 5.0]] == YES) + { + NSLog(@"Setup1"); + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + NSLog(@"Setup2"); + [self performSelectorOnMainThread: @selector(fire) + withObject: nil + waitUntilDone: NO]; + NSLog(@"Done perform no wait."); + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + NSLog(@"Setup3"); + [self performSelectorOnMainThread: @selector(fire) + withObject: nil + waitUntilDone: YES]; + NSLog(@"Done perform with wait."); + [lock unlock]; + } + else + { + NSLog(@"Failed to obtain lock"); + } + RELEASE(arp); + [NSThread exit]; +} +@end + +int main(int argc, char **argv, char **env) +{ + CREATE_AUTORELEASE_POOL(arp); + NSObject *o = [NSObject new]; + XX *x = [XX new]; + + NSLog(@"Start in main"); + lock = [NSLock new]; + [lock lock]; + + [NSThread detachNewThreadSelector: @selector(retainRelease:) + toTarget: x + withObject: o]; + [NSThread detachNewThreadSelector: @selector(retainRelease:) + toTarget: x + withObject: o]; + [NSThread detachNewThreadSelector: @selector(retainRelease:) + toTarget: x + withObject: o]; + [NSThread detachNewThreadSelector: @selector(retainRelease:) + toTarget: x + withObject: o]; + [NSThread detachNewThreadSelector: @selector(retainRelease:) + toTarget: x + withObject: o]; + + [NSThread detachNewThreadSelector: @selector(setup) + toTarget: x + withObject: nil]; + NSLog(@"Waiting to give thread time to start"); + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + NSLog(@"Releasing lock so thread may proceed"); + [lock unlock]; // Allow other thread to proceed. + + [[NSRunLoop currentRunLoop] runUntilDate: + [NSDate dateWithTimeIntervalSinceNow: 10.0]]; + + NSLog(@"Done main thread"); + + while (retainReleaseThreads < 5) + { + NSLog(@"Waiting for all 5 retainRelease threads to complete (%d)", + retainReleaseThreads); + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + } + if ([o retainCount] != 1) + { + NSLog(@"ERROR ... retain count is %d, expected 1", [o retainCount]); + } + DESTROY(arp); + return 0; +} + diff --git a/Testing/values.m b/Testing/values.m new file mode 100644 index 000000000..20455491d --- /dev/null +++ b/Testing/values.m @@ -0,0 +1,190 @@ +/* Test/example program for the base library + + Copyright (C) 2005 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + + This file is part of the GNUstep Base Library. +*/ +/* + Test NSValue, NSNumber, and related classes + +*/ + +#include +#include +#include +#include +#include +#include +#include + + +int main() +{ + NSPoint p; + NSRange range; + NSRect rect; + NSValue *v1, *v2; + NSNumber *nc, *ns, *n1, *n2, *n3, *n4, *n5, *n6, *n7; + NSMutableArray *a1, *a2; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + // Numbers + nc = [NSNumber numberWithChar: -100]; + ns = [NSNumber numberWithShort: -100]; +printf("try %d, %d", [nc charValue], [ns shortValue]); +printf("nc compare: ns is %d\n", [nc compare: ns]); + n1 = [NSNumber numberWithUnsignedShort: 30]; + if (strcmp([[n1 description] cString], "30") != 0) + printf("*** TEST FAILED **** description for unsigned short number\n"); + n2 = [NSNumber numberWithDouble: 2.7]; + if (strcmp([[n2 description] cString], "2.7") != 0) + printf("*** TEST FAILED **** description for double number\n"); + n3 = [NSNumber numberWithDouble: 30]; + if (strcmp([[n3 description] cString], "30") != 0) + printf("*** TEST FAILED **** description for double number\n"); + n4 = [NSNumber numberWithChar: 111]; + if (strcmp([[n4 description] cString], "111") != 0) + printf("*** TEST FAILED **** description for char number\n"); + n5 = [NSNumber numberWithChar: 111]; + if (strcmp([[n5 description] cString], "111") != 0) + printf("*** TEST FAILED **** description for unsigned char number\n"); + n6 = [NSNumber numberWithFloat: 1.5]; + if (strcmp([[n6 description] cString], "1.5") != 0) + printf("*** TEST FAILED **** description for float number\n"); + n7 = [NSNumber numberWithShort: 25]; + if (strcmp([[n7 description] cString], "25") != 0) + printf("*** TEST FAILED **** description for short number\n"); + + printf("Number(n1) as int %d, as float %f\n", + [n1 intValue], [n1 floatValue]); + printf("n1 times n2=%f as int to get %d\n", + [n2 floatValue], [n1 intValue]*[n2 intValue]); + printf("n2 as string: %s\n", [[n2 stringValue] cString]); + printf("n2 compare: n1 is %d\n", [n2 compare: n1]); + printf("n1 compare: n2 is %d\n", [n1 compare: n2]); + printf("n1 isEqual: n3 is %d\n", [n1 isEqual: n3]); + printf("n4 isEqual: n5 is %d\n", [n4 isEqual: n5]); + + a1 = [NSMutableArray arrayWithObjects: + [NSNumber numberWithChar: 111], + [NSNumber numberWithUnsignedChar: 112], + [NSNumber numberWithShort: 121], + [NSNumber numberWithUnsignedShort: 122], + [NSNumber numberWithInt: 131], + [NSNumber numberWithUnsignedInt: 132], + [NSNumber numberWithInt: 141], + [NSNumber numberWithUnsignedInt: 142], + [NSNumber numberWithFloat: 151], + [NSNumber numberWithDouble: 152], nil]; + + a2 = [NSMutableArray arrayWithObjects: + [NSNumber numberWithChar: 111], + [NSNumber numberWithUnsignedChar: 112], + [NSNumber numberWithShort: 121], + [NSNumber numberWithUnsignedShort: 122], + [NSNumber numberWithInt: 131], + [NSNumber numberWithUnsignedInt: 132], + [NSNumber numberWithInt: 141], + [NSNumber numberWithUnsignedInt: 142], + [NSNumber numberWithFloat: 151], + [NSNumber numberWithDouble: 152], nil]; + + printf("a1 isEqual: a2 is %d\n", [a1 isEqual: a2]); + + // Test values, Geometry + { + unsigned char v = 99; + v1 = [NSValue value: &v withObjCType: @encode(unsigned char)]; + [a1 addObject: v1]; + } + { + signed char v = 99; + v1 = [NSValue value: &v withObjCType: @encode(signed char)]; + [a1 addObject: v1]; + } + { + unsigned short v = 99; + v1 = [NSValue value: &v withObjCType: @encode(unsigned short)]; + [a1 addObject: v1]; + } + { + signed short v = 99; + v1 = [NSValue value: &v withObjCType: @encode(signed short)]; + [a1 addObject: v1]; + } + { + unsigned int v = 99; + v1 = [NSValue value: &v withObjCType: @encode(unsigned int)]; + [a1 addObject: v1]; + } + { + signed int v = 99; + v1 = [NSValue value: &v withObjCType: @encode(signed int)]; + [a1 addObject: v1]; + } + { + unsigned long v = 99; + v1 = [NSValue value: &v withObjCType: @encode(unsigned long)]; + [a1 addObject: v1]; + } + { + signed long v = 99; + v1 = [NSValue value: &v withObjCType: @encode(signed long)]; + [a1 addObject: v1]; + } + { + float v = 99; + v1 = [NSValue value: &v withObjCType: @encode(float)]; + [a1 addObject: v1]; + } + { + double v = 99; + v1 = [NSValue value: &v withObjCType: @encode(double)]; + [a1 addObject: v1]; + } + v1 = [NSValue valueWithPoint: NSMakePoint(1, 1)]; + [a1 addObject: v1]; + v1 = [NSValue valueWithRange: NSMakeRange(1, 1)]; + [a1 addObject: v1]; + rect = NSMakeRect(1.0, 103.3, 40.0, 843.); + rect = NSIntersectionRect(rect, NSMakeRect(20, 78., 89., 30)); + v1 = [NSValue valueWithRect: rect]; + [a1 addObject: v1]; + printf("Encoding for rect is %s\n", [v1 objCType]); + rect = [v1 rectValue]; + printf("Rect is %f %f %f %f\n", NSMinX(rect), NSMinY(rect), NSMaxX(rect), + NSMaxY(rect)); + v2 = [NSValue valueWithPoint: NSMakePoint(3,4)]; + [a1 addObject: v1]; + v1 = [NSValue valueWithNonretainedObject: v2]; + [[v1 nonretainedObjectValue] getValue: &p]; + printf("point is %f %f\n", p.x, p.y); + range = NSMakeRange(1, 103); + range = NSIntersectionRange(range, NSMakeRange(2, 73)); + v1 = [NSValue valueWithRange: range]; + [a1 addObject: v1]; + printf("Encoding for range is %s\n", [v1 objCType]); + range = [v1 rangeValue]; + printf("Range is %u %u\n", range.location, range.length); + + printf("Try getting a null NSValue, should get a NSLog error message: \n"); + v2 = [NSValue value: NULL withObjCType: @encode(int)]; + [a1 addObject: v1]; + + a2 = [NSUnarchiver unarchiveObjectWithData: + [NSArchiver archivedDataWithRootObject: a1]]; + + printf("After archiving, a1 isEqual: a2 is %d\n", [a1 isEqual: a2]); + if ([a1 isEqual: a2] == NO) + { + printf("a1 - %s\n", [[a1 description] cString]); + printf("a2 - %s\n", [[a2 description] cString]); + } + + [arp release]; + return 0; +} diff --git a/Examples/wgetopt.h b/Testing/wgetopt.h similarity index 94% rename from Examples/wgetopt.h rename to Testing/wgetopt.h index 792e6c446..f6165fc13 100644 --- a/Examples/wgetopt.h +++ b/Testing/wgetopt.h @@ -8,7 +8,7 @@ This file is part of the GNUstep Base Library. */ - +#if (defined __MINGW32__) /* A simple implementation of getopt() */ static int indexof(char c, char *string) @@ -28,7 +28,7 @@ indexof(char c, char *string) static char *optarg; static int optind; static char -wgetopt(int argc, char **argv, char *options) +getopt(int argc, char **argv, char *options) { static char *arg; int index; @@ -72,3 +72,4 @@ wgetopt(int argc, char **argv, char *options) } return -1; } +#endif diff --git a/Tests/GNUmakefile b/Tests/GNUmakefile new file mode 100644 index 000000000..e91cbe72a --- /dev/null +++ b/Tests/GNUmakefile @@ -0,0 +1,78 @@ +# +# Tests Makefile for GNUstep Base Library. +# +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# Written by: Richard Frith-Macdonald +# +# This file is part of the GNUstep Base Library. +# +# This library 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 2 of the License, or (at your option) any later version. +# +# This library 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 library; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02111 USA +# + +ifeq ($(GNUSTEP_MAKEFILES),) + GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) + ifeq ($(GNUSTEP_MAKEFILES),) + $(warning ) + $(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!) + $(warning Perhaps gnustep-make is not properly installed,) + $(warning so gnustep-config is not in your PATH.) + $(warning ) + $(warning Your PATH is currently $(PATH)) + $(warning ) + endif +endif + +ifeq ($(GNUSTEP_MAKEFILES),) + $(error You need to set GNUSTEP_MAKEFILES before running this!) +endif + +include $(GNUSTEP_MAKEFILES)/common.make + +TOP_DIR := $(shell dirname $(CURDIR)) + +# This message is also printed when you type 'make' top-level. It is +# the last message printed (since 'Tests' is the last directory in +# SUBPROJECTS top-level), which is good as it becomes a recommendation +# to run 'make check' after 'make'. +all:: + @(echo If you want to run the gnustep-base testsuite, please type \'make check\') + +# +# 'make check' runs the testsuite (Objective-C tests only) +# +# Use 'make check GNUSTEP_TEST_OBJCXX=yes' to run both Objective-C and Objective-C++ tests +# +check:: + (\ + GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES="$(TOP_DIR)/base.make";\ + ADDITIONAL_INCLUDE_DIRS="-I$(TOP_DIR)/Headers -I$(TOP_DIR)/Source/$(GNUSTEP_TARGET_DIR)";\ + ADDITIONAL_LIB_DIRS="-L$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR)";\ + LD_LIBRARY_PATH="$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR):${LD_LIBRARY_PATH}";\ + PATH="$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR):${PATH}";\ + export GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES;\ + export ADDITIONAL_INCLUDE_DIRS;\ + export ADDITIONAL_LIB_DIRS;\ + export LD_LIBRARY_PATH;\ + export PATH;\ + gnustep-tests base;\ + ) + +clean:: + gnustep-tests --clean + +# This makefile does nothing. +include $(GNUSTEP_MAKEFILES)/rules.make diff --git a/Tests/base/Functions/NSGeometry1.m b/Tests/base/Functions/NSGeometry1.m new file mode 100644 index 000000000..e840aac67 --- /dev/null +++ b/Tests/base/Functions/NSGeometry1.m @@ -0,0 +1,139 @@ +/* NSGeometry tests */ +#import +#import "Testing.h" + +static BOOL MacOSXCompatibleGeometry() +{ + NSUserDefaults *dflt = [NSUserDefaults standardUserDefaults]; + if ([dflt boolForKey: @"GSOldStyleGeometry"] == YES) + return NO; + return [dflt boolForKey: @"GSMacOSXCompatible"]; +} + +/* Test the string functions */ +int +geom_string() +{ +#if defined(GNUSTEP_BASE_LIBRARY) + NSUserDefaults *dflt = [NSUserDefaults standardUserDefaults]; + BOOL compat_mode = MacOSXCompatibleGeometry(); +#endif + NSPoint p, p2; + NSRect r, r2; + NSSize s, s2; + NSString *sp, *sr, *ss; + + p = NSMakePoint(23.45, -3.45); + r = NSMakeRect(23.45, -3.45, 2044.3, 2033); + s = NSMakeSize(0.5, 0.22); + + PASS(NSEqualPoints(p, NSMakePoint(23.45, -3.45)), + "identical points are equal"); + if (sizeof(CGFloat) == sizeof(float)) + { + PASS(NSEqualPoints(p, NSMakePoint(23.450001, -3.45)), + "near identical points are equal"); + } + else + { + PASS(NSEqualPoints(p, NSMakePoint(23.450000000000001, -3.45)), + "near identical points are equal"); + } + PASS(!NSEqualPoints(p, NSMakePoint(23.4500019, -3.45)), + "moderately similar points are not equal"); + PASS(NSEqualSizes(s, NSMakeSize(0.5, 0.22)), + "identical sizes are equal"); + if (sizeof(CGFloat) == sizeof(float)) + { + PASS(NSEqualSizes(s, NSMakeSize(0.50000001, 0.22)), + "near identical sizes are equal"); + } + else + { + PASS(NSEqualSizes(s, NSMakeSize(0.50000000000000001, 0.22)), + "near identical sizes are equal"); + } + PASS(!NSEqualSizes(s, NSMakeSize(0.50000003, 0.22)), + "moderately similar sizes are not equal"); + PASS(NSEqualRects(r, NSMakeRect(23.45, -3.45, 2044.3, 2033)), + "identical rects are equal"); + if (sizeof(CGFloat) == sizeof(float)) + { + PASS(NSEqualRects(r, NSMakeRect(23.45, -3.45, 2044.3, 2033.00001)), + "near identical rects are equal"); + } + else + { + PASS(NSEqualRects(r, NSMakeRect(23.45, -3.45, 2044.3, 2033.0000000000001)), + "near identical rects are equal"); + } + PASS(!NSEqualRects(r, NSMakeRect(23.45, -3.45, 2044.3, 2033.0001)), + "moderately similar rects are not equal"); + +#if defined(GNUSTEP_BASE_LIBRARY) + if (compat_mode == YES) + { + [dflt setBool: NO forKey: @"GSMacOSXCompatible"]; + [NSUserDefaults resetStandardUserDefaults]; + } + PASS((MacOSXCompatibleGeometry() == NO), + "Not in MacOSX geometry compat mode"); + + sp = NSStringFromPoint(p); + p2 = NSPointFromString(sp); + PASS((EQ(p2.x, p.x) && EQ(p2.y, p.y)), + "Can read output of NSStringFromPoint"); + + sr = NSStringFromRect(r); + r2 = NSRectFromString(sr); + PASS((EQ(r2.origin.x, r.origin.x) && EQ(r2.origin.y, r.origin.y) + && EQ(r2.size.width, r.size.width) && EQ(r2.size.height, r.size.height)), + "Can read output of NSStringFromRect"); + + ss = NSStringFromSize(s); + s2 = NSSizeFromString(ss); + PASS((EQ(s2.width, s.width) && EQ(s2.height, s.height)), + "Can read output of NSStringFromSize"); + + dflt = [NSUserDefaults standardUserDefaults]; + [dflt setBool: YES forKey: @"GSMacOSXCompatible"]; + [NSUserDefaults resetStandardUserDefaults]; + PASS((MacOSXCompatibleGeometry() == YES), + "In MacOSX geometry compat mode"); +#endif + + sp = NSStringFromPoint(p); + p2 = NSPointFromString(sp); + PASS((EQ(p2.x, p.x) && EQ(p2.y, p.y)), + "Can read output of NSStringFromPoint (MacOSX compat)"); + + sr = NSStringFromRect(r); + r2 = NSRectFromString(sr); + PASS((EQ(r2.origin.x, r.origin.x) && EQ(r2.origin.y, r.origin.y) + && EQ(r2.size.width, r.size.width) && EQ(r2.size.height, r.size.height)), + "Can read output of NSStringFromRect (MacOSX compat)"); + + ss = NSStringFromSize(s); + s2 = NSSizeFromString(ss); + PASS((EQ(s2.width, s.width) && EQ(s2.height, s.height)), + "Can read output of NSStringFromSize (MacOSX compat)"); + +#if defined(GNUSTEP_BASE_LIBRARY) + if (compat_mode != MacOSXCompatibleGeometry()) + { + [dflt setBool: NO forKey: @"GSMacOSXCompatible"]; + } +#endif + return 0; +} + +int main() +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + + geom_string(); + + [pool release]; pool = nil; + + return 0; +} diff --git a/Tests/base/Functions/NSPathUtilities.m b/Tests/base/Functions/NSPathUtilities.m new file mode 100644 index 000000000..fd0538970 --- /dev/null +++ b/Tests/base/Functions/NSPathUtilities.m @@ -0,0 +1,37 @@ +#import +#import "Testing.h" + +int main() +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + id o; + + /* The path utilities provide information about the current user and + * the current filesystem layout ... and are inherently system dependent + * so we can't know if they are operating correctly. The best we can do + * are trivial checks to see if their results look sane. + */ + NSLog(@"NSUserName() %@", o = NSUserName()); + PASS([o length] > 0, "we can get a user name"); + NSLog(@"NSFullUserName() %@", o = NSFullUserName()); + PASS([o length] > 0, "we can get a full user name"); + NSLog(@"NSHomeDirectory() %@", o = NSHomeDirectory()); + PASS([o length] > 0, "we can get a home directory"); + NSLog(@"NSTemporaryDirectory() %@", o = NSTemporaryDirectory()); + PASS([o length] > 0, "we can get a temporary directory"); + NSLog(@"NSOpenStepRootDirectory() %@", o = NSOpenStepRootDirectory()); + PASS([o length] > 0, "we can get a root directory"); + + /* These functions have been removed in recent OSX but are retained in GNUstep + */ +#if defined(GNUSTEP_BASE_LIBRARY) + NSLog(@"NSStandardApplicationPaths() %@", o = NSStandardApplicationPaths()); + PASS([o count] > 0, "we have application paths"); + NSLog(@"NSStandardLibraryPaths() %@", o = NSStandardLibraryPaths()); + PASS([o count] > 0, "we have library paths"); +#endif + + [pool release]; pool = nil; + + return 0; +} diff --git a/Tests/base/Functions/NSZone.m b/Tests/base/Functions/NSZone.m new file mode 100644 index 000000000..7451e040b --- /dev/null +++ b/Tests/base/Functions/NSZone.m @@ -0,0 +1,90 @@ +#import +#import "Testing.h" + +int main() +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSZone *aZone; + char *vp; + void *ovp; + + aZone = NSDefaultMallocZone(); + PASS((aZone != NULL), "NSDefaultMallocZone() returns something"); + + aZone = NSCreateZone(1024,1024,0); + PASS((aZone != NULL), "NSCreateZone() works for an unfreeable zone"); + + aZone = NSCreateZone(1024,1024,1); + PASS((aZone != NULL), "NSCreateZone() works for a normal zone"); + + if ([NSGarbageCollector defaultCollector] == nil) + { + NSSetZoneName(aZone, @"My Zone"); + PASS(([NSZoneName(aZone) isEqual: @"My Zone"]), + "NSZoneName() returns previously set string"); + + vp = NSZoneCalloc(aZone,17,12); + memset(vp,1,17*12); + + NS_DURING + { + NSZoneFree(aZone,vp); + PASS(1, "NSZoneFree() calloc'd buffer"); + } + NS_HANDLER + PASS(0, "NSZoneFree() calloc'd buffer %s", + [[localException name] cString]); + NS_ENDHANDLER + + NS_DURING + NSZoneFree(aZone,vp); + PASS(0, "NSZoneFree() free'd buffer throws exception"); + NS_HANDLER + PASS(1, "NSZoneFree() free'd buffer throws exception: %s", + [[localException name] cString]); + NS_ENDHANDLER + + + vp = NSZoneMalloc(aZone,2000); + memset(vp,2,2000); + + NS_DURING + { + NSZoneFree(aZone,vp); + PASS(1, "NSZoneFree() malloc'd buffer"); + } + NS_HANDLER + PASS(0, "NSZoneFree() malloc'd buffer %s", + [[localException name] cString]); + NS_ENDHANDLER + + ovp = NSZoneMalloc(aZone, 1000); + vp = NSZoneRealloc(aZone, ovp, 2000); + memset(vp,3,2000); + + NSZoneRealloc(aZone, vp, 1000); + memset(vp,4,1000); + + NS_DURING + NSZoneFree(aZone,vp); + PASS(1,"NSZoneFree() releases memory held after realloc"); + NS_HANDLER + PASS(0,"NSZoneFree() releases memory held after realloc"); + NS_ENDHANDLER + + PASS((NSZoneFromPointer(vp) == aZone), + "NSZoneFromPointer() returns zone where memory came from"); + + NS_DURING + [NSString allocWithZone:aZone]; + NSRecycleZone(aZone); + PASS(1,"NSRecycleZone seems to operate"); + NS_HANDLER + PASS(0,"NSRecycleZone seems to operate"); + NS_ENDHANDLER + } + + [pool release]; pool = nil; + + return 0; +} diff --git a/Tests/base/Functions/TestInfo b/Tests/base/Functions/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/Functions/class_hierarchy.m b/Tests/base/Functions/class_hierarchy.m new file mode 100644 index 000000000..9d590e96f --- /dev/null +++ b/Tests/base/Functions/class_hierarchy.m @@ -0,0 +1,88 @@ +#import "Testing.h" +#import + +// OS X doesn't seem to provide all of the runtime functions by default. +#ifndef GNUSTEP +# include +#endif + +// Simple root class - test that the runtime does the right thing with new +// roots +@interface Bar { id isa; } @end +@implementation Bar @end + + +// Some simple classes that inherit from root classes in Foundation. Test that +// they go in the right places in the runtime. +@interface Foo : NSObject @end +@implementation Foo @end +@interface Foo2 : Foo @end +@implementation Foo2 @end + +@interface Proxy : NSProxy @end +@implementation Proxy @end +@interface Proxy2 : Proxy @end +@implementation Proxy2 @end + +/** + * Tests a root class has its superclass and metaclass correctly configured + */ +void testRootClass(const char *clsName) +{ + testHopeful = YES; + START_SET("testRootClass") + Class cls = objc_getClass(clsName); + Class super = class_getSuperclass(cls); + Class meta = object_getClass(cls); + Class superMeta = class_getSuperclass(meta); + Class metaMeta = object_getClass(meta); + + PASS(Nil == super, "superclass of root class is Nil"); + PASS(metaMeta == meta, + "root class's metaclass is also its metaclass's metaclass"); + PASS(cls == superMeta, "Root class is its metaclass's superclass"); + END_SET("testRootClass") +} + +/** + * Tests a non-root class and its metaclass are in the correct place in the + * hierarchy. + */ +void testNonRootClass(const char *clsName) +{ + testHopeful = YES; + START_SET("testNonRootClass") + Class cls = objc_getClass(clsName); + Class super = class_getSuperclass(cls); + Class meta = object_getClass(cls); + Class superMeta = class_getSuperclass(meta); + Class metaMeta = object_getClass(meta); + Class metaSuper = object_getClass(super); + Class root = super; + Class rootMeta = Nil; + + do + { + rootMeta = object_getClass(root); + root = class_getSuperclass(root); + } while (root != Nil); + + PASS(Nil != super, "Non-root class has a superclass"); + PASS(superMeta == metaSuper, + "Metaclass's superclass is superclass's metaclass"); + PASS(rootMeta == metaMeta, + "Metaclass's metaclass is root class's metaclass"); + END_SET("testNonRootClass") +} + +int main(void) +{ + testRootClass("NSObject"); + testRootClass("NSProxy"); + testRootClass("Bar"); + testNonRootClass("Foo"); + testNonRootClass("Foo2"); + testNonRootClass("Proxy"); + testNonRootClass("Proxy2"); + return 0; +} diff --git a/Tests/base/Functions/properties.m b/Tests/base/Functions/properties.m new file mode 100644 index 000000000..5edea6b41 --- /dev/null +++ b/Tests/base/Functions/properties.m @@ -0,0 +1,113 @@ +#import "Testing.h" + +#ifndef OBJC_NEW_PROPERTIES +int main(void) +{ + START_SET("Properties") + OMIT("Your compiler does not support declared properties"); + END_SET("Properties") + return 0; +} +#else +#import + +@interface A : NSObject +{ +@private + NSObject *n; + NSObject *a; +} +@property (nonatomic,readwrite,retain) NSObject *n; +@property (readwrite,retain) NSObject *a; +@end + +@implementation A +- (NSObject *)n +{ + return [[n retain] autorelease]; +} +- (void)setN:(NSObject *)newN +{ + if (n != newN) + { + [n release]; + n = [newN retain]; + } +} +- (NSObject *)a +{ + return [[a retain] autorelease]; +} +- (void)setA:(NSObject *)newA +{ + @synchronized(self) + { + if (a != newA) + { + [a release]; + a = [newA retain]; + } + } +} +- (void)dealloc +{ + [a release]; + [n release]; + [super dealloc]; +} +@end +@interface B : NSObject +// If we've got non-fragile ABI support, try not declaring the ivars +#if !__has_feature(objc_nonfragile_abi) +{ + id a, b, c, d; +} +#endif +@property (nonatomic,readwrite,retain) id a; +@property (readwrite,retain) id b; +@property (nonatomic,readwrite,copy) id c; +@property (readwrite,copy) id d; +@end +@implementation B +@synthesize a,b,c,d; +- (void)dealloc +{ + [a release]; + [b release]; + [c release]; + [d release]; + [super dealloc]; +} +@end + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + id testObject = [@"str" mutableCopy]; + + A *a = [[A alloc] init]; + // Note: use of dot syntax here is only for testing purposes. This case - + // in the test suite and outside of the main code - does not invoke + // requirement to buy all of the other GNUstep developers a beer. + a.a = testObject; + PASS(a.a == testObject, "Setting manually created atomic property"); + a.n = testObject; + PASS(a.n == testObject, "Setting manually created nonatomic property"); + DESTROY(a); + B *b = [B new]; + b.a = testObject; + PASS(b.a == testObject, "Setting synthesized atomic property"); + b.b = testObject; + PASS(b.b == testObject, "Setting synthesized nonatomic property"); + b.c = testObject; + PASS(b.c != testObject, "Synthesized nonatomic copy method did not do simple assign"); + PASS([testObject isEqualToString: b.c], "Synthesized nonatomic copy method did copy"); + b.d = testObject; + PASS(b.d != testObject, "Synthesized atomic copy method did not do simple assign"); + PASS([testObject isEqualToString: b.d], "Synthesized atomic copy method did copy"); + [b release]; + return 0; +} +#endif + diff --git a/Tests/base/Functions/runtime.m b/Tests/base/Functions/runtime.m new file mode 100644 index 000000000..decf7fcf6 --- /dev/null +++ b/Tests/base/Functions/runtime.m @@ -0,0 +1,246 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +#include + +#if defined(GNUSTEP) +#import +#else +#include +#endif + +static int c1count = 0; +static int c1initialize = 0; +static int c1load = 0; + +@interface Class1 : NSObject +{ + int ivar1; + Class1 *ivar1obj; +} +- (const char *) sel1; +@end + +@implementation Class1 ++ (void) initialize +{ + if (self == [Class1 class]) + c1initialize = ++c1count; +} ++ (void) load +{ + c1load = ++c1count; +} +- (const char *) sel1 +{ + return ""; +} +@end + +@protocol SubProto +- (const char *) sel2; +@end + +@interface SubClass1 : Class1 +{ + int ivar2; +} +- (const char *) sel2; +@end + +@implementation SubClass1 +- (const char *) sel2 +{ + return ""; +} +@end + +@interface SubClass1 (Cat1) +- (BOOL) catMethod; +- (const char *) sel2; +@end + +@implementation SubClass1 (Cat1) +- (BOOL) catMethod +{ + return YES; +} +- (const char *) sel2 +{ + return "category sel2"; +} +@end + +int +main(int argc, char *argv[]) +{ + id obj; + Class cls; + Class meta; + SEL sel; + Ivar ivar; + Ivar *ivars; + unsigned int count; + unsigned int index; + Method method; + Method *methods; + Protocol **protocols; + NSUInteger s; + NSUInteger a; + const char *t0; + const char *t1; + const char *n; + + t0 = "1@1:@"; + t1 = NSGetSizeAndAlignment(t0, &s, &a); + PASS(t1 == &t0[2], "NSGetSizeAndAlignment() steps through id"); + t1 = NSGetSizeAndAlignment(t1, &s, &a); + PASS(t1 == &t0[4], "NSGetSizeAndAlignment() steps through sel"); + + PASS(NO == class_isMetaClass(Nil), + "class_isMetaClass() returns NO for Nil"); + PASS(Nil == class_getSuperclass(Nil), + "class_getSuperclass() returns NO for Nil"); + + /* NB. the OSX documentation says that the function returns an empty string + * when given a Nil argument, but the actual behavior on OSX 10.6 is to + * return the string "nil" + */ + PASS_RUNS(n = class_getName(Nil), "class_getName() for Nil does not crash") + PASS(n != 0 && strcmp(n, "nil") == 0, "class_getName() for Nil is nil"); + + PASS(0 == class_getInstanceVariable(Nil, 0), + "class_getInstanceVariables() for Nil,0 is 0"); + PASS(0 == class_getVersion(Nil), + "class_getVersion() for Nil is 0"); + + obj = [NSObject new]; + cls = [SubClass1 class]; + + PASS(c1initialize != 0, "+initialize was called"); + PASS(c1load != 0, "+load was called"); + PASS(c1initialize > c1load, "+load occurs before +initialize"); + PASS(strcmp(class_getName(cls), "SubClass1") == 0, "class name works"); + PASS(YES == class_respondsToSelector(cls, @selector(sel2)), + "class_respondsToSelector() works for class method"); + PASS(YES == class_respondsToSelector(cls, @selector(sel1)), + "class_respondsToSelector() works for superclass method"); + PASS(NO == class_respondsToSelector(cls, @selector(rangeOfString:)), + "class_respondsToSelector() returns NO for unknown method"); + PASS(NO == class_respondsToSelector(cls, 0), + "class_respondsToSelector() returns NO for nul selector"); + PASS(NO == class_respondsToSelector(0, @selector(sel1)), + "class_respondsToSelector() returns NO for nul class"); + meta = object_getClass(cls); + PASS(class_isMetaClass(meta), "object_getClass() retrieves meta class"); + PASS(strcmp(class_getName(meta), "SubClass1") == 0, "metaclass name works"); + ivar = class_getInstanceVariable(cls, 0); + PASS(ivar == 0, "class_getInstanceVariable() returns 0 for null name"); + ivar = class_getInstanceVariable(cls, "bad name"); + PASS(ivar == 0, "class_getInstanceVariable() returns 0 for non-existent"); + ivar = class_getInstanceVariable(0, "ivar2"); + PASS(ivar == 0, "class_getInstanceVariable() returns 0 for Nil class"); + ivar = class_getInstanceVariable(cls, "ivar2"); + PASS(ivar != 0, "class_getInstanceVariable() works"); + ivar = class_getInstanceVariable(cls, "ivar1"); + PASS(ivar != 0, "class_getInstanceVariable() works for superclass ivar"); + ivar = class_getInstanceVariable(cls, "ivar1obj"); + PASS(ivar != 0, "class_getInstanceVariable() works for superclass obj ivar"); + + methods = class_copyMethodList(cls, &count); + PASS(count == 3, "SubClass1 has three methods"); + PASS(methods[count] == 0, "method list is terminated"); + + method = methods[2]; + sel = method_getName(method); + PASS(sel_isEqual(sel, sel_getUid("sel2")), + "last method is sel2"); + PASS(method_getImplementation(method) != [cls instanceMethodForSelector: sel], + "method 2 is the original, overridden by the category"); + + method = methods[0]; + sel = method_getName(method); + PASS(sel_isEqual(sel, sel_getUid("catMethod")) + || sel_isEqual(sel, sel_getUid("sel2")), + "method 0 has expected name"); + + if (sel_isEqual(sel, sel_getUid("catMethod"))) + { + method = methods[1]; + sel = method_getName(method); + PASS(sel_isEqual(sel, sel_getUid("sel2")), + "method 1 has expected name"); + PASS(method_getImplementation(method) + == [cls instanceMethodForSelector: sel], + "method 1 is the category method overriding original"); + } + else + { + PASS(method_getImplementation(method) + == [cls instanceMethodForSelector: sel], + "method 0 is the category method overriding original"); + method = methods[1]; + sel = method_getName(method); + PASS(sel_isEqual(sel, sel_getUid("catMethod")), + "method 1 has expected name"); + } + + ivars = class_copyIvarList(cls, &count); + PASS(count == 1, "SubClass1 has one ivar"); + PASS(ivars[count] == 0, "ivar list is terminated"); + PASS(strcmp(ivar_getName(ivars[0]), "ivar2") == 0, + "ivar has correct name"); + PASS(strcmp(ivar_getTypeEncoding(ivars[0]), @encode(int)) == 0, + "ivar has correct type"); + + protocols = class_copyProtocolList(cls, &count); + PASS(count == 1, "SubClass1 has one protocol"); + PASS(protocols[count] == 0, "protocol list is terminated"); + PASS(strcmp(protocol_getName(protocols[0]), "SubProto") == 0, + "protocol has correct name"); + + cls = objc_allocateClassPair([NSString class], "runtime generated", 0); + PASS(cls != Nil, "can allocate a class pair"); + PASS(class_addIvar(cls, "iv1", 1, 6, "c") == YES, + "able to add iVar 'iv1'"); + PASS(class_addIvar(cls, "iv2", 1, 5, "c") == YES, + "able to add iVar 'iv2'"); + PASS(class_addIvar(cls, "iv3", 1, 4, "c") == YES, + "able to add iVar 'iv3'"); + PASS(class_addIvar(cls, "iv4", 1, 3, "c") == YES, + "able to add iVar 'iv4'"); + objc_registerClassPair (cls); + ivar = class_getInstanceVariable(cls, "iv1"); + PASS(ivar != 0, "iv1 exists"); + PASS(ivar_getOffset(ivar) == 64, "iv1 offset is 64"); + ivar = class_getInstanceVariable(cls, "iv2"); + PASS(ivar != 0, "iv2 exists"); + PASS(ivar_getOffset(ivar) == 96, "iv2 offset is 96"); + ivar = class_getInstanceVariable(cls, "iv3"); + PASS(ivar != 0, "iv3 exists"); + PASS(ivar_getOffset(ivar) == 112, "iv3 offset is 112"); + ivar = class_getInstanceVariable(cls, "iv4"); + PASS(ivar != 0, "iv4 exists"); + PASS(ivar_getOffset(ivar) == 120, "iv4 offset is 120"); + + /* NSObjCRuntime function tests. + */ + sel = NSSelectorFromString(nil); + PASS(sel == 0, + "NSSelectorFromString() returns 0 for nil string"); + PASS(NSStringFromSelector(0) == nil, + "NSStringFromSelector() returns nil for null selector"); + sel = NSSelectorFromString(@"xxxyyy_odd_name_xxxyyy"); + PASS(sel != 0, + "NSSelectorFromString() creates for non-existent selector"); + PASS([NSStringFromSelector(sel) isEqual: @"xxxyyy_odd_name_xxxyyy"], + "NSStringFromSelector() works for existing selector"); + + return 0; +} + diff --git a/Tests/base/GNUmakefile.postamble b/Tests/base/GNUmakefile.postamble new file mode 100644 index 000000000..6b14b1623 --- /dev/null +++ b/Tests/base/GNUmakefile.postamble @@ -0,0 +1,32 @@ +# +# GNUmakefile.postamble for base tests +# +# Find all all subdirectories and run a clean in them independantly +# + +after-clean:: + $(ECHO_NOTHING)\ + RUNDIR=`pwd`; \ + TESTDIRS=`find . -type d`; \ + for dir in $$TESTDIRS __done; do \ + if [ $$dir != . -a -f $$dir/GNUmakefile ]; then \ + echo Cleaning $$dir; cd $$dir; make clean; cd $$RUNDIR; \ + fi \ + done \ + $(END_ECHO) + +after-distclean:: + $(ECHO_NOTHING)\ + RUNDIR=`pwd`; \ + TESTDIRS=`find . -type d`; \ + for dir in $$TESTDIRS __done; do \ + if [ $$dir != . -a -f $$dir/GNUmakefile ]; then \ + echo Cleaning $$dir; cd $$dir; make distclean; \ + if [ \! -f IGNORE ]; then \ + $(RM) GNUmakefile; \ + fi; \ + cd $$RUNDIR; \ + fi \ + done \ + $(END_ECHO) + diff --git a/Tests/base/GSMime/HTTP1.dat b/Tests/base/GSMime/HTTP1.dat new file mode 100644 index 000000000..04923ef32 --- /dev/null +++ b/Tests/base/GSMime/HTTP1.dat @@ -0,0 +1,9 @@ +HTTP/1.1 200 OK +Date: Thu, 02 Oct 2008 17:07:20 GMT +Server: Microsoft-IIS/6.0 +MicrosoftOfficeWebServer: 5.0_Pub +X-Powered-By: ASP.NET +X-AspNet-Version: 2.0.50727 +Cache-Control: private +Content-Length: 0 + diff --git a/Tests/base/GSMime/TestInfo b/Tests/base/GSMime/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/GSMime/build.m b/Tests/base/GSMime/build.m new file mode 100644 index 000000000..bda82f4e8 --- /dev/null +++ b/Tests/base/GSMime/build.m @@ -0,0 +1,31 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +#import +#import +#import "Testing.h" +int main(int argc,char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *data = nil; + GSMimeDocument *doc = [[GSMimeDocument alloc] init]; + NSMutableDictionary *par = [[NSMutableDictionary alloc] init]; + [par setObject: @"my/type" forKey: @"type"]; + [doc setContent: @"Hello\r\n"]; + [doc setHeader: [[GSMimeHeader alloc] initWithName: @"content-type" + value: @"text/plain" + parameters: par]]; + + [doc setHeader: [[GSMimeHeader alloc] initWithName: @"content-transfer-encoding" + value: @"binary" + parameters: nil]]; + + data = [NSData dataWithContentsOfFile: @"mime8.dat"]; + PASS([[doc rawMimeData] isEqual: data], "Can make a simple document"); + [arp release]; arp = nil; + return 0; +} +#else +int main(int argc,char **argv) +{ + return 0; +} +#endif diff --git a/Tests/base/GSMime/general.m b/Tests/base/GSMime/general.m new file mode 100644 index 000000000..ddb67ca21 --- /dev/null +++ b/Tests/base/GSMime/general.m @@ -0,0 +1,141 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +#import +#import +#import "Testing.h" + +static GSMimeDocument * +parse(GSMimeParser *parser, NSData *data) +{ + unsigned length = [data length]; + unsigned index; + + for (index = 0; index < length-1; index++) + { + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSData *d; + + d = [data subdataWithRange: NSMakeRange(index, 1)]; + if ([parser parse: d] == NO) + { + return [parser mimeDocument]; + } + [arp release]; + } + data = [data subdataWithRange: NSMakeRange(index, 1)]; + if ([parser parse: data] == YES) + { + [parser parse: nil]; + } + return [parser mimeDocument]; +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSData *data; + GSMimeDocument *doc; + GSMimeDocument *idoc; + + data = [NSData dataWithContentsOfFile: @"mime1.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[[[idoc content] objectAtIndex:0] content] isEqual: @"a"]), + "can parse one char base64 mime1.dat incrementally"); + doc = [GSMimeParser documentFromData: data]; + PASS(([[[[doc content] objectAtIndex:0] content] isEqual: @"a"]), + "can parse one char base64 mime1.dat in one go"); + PASS([idoc isEqual: doc], "mime1.dat documents are the same"); + + data = [NSData dataWithContentsOfFile: @"mime2.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[idoc content] isEqual: @"aa"]), + "can parse two char base64 mime2.dat incrementally"); + doc = [GSMimeParser documentFromData: data]; + PASS(([[doc content] isEqual: @"aa"]), + "can parse two char base64 mime2.dat in one go"); + PASS([idoc isEqual: doc], "mime2.dat documents are the same"); + + data = [NSData dataWithContentsOfFile: @"mime3.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[idoc content] isEqual: @"aaa"]), + "can parse three char base64 mime3.dat incrementally"); + doc = [GSMimeParser documentFromData: data]; + PASS(([[doc content] isEqual: @"aaa"]), + "can parse three char base64 mime3.dat in one go"); + PASS([idoc isEqual: doc], "mime3.dat documents are the same"); + + data = [NSData dataWithContentsOfFile: @"mime4.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[[[idoc content] objectAtIndex:0] content] isEqual: @"hello\n"] + && [[[[idoc content] objectAtIndex:1] content] isEqual: @"there\n"]), + "can parse multi-part text mime4.dat incrementally"); + PASS(([[[[idoc content] objectAtIndex:0] contentFile] isEqual: @"a.a"]), + "can extract content file name from mime4.dat (incrementally parsed)"); + PASS(([[[[idoc content] objectAtIndex:0] contentType] isEqual: @"text"]), + "can extract content type from mime4.dat (incrementally parsed)"); + PASS(([[[[idoc content] objectAtIndex:0] contentSubtype] isEqual: @"plain"]), + "can extract content sub type from mime4.dat (incrementally parsed)"); + + doc = [GSMimeParser documentFromData: data]; + PASS(([[[[doc content] objectAtIndex:0] content] isEqual: @"hello\n"] + && [[[[doc content] objectAtIndex:1] content] isEqual: @"there\n"]), + "can parse multi-part text mime4.dat in one go"); + PASS(([[[[doc content] objectAtIndex:0] contentFile] isEqual: @"a.a"]), + "can extract content file name from mime4.dat (parsed in one go)"); + PASS(([[[[doc content] objectAtIndex:0] contentType] isEqual: @"text"]), + "can extract content type from mime4.dat (parsed in one go)"); + PASS(([[[[doc content] objectAtIndex:0] contentSubtype] isEqual: @"plain"]), + "can extract content sub type from mime4.dat (parsed in one go)"); + PASS([idoc isEqual: doc], "mime4.dat documents are the same"); + + data = [NSData dataWithContentsOfFile: @"mime5.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[idoc contentSubtype] isEqual: @"xml"]), + "can parse http document mime5.dat incrementally"); + doc = [GSMimeParser documentFromData: data]; + PASS(([[doc contentSubtype] isEqual: @"xml"]), + "can parse http document mime5.dat in one go"); + PASS([idoc isEqual: doc], "mime5.dat documents are the same"); + + data = [NSData dataWithContentsOfFile: @"mime6.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[idoc content] count] == 3), + "can parse multipart mixed mime6.dat incrementally"); + doc = [GSMimeParser documentFromData: data]; + PASS(([[doc content] count] == 3), + "can parse multipart mixed mime6.dat in one go"); + PASS([idoc isEqual: doc], "mime6.dat documents are the same"); + + data = [NSData dataWithContentsOfFile: @"mime7.dat"]; + PASS(([[[[doc content] objectAtIndex:1] content] isEqual: data]), + "mime6.dat binary data part matches mime7.dat"); + + data = [NSData dataWithContentsOfFile: @"mime9.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + PASS(([[[idoc headerNamed: @"Long"] value] isEqual: @"first second third"]), + "mime9.dat folded header unfolds correctly incrementally"); + doc = [GSMimeParser documentFromData: data]; +//NSLog(@"'%@'", [[doc headerNamed: @"Long"] value]); + PASS(([[[doc headerNamed: @"Long"] value] isEqual: @"first second third"]), + "mime9.dat folded header unfolds correctly in one go"); + PASS([idoc isEqual: doc], "mime9.dat documents are the same"); + + /* Test a document containing nested multipart documents + */ + data = [NSData dataWithContentsOfFile: @"mime10.dat"]; + idoc = parse([[GSMimeParser new] autorelease], data); + doc = [GSMimeParser documentFromData: data]; + PASS([idoc isEqual: doc], "mime10.dat documents are the same"); + data = [idoc rawMimeData]; + doc = [GSMimeParser documentFromData: data]; + PASS([idoc isEqual: doc], "rawMimeData reproduces docuement"); + + + [arp release]; arp = nil; + return 0; +} +#else +int main(int argc,char **argv) +{ + return 0; +} +#endif diff --git a/Tests/base/GSMime/mime1.dat b/Tests/base/GSMime/mime1.dat new file mode 100644 index 000000000..6a734f715 --- /dev/null +++ b/Tests/base/GSMime/mime1.dat @@ -0,0 +1,18 @@ +content-type: multipart/mixed; boundary=xxxx + +--xxxx +content-transfer-encoding: base64 + +YQ== + +--xxxx +content-transfer-encoding: 8bit + +Hello there + +--xxxx +content-transfer-encoding: 7bit + +Testing again. + +--xxxx-- diff --git a/Tests/base/GSMime/mime10.dat b/Tests/base/GSMime/mime10.dat new file mode 100644 index 000000000..85e0510f9 --- /dev/null +++ b/Tests/base/GSMime/mime10.dat @@ -0,0 +1,194 @@ +Date: Mon, 27 May 2002 09:41:03 +0100 +Mime-Version: 1.0 (Apple Message framework v481) +Content-Type: multipart/mixed; boundary=Apple-Mail-2--915493160 +Subject: test +From: Richard Frith-Macdonald +To: Richard Frith-Macdonald +Message-Id: <7A6B10F5-714D-11D6-9738-00306544502E@brainstorm.co.uk> +X-Mailer: Apple Mail (2.481) +X-SpamBouncer: 1.4 (10/07/01) +X-SBClass: OK + + +--Apple-Mail-2--915493160 +Content-Disposition: attachment; + filename=a.a +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + x-unix-mode=0644; + name="a.a" + +hello + +--Apple-Mail-2--915493160 +Content-Disposition: attachment; + filename=b.b +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + x-unix-mode=0644; + name="b.b" + +there + +--Apple-Mail-2--915493160 + +Content-Transfer-Encoding: 7bit +Content-Type: multipart/mixed; boundary="e7paaJyQU/hlJOcvRPG4PgAAAAU=" + +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: application/smil; charset=us-ascii; name=mms.smil +Content-Transfer-Encoding: 7bit + + + + + + + + + + + + + + + + + + + +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: image/gif; name=SME46224_1.gif +Content-Transfer-Encoding: base64 + +R0lGODlhUABaAMQAAAAAAP///8zMzLKyspmZmQEjWGZmZlFSUgkVKOTk5Fmm3DMzMxROqCtPafT0 +9Hp/ggY3hKnc8tzw+hZn5iEjJYewweb5/QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAA +AAAALAAAAABQAFoAAAX/YCCOZGmepqOurIO+cCzPAZvceI6zdO/HK5xgSCwad6qfshdMEAfQaJQg +jRJvq6U25RAKpoTwY0wmh8NWAXKrVd2G4Ad6mHCJunDxGUqv29kzbk5fA3oDCT8JhWNUA31JgDCC +hARyhyROUGd7jmqYi410kJElk1+VBAJ2Dl8PBgcHCwsUCLUUsgcGlnV3Aqh8WH+kk4VhqiJfr7MA +zM3OzxS5qYg1oI7BpDV4p1TUvgbLz+LjzNEPlwGKltejW26UqcgE4Ajk9uQIB+fev2rtSu8WXXIw +gN69g/gOxEvXz08bPMUGIHtwgALCe/XsUTAwwM4AS/6E0QhoTETBBRft/9WqdVAhtY9UQvoguXBA +xZT4EDRokPHeAgIvQTocmalkAJs9D65cWqtAgwc8ASQdR+HBSwMxeQV681Hi0QMImYqtBeFBhQdM +D1o1iZWdDJJebYZlWqDAyroFGCiIwGDsvbUB5nX7l6Io0KMGpopbirex3QIQ9vIdy5IqARcJGPmT +9KakAAMWczZ1TDqvAgl88VJWvKBjgM/nNqOASKXGA5SiEZSuCwECb7MBIvhuTFmcAQEiBB8SOYL2 +YbnjGDfuzbs3A+unJVS4Przu6meX02nWWirTA+QJQEcfjbe3ewgMGEyYP0FBhQgRFMyPT111Wmet +VdPWMeVx4wIBuD1z1/901slHX3zxmVWBAlHlNcF1ji1lHGauTCMSROe9lthi7EHmXnzzQbCSVKvp +dmF33mnYDAISOTBPbB8qEsaBCc5Y4okOQsCiTg3E8l1eGPq3ojMGuPAZVrLVUJRE6Sk2mm8N7rfS +AV6NkAABB2z52gIIwNefkknRWINy5OFRCSLQOXMlkPWhVQtyLxCwEnIC1PJiaUsyQ4CAsVFTAzdr +huajbibC56ACtSwwgwBkHiACWvwBWhkzCyCSHpS80CbRZyS2lyWFCEjqJZgKmUCpmnrKxx1xdm0K +AJU3LidlK3CCJSejjcI3H6QI4BkYUwcYalKqAWCqAHfd/cfMA9Xo44j/C10Uk5yizMx5Kk+WJlfL +eUiFS0KYdirwLLQZ9pSPkwaAeqi2DjxQ6nuOqlvLoK/tO0KfCPA7wgBLqQvhmbVWVg+f8Q42ZToG +KMjoeyjqd+elCFD7Wpgr8esLmfUgoN/BMEpLpSv7gMiwjws0gK+j9RE7QphUgpyqzSu1XAAACyjw +AH/uxRjooJnpcq15fPoq1VMETKjuz/GpO0EtI9wpAMfMZlbLU+qqS2YDPkMbbaDU2qjPNOYhQumM +C8gRgQRwR+B011SLMC6ZIIebQKpd912Lwe+124wBa0qjhhOVuDBAaCuVZd/bIiQQdwUXB4D1oFcH +jHHfXX/tc+DEVSYp/0GGd6Yxwd1KxRsDDzz+NmoR8KSxnvl4WfuxnHctVX1At5sRBSZJcwjip2cU +8sTWtX4ffmipmkClJNxOAAC5q9sAz+sGrWQzwbdl+rJDAgtk6/ZVQLnmR9VyAHJ6hotW1zzppG/G +zyKccDnVek+8k4x7C+EDMbNe5V6VMzzJQl/xk9/1esau7fGscPrzxVrWJh0gsc5vOTNUJfSBJ4K1 +jicFIFOf5te6WTmQcF8SHldCdLXUIe9EAJwfU7pUAoDBr1Zksh4AwAa0sdWDWplRIdIg1q0FUQx+ +9RCg+g4jj3HlDio9U5dUAIcwlmDuFaAyz8lcaKp8EQt7XpNFzozkxP/qda11OTSYCb1zKxE1zB+I +slHIWFQdmNlpDNVrAM6eAjYzes1nAFDehH5GHZYgpyBG84eONEZBIzYIVW3zo89CFkZJRpJvy8uP +AgzQALscQHG5wJGbjkPEItYRPk+jZCrp9zS09LEeUcwd13iiLvPhR270IBpFEhmQc6zpV3XUCyB/ +iEHORVKGZmwdWsiHR3WBgwKjwuJg5hUGk6DkeMEUJsjIJ0VW6uuMBate67DXw05Go1e68JCUFuGp +iJkyWFEbw9YESL1J/k0BOLvnTlIJKR6a0F9BTGSotFgNd4kvedYjk1Raxk1aTlIhLKmHU/jmNZ30 +0DsUOKQ0r9WcUzz/ADPupGMXhWlPbxozZF/Y2opU+rcGjksFYEqnru6AOI6A752NiprPoqJKcD4g +AppLos8UuhJ/ag8BGRVRKN1C01Z8tAYhXVBOhRm/WnETkMjJ2N5E1jeocPOi+4JpLgaUo0LY9CgJ +cuQjo9LJm3GzKflIV9/qw7ty2mUBGg2lOkkAIsBMr4jiy+kEuMaUhmooY3Slz4XEpouKnGysWWHO +KMOTHh85hmLD2olu7CSVvmQskIHEz4QWK7an3GYtNomXHKLEV/NwxElKk2ow+0bLwoqsdQWwigXy +QzLqNACLDNMrUwsjwRAdRVElMpVe5kYsVEntWSKzgHYICTqkBiig/wJlTnOydaOXGJQ02DEf/HoG +la5xR5gP0J6ScDVWoWi3OUXBincBK1VU4udZAeyb2EAntFrUiFUyZe1sXMvExdGXMXqRG38gxGB8 +NQpN0EwOLBrGjvfy1U0deomvxFKXBCvgZSCezva4VLj2RpYoHoWSk+x1YPsaYDe8gfGKQpRCEw93 +K6dQ7TG+dM0hFcAA6upvcjWVqksIgCI2lslMiuIKjngDLSx7RaAA6ztb1ASLqo2shTmTYijdoSC2 +oMAtLLKRSyhCPZSpyo7nMdYAD2UJtHFFLrrUBbUhiGc0HJjSpAIAhRyDIK9os3u3vJX4SkO7BTGW +q3ylEHQQBMnxSv+nlofBFTYvgJQpiMEXPBG5j0w40utQ8jBoowxFAyTHn85yTESdjV2ZNVmETkGK +YdFmSQPjza1uqlk7YQVllcesslhArRnBB1bnGr6toIIY3PvrecxC2KqVQygOR5hjN/VGcl4qa1nh +7GcLt9jYsPaAUR1sYWsZIsqYhfA6sQZxc/nVs7jFtPOQ7lskktrVdncpSK2MjWxCDOAotxDzre8T +kKTJE25yoMtt70LFuuD7HkQxAp2LWJTb26B6OMS5IPFKpJvhtxCegDfOhDrn+OPBFjl5SA7nOMeL +1lm+xspZDudKV8IMWZk5zVsu8So8YufZEMQgDodroEeiBTwoeAgBAAA7 +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: text/plain; charset=us-ascii; name=SME46224_2.txt +Content-Transfer-Encoding: 7bit + +You won't be worried about what people think of you once you see how they flock around today. The mere fact that someone has questions and interest in what you're doing suggests that they admire you for who and what you are. + +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Transfer-Encoding: 7bit +Content-Type: multipart/mixed; boundary="f7paaJyQU/hlJOcvRPG4PgAAAAU=" + +--f7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: application/smil; charset=us-ascii; name=mms.smil +Content-Transfer-Encoding: 7bit + + + + + + + + + + + + + + + + + + + +--f7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: image/gif; name=SME46224_1.gif +Content-Transfer-Encoding: base64 + +R0lGODlhUABaAMQAAAAAAP///8zMzLKyspmZmQEjWGZmZlFSUgkVKOTk5Fmm3DMzMxROqCtPafT0 +9Hp/ggY3hKnc8tzw+hZn5iEjJYewweb5/QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAA +AAAALAAAAABQAFoAAAX/YCCOZGmepqOurIO+cCzPAZvceI6zdO/HK5xgSCwad6qfshdMEAfQaJQg +jRJvq6U25RAKpoTwY0wmh8NWAXKrVd2G4Ad6mHCJunDxGUqv29kzbk5fA3oDCT8JhWNUA31JgDCC +hARyhyROUGd7jmqYi410kJElk1+VBAJ2Dl8PBgcHCwsUCLUUsgcGlnV3Aqh8WH+kk4VhqiJfr7MA +zM3OzxS5qYg1oI7BpDV4p1TUvgbLz+LjzNEPlwGKltejW26UqcgE4Ajk9uQIB+fev2rtSu8WXXIw +gN69g/gOxEvXz08bPMUGIHtwgALCe/XsUTAwwM4AS/6E0QhoTETBBRft/9WqdVAhtY9UQvoguXBA +xZT4EDRokPHeAgIvQTocmalkAJs9D65cWqtAgwc8ASQdR+HBSwMxeQV681Hi0QMImYqtBeFBhQdM +D1o1iZWdDJJebYZlWqDAyroFGCiIwGDsvbUB5nX7l6Io0KMGpopbirex3QIQ9vIdy5IqARcJGPmT +9KakAAMWczZ1TDqvAgl88VJWvKBjgM/nNqOASKXGA5SiEZSuCwECb7MBIvhuTFmcAQEiBB8SOYL2 +YbnjGDfuzbs3A+unJVS4Przu6meX02nWWirTA+QJQEcfjbe3ewgMGEyYP0FBhQgRFMyPT111Wmet +VdPWMeVx4wIBuD1z1/901slHX3zxmVWBAlHlNcF1ji1lHGauTCMSROe9lthi7EHmXnzzQbCSVKvp +dmF33mnYDAISOTBPbB8qEsaBCc5Y4okOQsCiTg3E8l1eGPq3ojMGuPAZVrLVUJRE6Sk2mm8N7rfS +AV6NkAABB2z52gIIwNefkknRWINy5OFRCSLQOXMlkPWhVQtyLxCwEnIC1PJiaUsyQ4CAsVFTAzdr +huajbibC56ACtSwwgwBkHiACWvwBWhkzCyCSHpS80CbRZyS2lyWFCEjqJZgKmUCpmnrKxx1xdm0K +AJU3LidlK3CCJSejjcI3H6QI4BkYUwcYalKqAWCqAHfd/cfMA9Xo44j/C10Uk5yizMx5Kk+WJlfL +eUiFS0KYdirwLLQZ9pSPkwaAeqi2DjxQ6nuOqlvLoK/tO0KfCPA7wgBLqQvhmbVWVg+f8Q42ZToG +KMjoeyjqd+elCFD7Wpgr8esLmfUgoN/BMEpLpSv7gMiwjws0gK+j9RE7QphUgpyqzSu1XAAACyjw +AH/uxRjooJnpcq15fPoq1VMETKjuz/GpO0EtI9wpAMfMZlbLU+qqS2YDPkMbbaDU2qjPNOYhQumM +C8gRgQRwR+B011SLMC6ZIIebQKpd912Lwe+124wBa0qjhhOVuDBAaCuVZd/bIiQQdwUXB4D1oFcH +jHHfXX/tc+DEVSYp/0GGd6Yxwd1KxRsDDzz+NmoR8KSxnvl4WfuxnHctVX1At5sRBSZJcwjip2cU +8sTWtX4ffmipmkClJNxOAAC5q9sAz+sGrWQzwbdl+rJDAgtk6/ZVQLnmR9VyAHJ6hotW1zzppG/G +zyKccDnVek+8k4x7C+EDMbNe5V6VMzzJQl/xk9/1esau7fGscPrzxVrWJh0gsc5vOTNUJfSBJ4K1 +jicFIFOf5te6WTmQcF8SHldCdLXUIe9EAJwfU7pUAoDBr1Zksh4AwAa0sdWDWplRIdIg1q0FUQx+ +9RCg+g4jj3HlDio9U5dUAIcwlmDuFaAyz8lcaKp8EQt7XpNFzozkxP/qda11OTSYCb1zKxE1zB+I +slHIWFQdmNlpDNVrAM6eAjYzes1nAFDehH5GHZYgpyBG84eONEZBIzYIVW3zo89CFkZJRpJvy8uP +AgzQALscQHG5wJGbjkPEItYRPk+jZCrp9zS09LEeUcwd13iiLvPhR270IBpFEhmQc6zpV3XUCyB/ +iEHORVKGZmwdWsiHR3WBgwKjwuJg5hUGk6DkeMEUJsjIJ0VW6uuMBate67DXw05Go1e68JCUFuGp +iJkyWFEbw9YESL1J/k0BOLvnTlIJKR6a0F9BTGSotFgNd4kvedYjk1Raxk1aTlIhLKmHU/jmNZ30 +0DsUOKQ0r9WcUzz/ADPupGMXhWlPbxozZF/Y2opU+rcGjksFYEqnru6AOI6A752NiprPoqJKcD4g +AppLos8UuhJ/ag8BGRVRKN1C01Z8tAYhXVBOhRm/WnETkMjJ2N5E1jeocPOi+4JpLgaUo0LY9CgJ +cuQjo9LJm3GzKflIV9/qw7ty2mUBGg2lOkkAIsBMr4jiy+kEuMaUhmooY3Slz4XEpouKnGysWWHO +KMOTHh85hmLD2olu7CSVvmQskIHEz4QWK7an3GYtNomXHKLEV/NwxElKk2ow+0bLwoqsdQWwigXy +QzLqNACLDNMrUwsjwRAdRVElMpVe5kYsVEntWSKzgHYICTqkBiig/wJlTnOydaOXGJQ02DEf/HoG +la5xR5gP0J6ScDVWoWi3OUXBincBK1VU4udZAeyb2EAntFrUiFUyZe1sXMvExdGXMXqRG38gxGB8 +NQpN0EwOLBrGjvfy1U0deomvxFKXBCvgZSCezva4VLj2RpYoHoWSk+x1YPsaYDe8gfGKQpRCEw93 +K6dQ7TG+dM0hFcAA6upvcjWVqksIgCI2lslMiuIKjngDLSx7RaAA6ztb1ASLqo2shTmTYijdoSC2 +oMAtLLKRSyhCPZSpyo7nMdYAD2UJtHFFLrrUBbUhiGc0HJjSpAIAhRyDIK9os3u3vJX4SkO7BTGW +q3ylEHQQBMnxSv+nlofBFTYvgJQpiMEXPBG5j0w40utQ8jBoowxFAyTHn85yTESdjV2ZNVmETkGK +YdFmSQPjza1uqlk7YQVllcesslhArRnBB1bnGr6toIIY3PvrecxC2KqVQygOR5hjN/VGcl4qa1nh +7GcLt9jYsPaAUR1sYWsZIsqYhfA6sQZxc/nVs7jFtPOQ7lskktrVdncpSK2MjWxCDOAotxDzre8T +kKTJE25yoMtt70LFuuD7HkQxAp2LWJTb26B6OMS5IPFKpJvhtxCegDfOhDrn+OPBFjl5SA7nOMeL +1lm+xspZDudKV8IMWZk5zVsu8So8YufZEMQgDodroEeiBTwoeAgBAAA7 +--f7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: text/plain; charset=us-ascii; name=SME46224_2.txt +Content-Transfer-Encoding: 7bit + +You won't be worried about what people think of you once you see how they flock around today. The mere fact that someone has questions and interest in what you're doing suggests that they admire you for who and what you are. + +--f7paaJyQU/hlJOcvRPG4PgAAAAU=-- +--e7paaJyQU/hlJOcvRPG4PgAAAAU=-- +--Apple-Mail-2--915493160-- diff --git a/Tests/base/GSMime/mime2.dat b/Tests/base/GSMime/mime2.dat new file mode 100644 index 000000000..0de1c504a --- /dev/null +++ b/Tests/base/GSMime/mime2.dat @@ -0,0 +1,3 @@ +content-transfer-encoding: base64 + +YWE= diff --git a/Tests/base/GSMime/mime3.dat b/Tests/base/GSMime/mime3.dat new file mode 100644 index 000000000..0e3d3a0ec --- /dev/null +++ b/Tests/base/GSMime/mime3.dat @@ -0,0 +1,3 @@ +content-transfer-encoding: base64 + +YWFh diff --git a/Tests/base/GSMime/mime4.dat b/Tests/base/GSMime/mime4.dat new file mode 100644 index 000000000..c68588317 --- /dev/null +++ b/Tests/base/GSMime/mime4.dat @@ -0,0 +1,34 @@ +Date: Mon, 27 May 2002 09:41:03 +0100 +Mime-Version: 1.0 (Apple Message framework v481) +Content-Type: multipart/mixed; boundary=Apple-Mail-2--915493160 +Subject: test +From: Richard Frith-Macdonald +To: Richard Frith-Macdonald +Message-Id: <7A6B10F5-714D-11D6-9738-00306544502E@brainstorm.co.uk> +X-Mailer: Apple Mail (2.481) +X-SpamBouncer: 1.4 (10/07/01) +X-SBClass: OK + + +--Apple-Mail-2--915493160 +Content-Disposition: attachment; + filename=a.a +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + x-unix-mode=0644; + name="a.a" + +hello + +--Apple-Mail-2--915493160 +Content-Disposition: attachment; + filename=b.b +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + x-unix-mode=0644; + name="b.b" + +there + +--Apple-Mail-2--915493160-- + diff --git a/Tests/base/GSMime/mime5.dat b/Tests/base/GSMime/mime5.dat new file mode 100644 index 000000000..6eb744ec9 --- /dev/null +++ b/Tests/base/GSMime/mime5.dat @@ -0,0 +1,63 @@ +HTTP/1.0 200 OK +Set-Cookie: WEBTRENDS_ID=213.86.45.65-35905744.29522136; expires=Fri, 31-Dec-2010 00:00:00 GMT; path=/ +Server: Microsoft-IIS/4.0 +Date: Mon, 21 Oct 2002 08:01:06 GMT +Content-Length: 3956 +Content-Type: text/xml +Set-Cookie: ASPSESSIONIDGGQGQQDK=JJIMJBOCFKDOKHDJENONIFLG; path=/ +Cache-Control: private +X-Cache: MISS from pcproxy.uk1.brainstorm.co.uk +Proxy-Connection: keep-alive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/base/GSMime/mime6.dat b/Tests/base/GSMime/mime6.dat new file mode 100644 index 000000000..07e100f6a --- /dev/null +++ b/Tests/base/GSMime/mime6.dat @@ -0,0 +1,84 @@ +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Bsmil-Feed: VDataFeed +X-Bsmil-Type: VDailyAries +X-Bsmil-Subtype: +X-Bsmil-Reference: 20021119 +Content-Type: multipart/mixed; boundary="e7paaJyQU/hlJOcvRPG4PgAAAAU=" + +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: application/smil; charset=us-ascii; name=mms.smil +Content-Transfer-Encoding: 7bit + + + + + + + + + + + + + + + + + + + +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: image/gif; name=SME46224_1.gif +Content-Transfer-Encoding: base64 + +R0lGODlhUABaAMQAAAAAAP///8zMzLKyspmZmQEjWGZmZlFSUgkVKOTk5Fmm3DMzMxROqCtPafT0 +9Hp/ggY3hKnc8tzw+hZn5iEjJYewweb5/QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAA +AAAALAAAAABQAFoAAAX/YCCOZGmepqOurIO+cCzPAZvceI6zdO/HK5xgSCwad6qfshdMEAfQaJQg +jRJvq6U25RAKpoTwY0wmh8NWAXKrVd2G4Ad6mHCJunDxGUqv29kzbk5fA3oDCT8JhWNUA31JgDCC +hARyhyROUGd7jmqYi410kJElk1+VBAJ2Dl8PBgcHCwsUCLUUsgcGlnV3Aqh8WH+kk4VhqiJfr7MA +zM3OzxS5qYg1oI7BpDV4p1TUvgbLz+LjzNEPlwGKltejW26UqcgE4Ajk9uQIB+fev2rtSu8WXXIw +gN69g/gOxEvXz08bPMUGIHtwgALCe/XsUTAwwM4AS/6E0QhoTETBBRft/9WqdVAhtY9UQvoguXBA +xZT4EDRokPHeAgIvQTocmalkAJs9D65cWqtAgwc8ASQdR+HBSwMxeQV681Hi0QMImYqtBeFBhQdM +D1o1iZWdDJJebYZlWqDAyroFGCiIwGDsvbUB5nX7l6Io0KMGpopbirex3QIQ9vIdy5IqARcJGPmT +9KakAAMWczZ1TDqvAgl88VJWvKBjgM/nNqOASKXGA5SiEZSuCwECb7MBIvhuTFmcAQEiBB8SOYL2 +YbnjGDfuzbs3A+unJVS4Przu6meX02nWWirTA+QJQEcfjbe3ewgMGEyYP0FBhQgRFMyPT111Wmet +VdPWMeVx4wIBuD1z1/901slHX3zxmVWBAlHlNcF1ji1lHGauTCMSROe9lthi7EHmXnzzQbCSVKvp +dmF33mnYDAISOTBPbB8qEsaBCc5Y4okOQsCiTg3E8l1eGPq3ojMGuPAZVrLVUJRE6Sk2mm8N7rfS +AV6NkAABB2z52gIIwNefkknRWINy5OFRCSLQOXMlkPWhVQtyLxCwEnIC1PJiaUsyQ4CAsVFTAzdr +huajbibC56ACtSwwgwBkHiACWvwBWhkzCyCSHpS80CbRZyS2lyWFCEjqJZgKmUCpmnrKxx1xdm0K +AJU3LidlK3CCJSejjcI3H6QI4BkYUwcYalKqAWCqAHfd/cfMA9Xo44j/C10Uk5yizMx5Kk+WJlfL +eUiFS0KYdirwLLQZ9pSPkwaAeqi2DjxQ6nuOqlvLoK/tO0KfCPA7wgBLqQvhmbVWVg+f8Q42ZToG +KMjoeyjqd+elCFD7Wpgr8esLmfUgoN/BMEpLpSv7gMiwjws0gK+j9RE7QphUgpyqzSu1XAAACyjw +AH/uxRjooJnpcq15fPoq1VMETKjuz/GpO0EtI9wpAMfMZlbLU+qqS2YDPkMbbaDU2qjPNOYhQumM +C8gRgQRwR+B011SLMC6ZIIebQKpd912Lwe+124wBa0qjhhOVuDBAaCuVZd/bIiQQdwUXB4D1oFcH +jHHfXX/tc+DEVSYp/0GGd6Yxwd1KxRsDDzz+NmoR8KSxnvl4WfuxnHctVX1At5sRBSZJcwjip2cU +8sTWtX4ffmipmkClJNxOAAC5q9sAz+sGrWQzwbdl+rJDAgtk6/ZVQLnmR9VyAHJ6hotW1zzppG/G +zyKccDnVek+8k4x7C+EDMbNe5V6VMzzJQl/xk9/1esau7fGscPrzxVrWJh0gsc5vOTNUJfSBJ4K1 +jicFIFOf5te6WTmQcF8SHldCdLXUIe9EAJwfU7pUAoDBr1Zksh4AwAa0sdWDWplRIdIg1q0FUQx+ +9RCg+g4jj3HlDio9U5dUAIcwlmDuFaAyz8lcaKp8EQt7XpNFzozkxP/qda11OTSYCb1zKxE1zB+I +slHIWFQdmNlpDNVrAM6eAjYzes1nAFDehH5GHZYgpyBG84eONEZBIzYIVW3zo89CFkZJRpJvy8uP +AgzQALscQHG5wJGbjkPEItYRPk+jZCrp9zS09LEeUcwd13iiLvPhR270IBpFEhmQc6zpV3XUCyB/ +iEHORVKGZmwdWsiHR3WBgwKjwuJg5hUGk6DkeMEUJsjIJ0VW6uuMBate67DXw05Go1e68JCUFuGp +iJkyWFEbw9YESL1J/k0BOLvnTlIJKR6a0F9BTGSotFgNd4kvedYjk1Raxk1aTlIhLKmHU/jmNZ30 +0DsUOKQ0r9WcUzz/ADPupGMXhWlPbxozZF/Y2opU+rcGjksFYEqnru6AOI6A752NiprPoqJKcD4g +AppLos8UuhJ/ag8BGRVRKN1C01Z8tAYhXVBOhRm/WnETkMjJ2N5E1jeocPOi+4JpLgaUo0LY9CgJ +cuQjo9LJm3GzKflIV9/qw7ty2mUBGg2lOkkAIsBMr4jiy+kEuMaUhmooY3Slz4XEpouKnGysWWHO +KMOTHh85hmLD2olu7CSVvmQskIHEz4QWK7an3GYtNomXHKLEV/NwxElKk2ow+0bLwoqsdQWwigXy +QzLqNACLDNMrUwsjwRAdRVElMpVe5kYsVEntWSKzgHYICTqkBiig/wJlTnOydaOXGJQ02DEf/HoG +la5xR5gP0J6ScDVWoWi3OUXBincBK1VU4udZAeyb2EAntFrUiFUyZe1sXMvExdGXMXqRG38gxGB8 +NQpN0EwOLBrGjvfy1U0deomvxFKXBCvgZSCezva4VLj2RpYoHoWSk+x1YPsaYDe8gfGKQpRCEw93 +K6dQ7TG+dM0hFcAA6upvcjWVqksIgCI2lslMiuIKjngDLSx7RaAA6ztb1ASLqo2shTmTYijdoSC2 +oMAtLLKRSyhCPZSpyo7nMdYAD2UJtHFFLrrUBbUhiGc0HJjSpAIAhRyDIK9os3u3vJX4SkO7BTGW +q3ylEHQQBMnxSv+nlofBFTYvgJQpiMEXPBG5j0w40utQ8jBoowxFAyTHn85yTESdjV2ZNVmETkGK +YdFmSQPjza1uqlk7YQVllcesslhArRnBB1bnGr6toIIY3PvrecxC2KqVQygOR5hjN/VGcl4qa1nh +7GcLt9jYsPaAUR1sYWsZIsqYhfA6sQZxc/nVs7jFtPOQ7lskktrVdncpSK2MjWxCDOAotxDzre8T +kKTJE25yoMtt70LFuuD7HkQxAp2LWJTb26B6OMS5IPFKpJvhtxCegDfOhDrn+OPBFjl5SA7nOMeL +1lm+xspZDudKV8IMWZk5zVsu8So8YufZEMQgDodroEeiBTwoeAgBAAA7 +--e7paaJyQU/hlJOcvRPG4PgAAAAU= +Content-Type: text/plain; charset=us-ascii; name=SME46224_2.txt +Content-Transfer-Encoding: 7bit + +You won't be worried about what people think of you once you see how they flock around today. The mere fact that someone has questions and interest in what you're doing suggests that they admire you for who and what you are. + +--e7paaJyQU/hlJOcvRPG4PgAAAAU=-- diff --git a/Tests/base/GSMime/mime7.dat b/Tests/base/GSMime/mime7.dat new file mode 100644 index 000000000..d126394ed Binary files /dev/null and b/Tests/base/GSMime/mime7.dat differ diff --git a/Tests/base/GSMime/mime8.dat b/Tests/base/GSMime/mime8.dat new file mode 100644 index 000000000..22d6cb001 --- /dev/null +++ b/Tests/base/GSMime/mime8.dat @@ -0,0 +1,5 @@ +MIME-Version: 1.0 +Content-Type: text/plain; type="my/type" +Content-Transfer-Encoding: binary + +Hello diff --git a/Tests/base/GSMime/mime9.dat b/Tests/base/GSMime/mime9.dat new file mode 100644 index 000000000..91110ebe5 --- /dev/null +++ b/Tests/base/GSMime/mime9.dat @@ -0,0 +1,8 @@ +MIME-Version: 1.0 +Content-Type: text/plain; type="my/type" +Content-Transfer-Encoding: binary +Long: first + second + third + +Hello diff --git a/Tests/base/GSMime/test01.m b/Tests/base/GSMime/test01.m new file mode 100644 index 000000000..154260b98 --- /dev/null +++ b/Tests/base/GSMime/test01.m @@ -0,0 +1,82 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +#import +#import +#import "Testing.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + GSMimeParser *parser = [GSMimeParser mimeParser]; + NSStringEncoding enc = [GSMimeDocument encodingFromCharset: @"utf-8"]; + NSData *data; + GSMimeDocument *doc = [[parser mimeDocument] retain]; + GSMimeHeader *hdr; + NSString *val; + NSString *raw; + BOOL complete; + + data = [@"Content-type: application/xxx\r\n" dataUsingEncoding: enc]; + PASS([parser parse:data] && [parser isInHeaders] && (doc != nil), + "can parse one header"); + + PASS([doc contentType] == nil, "First Header not complete until next starts"); + + data = [@"Content-id: <" dataUsingEncoding:enc]; + PASS([parser parse: data] && + [parser isInHeaders], + "Adding partial headers is ok"); + + PASS([[doc contentType] isEqual: @"application"] && + [[doc contentSubtype] isEqual:@"xxx"],"Parsed first header as expected"); + + data = [@"hello>\r\n" dataUsingEncoding: enc]; + PASS([parser parse: data] && + [parser isInHeaders], + "Completing partial header is ok"); + + PASS([doc contentID] == nil, "Partial header not complete until next starts"); + + data = [@"Folded\r\n : testing\r\n" dataUsingEncoding:enc]; + PASS([parser parse:data] && [parser isInHeaders], "Folded header is ok"); + + PASS([@"" isEqual: [doc contentID]],"Parsed partial header as expected %s",[[doc contentID] cString]); + + PASS([doc headerNamed: @"Folded"] == nil,"Folded header not complete until next starts"); + + data = [@"\r" dataUsingEncoding:enc]; + PASS([parser parse:data] && [parser isInHeaders], "partial end-of-line is ok"); + + PASS([[[doc headerNamed:@"Folded"] value] isEqual: @"testing"],"Parsed folded header as expected %s",[[[doc headerNamed:@"Folded"] value] cString]); + + data = [@"\n" dataUsingEncoding:enc]; + PASS([parser parse:data] && ![parser isInHeaders], "completing end-of-line is ok"); + + doc = [GSMimeDocument documentWithContent:[@"\"\\UFE66???\"" propertyList] + type:@"text/plain" + name:nil]; + [doc rawMimeData]; + PASS([[[doc headerNamed:@"content-type"] parameterForKey:@"charset"] isEqual:@"utf-8"],"charset is inferred"); + + + val = @"by mail.turbocat.net (Postfix, from userid 1002) id 90885422ECBF; Sat, 22 Dec 2007 15:40:10 +0100 (CET)"; + raw = @"Received: by mail.turbocat.net (Postfix, from userid 1002) id 90885422ECBF;\r\n\tSat, 22 Dec 2007 15:40:10 +0100 (CET)\r\n"; + hdr = [[GSMimeHeader alloc] initWithName: @"Received" value: val]; + data = [hdr rawMimeDataPreservingCase: YES]; +//NSLog(@"Header: '%*.*s'", [data length], [data length], [data bytes]); + PASS([data isEqual: [raw dataUsingEncoding: NSASCIIStringEncoding]], + "raw mime data for long header is OK"); + + data = [NSData dataWithContentsOfFile: @"HTTP1.dat"]; + parser = [GSMimeParser mimeParser]; + PASS ([parser parse: data] == NO, "can parse HTTP 200 reponse in one go"); + PASS ([parser isComplete], "parse is complete"); + + [arp release]; arp = nil; + return 0; +} +#else +int main(int argc,char **argv) +{ + return 0; +} +#endif diff --git a/Tests/base/GSMime/test02.m b/Tests/base/GSMime/test02.m new file mode 100644 index 000000000..2bdca6356 --- /dev/null +++ b/Tests/base/GSMime/test02.m @@ -0,0 +1,355 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +#import +#import +#import "Testing.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + // Test charset conversions. + PASS([GSMimeDocument encodingFromCharset: @"ansi_x3.4-1968"] + == NSASCIIStringEncoding, + "charset 'ansi_x3.4-1968' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ansi_x3.4-1986"] + == NSASCIIStringEncoding, + "charset 'ansi_x3.4-1986' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"apple-roman"] + == NSMacOSRomanStringEncoding, + "charset 'apple-roman' is NSMacOSRomanStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ascii"] + == NSASCIIStringEncoding, + "charset 'ascii' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"big5"] + == NSBIG5StringEncoding, + "charset 'big5' is NSBIG5StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"cp367"] + == NSASCIIStringEncoding, + "charset 'cp367' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"cp819"] + == NSISOLatin1StringEncoding, + "charset 'cp819' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"csascii"] + == NSASCIIStringEncoding, + "charset 'csascii' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"csisolatin1"] + == NSISOLatin1StringEncoding, + "charset 'csisolatin1' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"gb2312.1980"] + == NSGB2312StringEncoding, + "charset 'gb2312.1980' is NSGB2312StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"gsm0338"] + == NSGSM0338StringEncoding, + "charset 'gsm0338' is NSGSM0338StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ia5"] + == NSASCIIStringEncoding, + "charset 'ia5' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ibm367"] + == NSASCIIStringEncoding, + "charset 'ibm367' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ibm819"] + == NSISOLatin1StringEncoding, + "charset 'ibm819' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-10646-ucs-2"] + == NSUnicodeStringEncoding, + "charset 'iso-10646-ucs-2' is NSUnicodeStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso10646-ucs-2"] + == NSUnicodeStringEncoding, + "charset 'iso10646-ucs-2' is NSUnicodeStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-1"] + == NSISOLatin1StringEncoding, + "charset 'iso-8859-1' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-1"] + == NSISOLatin1StringEncoding, + "charset 'iso8859-1' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-10"] + == NSISOLatin6StringEncoding, + "charset 'iso-8859-10' is NSISOLatin6StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-10"] + == NSISOLatin6StringEncoding, + "charset 'iso8859-10' is NSISOLatin6StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-11"] + == NSISOThaiStringEncoding, + "charset 'iso-8859-11' is NSISOThaiStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-11"] + == NSISOThaiStringEncoding, + "charset 'iso8859-11' is NSISOThaiStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-13"] + == NSISOLatin7StringEncoding, + "charset 'iso-8859-13' is NSISOLatin7StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-13"] + == NSISOLatin7StringEncoding, + "charset 'iso8859-13' is NSISOLatin7StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-14"] + == NSISOLatin8StringEncoding, + "charset 'iso-8859-14' is NSISOLatin8StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-14"] + == NSISOLatin8StringEncoding, + "charset 'iso8859-14' is NSISOLatin8StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-15"] + == NSISOLatin9StringEncoding, + "charset 'iso-8859-15' is NSISOLatin9StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-15"] + == NSISOLatin9StringEncoding, + "charset 'iso8859-15' is NSISOLatin9StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-1:1987"] + == NSISOLatin1StringEncoding, + "charset 'iso-8859-1:1987' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-1:1987"] + == NSISOLatin1StringEncoding, + "charset 'iso8859-1:1987' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-2"] + == NSISOLatin2StringEncoding, + "charset 'iso-8859-2' is NSISOLatin2StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-2"] + == NSISOLatin2StringEncoding, + "charset 'iso8859-2' is NSISOLatin2StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-3"] + == NSISOLatin3StringEncoding, + "charset 'iso-8859-3' is NSISOLatin3StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-3"] + == NSISOLatin3StringEncoding, + "charset 'iso8859-3' is NSISOLatin3StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-4"] + == NSISOLatin4StringEncoding, + "charset 'iso-8859-4' is NSISOLatin4StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-4"] + == NSISOLatin4StringEncoding, + "charset 'iso8859-4' is NSISOLatin4StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-5"] + == NSISOCyrillicStringEncoding, + "charset 'iso-8859-5' is NSISOCyrillicStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-5"] + == NSISOCyrillicStringEncoding, + "charset 'iso8859-5' is NSISOCyrillicStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-6"] + == NSISOArabicStringEncoding, + "charset 'iso-8859-6' is NSISOArabicStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-6"] + == NSISOArabicStringEncoding, + "charset 'iso8859-6' is NSISOArabicStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-7"] + == NSISOGreekStringEncoding, + "charset 'iso-8859-7' is NSISOGreekStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-7"] + == NSISOGreekStringEncoding, + "charset 'iso8859-7' is NSISOGreekStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-8"] + == NSISOHebrewStringEncoding, + "charset 'iso-8859-8' is NSISOHebrewStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-8"] + == NSISOHebrewStringEncoding, + "charset 'iso8859-8' is NSISOHebrewStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-8859-9"] + == NSISOLatin5StringEncoding, + "charset 'iso-8859-9' is NSISOLatin5StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso8859-9"] + == NSISOLatin5StringEncoding, + "charset 'iso8859-9' is NSISOLatin5StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-ir-100"] + == NSISOLatin1StringEncoding, + "charset 'iso-ir-100' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-ir-6"] + == NSASCIIStringEncoding, + "charset 'iso-ir-6' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso-10646-1"] + == NSUnicodeStringEncoding, + "charset 'iso-10646-1' is NSUnicodeStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso10646-1"] + == NSUnicodeStringEncoding, + "charset 'iso10646-1' is NSUnicodeStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso646-us"] + == NSASCIIStringEncoding, + "charset 'iso646-us' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso_646.991-irv"] + == NSASCIIStringEncoding, + "charset 'iso_646.991-irv' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso_646.irv:1991"] + == NSASCIIStringEncoding, + "charset 'iso_646.irv:1991' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"iso_8859-1"] + == NSISOLatin1StringEncoding, + "charset 'iso_8859-1' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"jisx0201.1976"] + == NSShiftJISStringEncoding, + "charset 'jisx0201.1976' is NSShiftJISStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"koi8-r"] + == NSKOI8RStringEncoding, + "charset 'koi8-r' is NSKOI8RStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ksc5601.1987"] + == NSKoreanEUCStringEncoding, + "charset 'ksc5601.1987' is NSKoreanEUCStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"ksc5601.1997"] + == NSKoreanEUCStringEncoding, + "charset 'ksc5601.1997' is NSKoreanEUCStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"l1"] + == NSISOLatin1StringEncoding, + "charset 'l1' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"latin1"] + == NSISOLatin1StringEncoding, + "charset 'latin1' is NSISOLatin1StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"microsoft-cp1250"] + == NSWindowsCP1250StringEncoding, + "charset 'microsoft-cp1250' is NSWindowsCP1250StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"microsoft-cp1251"] + == NSWindowsCP1251StringEncoding, + "charset 'microsoft-cp1251' is NSWindowsCP1251StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"microsoft-cp1252"] + == NSWindowsCP1252StringEncoding, + "charset 'microsoft-cp1252' is NSWindowsCP1252StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"microsoft-cp1253"] + == NSWindowsCP1253StringEncoding, + "charset 'microsoft-cp1253' is NSWindowsCP1253StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"microsoft-cp1254"] + == NSWindowsCP1254StringEncoding, + "charset 'microsoft-cp1254' is NSWindowsCP1254StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"microsoft-symbol"] + == NSSymbolStringEncoding, + "charset 'microsoft-symbol' is NSSymbolStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"shift_JIS"] + == NSShiftJISStringEncoding, + "charset 'shift_JIS' is NSShiftJISStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"us"] + == NSASCIIStringEncoding, + "charset 'us' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"us-ascii"] + == NSASCIIStringEncoding, + "charset 'us-ascii' is NSASCIIStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"utf-16"] + == NSUnicodeStringEncoding, + "charset 'utf-16' is NSUnicodeStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"utf16"] + == NSUnicodeStringEncoding, + "charset 'utf16' is NSUnicodeStringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"utf-7"] + == NSUTF7StringEncoding, + "charset 'utf-7' is NSUTF7StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"utf7"] + == NSUTF7StringEncoding, + "charset 'utf7' is NSUTF7StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"utf-8"] + == NSUTF8StringEncoding, + "charset 'utf-8' is NSUTF8StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"utf8"] + == NSUTF8StringEncoding, + "charset 'utf8' is NSUTF8StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"windows-1250"] + == NSWindowsCP1250StringEncoding, + "charset 'windows-1250' is NSWindowsCP1250StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"windows-1251"] + == NSWindowsCP1251StringEncoding, + "charset 'windows-1251' is NSWindowsCP1251StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"windows-1252"] + == NSWindowsCP1252StringEncoding, + "charset 'windows-1252' is NSWindowsCP1252StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"windows-1253"] + == NSWindowsCP1253StringEncoding, + "charset 'windows-1253' is NSWindowsCP1253StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"windows-1254"] + == NSWindowsCP1254StringEncoding, + "charset 'windows-1254' is NSWindowsCP1254StringEncoding"); + PASS([GSMimeDocument encodingFromCharset: @"windows-symbol"] + == NSSymbolStringEncoding, + "charset 'windows-symbol' is NSSymbolStringEncoding"); + + // Test canonical charset names. + + PASS([[GSMimeDocument charsetFromEncoding: NSASCIIStringEncoding] + isEqualToString: @"us-ascii"], + "NSASCIIStringEncoding canonical charset is us-ascii"); + PASS([[GSMimeDocument charsetFromEncoding: NSBIG5StringEncoding] + isEqualToString: @"big5"], + "NSBIG5StringEncoding canonical charset is big5"); + PASS([[GSMimeDocument charsetFromEncoding: NSGB2312StringEncoding] + isEqualToString: @"gb2312.1980"], + "NSGB2312StringEncoding canonical charset is gb2312.1980"); + PASS([[GSMimeDocument charsetFromEncoding: NSGSM0338StringEncoding] + isEqualToString: @"gsm0338"], + "NSGSM0338StringEncoding canonical charset is gsm0338"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOArabicStringEncoding] + isEqualToString: @"iso-8859-6"], + "NSISOArabicStringEncoding canonical charset is iso-8859-6"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOCyrillicStringEncoding] + isEqualToString: @"iso-8859-5"], + "NSISOCyrillicStringEncoding canonical charset is iso-8859-5"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOGreekStringEncoding] + isEqualToString: @"iso-8859-7"], + "NSISOGreekStringEncoding canonical charset is iso-8859-7"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOHebrewStringEncoding] + isEqualToString: @"iso-8859-8"], + "NSISOHebrewStringEncoding canonical charset is iso-8859-8"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin1StringEncoding] + isEqualToString: @"iso-8859-1"], + "NSISOLatin1StringEncoding canonical charset is iso-8859-1"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin2StringEncoding] + isEqualToString: @"iso-8859-2"], + "NSISOLatin2StringEncoding canonical charset is iso-8859-2"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin3StringEncoding] + isEqualToString: @"iso-8859-3"], + "NSISOLatin3StringEncoding canonical charset is iso-8859-3"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin4StringEncoding] + isEqualToString: @"iso-8859-4"], + "NSISOLatin4StringEncoding canonical charset is iso-8859-4"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin5StringEncoding] + isEqualToString: @"iso-8859-9"], + "NSISOLatin5StringEncoding canonical charset is iso-8859-9"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin6StringEncoding] + isEqualToString: @"iso-8859-10"], + "NSISOLatin6StringEncoding canonical charset is iso-8859-10"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin7StringEncoding] + isEqualToString: @"iso-8859-13"], + "NSISOLatin7StringEncoding canonical charset is iso-8859-13"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin8StringEncoding] + isEqualToString: @"iso-8859-14"], + "NSISOLatin8StringEncoding canonical charset is iso-8859-14"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOLatin9StringEncoding] + isEqualToString: @"iso-8859-15"], + "NSISOLatin9StringEncoding canonical charset is iso-8859-15"); + PASS([[GSMimeDocument charsetFromEncoding: NSISOThaiStringEncoding] + isEqualToString: @"iso-8859-11"], + "NSISOThaiStringEncoding canonical charset is iso-8859-11"); + PASS([[GSMimeDocument charsetFromEncoding: NSKOI8RStringEncoding] + isEqualToString: @"koi8-r"], + "NSKOI8RStringEncoding canonical charset is koi8-r"); + PASS([[GSMimeDocument charsetFromEncoding: NSKoreanEUCStringEncoding] + isEqualToString: @"ksc5601.1987"], + "NSKoreanEUCStringEncoding canonical charset is ksc5601.1987"); + PASS([[GSMimeDocument charsetFromEncoding: NSMacOSRomanStringEncoding] + isEqualToString: @"apple-roman"], + "NSMacOSRomanStringEncoding canonical charset is apple-roman"); + PASS([[GSMimeDocument charsetFromEncoding: NSShiftJISStringEncoding] + isEqualToString: @"shift_JIS"], + "NSShiftJISStringEncoding canonical charset is shift_JIS"); + PASS([[GSMimeDocument charsetFromEncoding: NSUTF7StringEncoding] + isEqualToString: @"utf-7"], + "NSUTF7StringEncoding canonical charset is utf-7"); + PASS([[GSMimeDocument charsetFromEncoding: NSUTF8StringEncoding] + isEqualToString: @"utf-8"], + "NSUTF8StringEncoding canonical charset is utf-8"); + PASS([[GSMimeDocument charsetFromEncoding: NSUnicodeStringEncoding] + isEqualToString: @"utf-16"], + "NSUnicodeStringEncoding canonical charset is utf-16"); + PASS([[GSMimeDocument charsetFromEncoding: NSWindowsCP1250StringEncoding] + isEqualToString: @"windows-1250"], + "NSWindowsCP1250StringEncoding canonical charset is windows-1250"); + PASS([[GSMimeDocument charsetFromEncoding: NSWindowsCP1251StringEncoding] + isEqualToString: @"windows-1251"], + "NSWindowsCP1251StringEncoding canonical charset is windows-1251"); + PASS([[GSMimeDocument charsetFromEncoding: NSWindowsCP1252StringEncoding] + isEqualToString: @"windows-1252"], + "NSWindowsCP1252StringEncoding canonical charset is windows-1252"); + PASS([[GSMimeDocument charsetFromEncoding: NSWindowsCP1253StringEncoding] + isEqualToString: @"windows-1253"], + "NSWindowsCP1253StringEncoding canonical charset is windows-1253"); + PASS([[GSMimeDocument charsetFromEncoding: NSWindowsCP1254StringEncoding] + isEqualToString: @"windows-1254"], + "NSWindowsCP1254StringEncoding canonical charset is windows-1254"); + [arp release]; arp = nil; + return 0; +} +#else +int main(int argc,char **argv) +{ + return 0; +} +#endif diff --git a/Tests/base/GSXML/TestInfo b/Tests/base/GSXML/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/GSXML/basic.m b/Tests/base/GSXML/basic.m new file mode 100644 index 000000000..359caa530 --- /dev/null +++ b/Tests/base/GSXML/basic.m @@ -0,0 +1,159 @@ +#import +#import "Testing.h" +#if defined(GNUSTEP_BASE_LIBRARY) && (GS_USE_LIBXML == 1) +#import +#import "ObjectTesting.h" +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + GSXMLDocument *doc; + volatile GSXMLNamespace *namespace; + NSMutableArray *iparams; + NSMutableArray *oparams; + GSXMLNode *node; + GSXMLRPC *rpc; + NSString *str; + NSData *dat; + + TEST_FOR_CLASS(@"GSXMLDocument",[GSXMLDocument alloc], + "GSXMLDocument +alloc returns a GSXMLDocument"); + + TEST_FOR_CLASS(@"GSXMLDocument",[GSXMLDocument documentWithVersion: @"1.0"], + "GSXMLDocument +documentWithVersion: returns a GSXMLDocument"); + + TEST_FOR_CLASS(@"GSXMLNode",[GSXMLNode alloc], + "GSXMLNode +alloc returns a GSXMLNode"); + + TEST_FOR_CLASS(@"GSXMLRPC",[GSXMLRPC alloc], + "GSXMLRPC +alloc returns a GSXMLRPC instance"); + + NS_DURING + node = [GSXMLNode new]; + PASS(node == nil, "GSXMLNode +new returns nil"); + NS_HANDLER + PASS(node == nil, "GSXMLNode +new returns nil"); + NS_ENDHANDLER + + TEST_FOR_CLASS(@"GSXMLNamespace",[GSXMLNamespace alloc], + "GSXMLNamespace +alloc returns a GSXMLNamespace"); + + + NS_DURING + namespace = [GSXMLNamespace new]; + PASS(namespace == nil, "GSXMLNamespace +new returns nil"); + NS_HANDLER + PASS(namespace == nil, "GSXMLNamespace +new returns nil"); + NS_ENDHANDLER + + doc = [GSXMLDocument documentWithVersion: @"1.0"]; + node = [doc makeNodeWithNamespace: nil name: @"nicola" content: nil]; + PASS (node != nil,"Can create a document node"); + + + [doc setRoot: node]; + PASS([[doc root] isEqual: node],"Can set document node as root node"); + + [doc makeNodeWithNamespace: nil name: @"nicola" content: nil]; + [node makeChildWithNamespace: nil + name: @"paragraph" + content: @"Hi this is some text"]; + [node makeChildWithNamespace: nil + name: @"paragraph" + content: @"Hi this is even some more text"]; + [doc setRoot: node]; + PASS([[doc root] isEqual: node], + "Can set a document node (with children) as root node"); + + namespace = [node makeNamespaceHref: @"http: //www.gnustep.org" + prefix: @"gnustep"]; + PASS(namespace != nil,"Can create a node namespace"); + + node = [doc makeNodeWithNamespace: namespace name: @"nicola" content: nil]; + PASS([[node namespace] isEqual: namespace], + "Can create a node with a namespace"); + + node = [doc makeNodeWithNamespace: namespace name: @"another" content: nil]; + PASS([[node namespace] isEqual: namespace], + "Can create a node with same namespace as another node"); + + PASS([[namespace prefix] isEqual: @"gnustep"], + "A namespace remembers its prefix"); + + + rpc = [(GSXMLRPC*)[GSXMLRPC alloc] initWithURL: @"http://localhost/"]; + PASS(rpc != nil, "Can initialise an RPC instance"); + + iparams = [NSMutableArray array]; + oparams = [NSMutableArray array]; + + dat = [rpc buildMethod: @"method" params: nil]; + PASS(dat != nil, "Can build an empty method call (nil params)"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse an empty method call (nil params)"); + + dat = [rpc buildMethod: @"method" params: iparams]; + PASS(dat != nil, "Can build an empty method call"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse an empty method call"); + + [iparams addObject: @"a string"]; + dat = [rpc buildMethod: @"method" params: iparams]; + PASS(dat != nil, "Can build a method call with a string"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse a method call with a string"); + + [rpc setCompact: YES]; + str = [rpc buildMethodCall: @"method" params: iparams]; + [rpc setCompact: NO]; + str = [str stringByReplacingString: @"" withString: @""]; + str = [str stringByReplacingString: @"" withString: @""]; + str = [rpc parseMethod: [str dataUsingEncoding: NSUTF8StringEncoding] + params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse a method call with a string without the element"); + + [iparams addObject: [NSNumber numberWithInt: 4]]; + dat = [rpc buildMethod: @"method" params: iparams]; + PASS(dat != nil, "Can build a method call with an integer"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse a method call with an integer"); + + [iparams addObject: [NSNumber numberWithFloat: 4.5]]; + dat = [rpc buildMethod: @"method" params: iparams]; + PASS(dat != nil, "Can build a method call with a float"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse a method call with a float"); + + [iparams addObject: [NSData dataWithBytes: "1234" length: 4]]; + dat = [rpc buildMethod: @"method" params: iparams]; + PASS(dat != nil, "Can build a method call with binary data"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] && [iparams isEqual: oparams], + "Can parse a method call with binary data"); + + [iparams addObject: [NSDate date]]; + dat = [rpc buildMethod: @"method" params: iparams]; + PASS(dat != nil, "Can build a method call with a date"); + str = [rpc parseMethod: dat params: oparams]; + PASS([str isEqual: @"method"] + && [[iparams description] isEqual: [oparams description]], + "Can parse a method call with a date"); + + + [arp release]; arp = nil; + return 0; +} +#else +int main(int argc,char **argv) +{ + START_SET("GSXML") + SKIP("GSXML support unavailable"); + END_SET("GSXML") + return 0; +} +#endif diff --git a/Tests/base/GarbageCollection/TestInfo b/Tests/base/GarbageCollection/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/GarbageCollection/general.m b/Tests/base/GarbageCollection/general.m new file mode 100644 index 000000000..763d8bca0 --- /dev/null +++ b/Tests/base/GarbageCollection/general.m @@ -0,0 +1,28 @@ +#import +#import "ObjectTesting.h" + +int +main() +{ + NSGarbageCollector *collector; + NSZone *z; + + collector = [NSGarbageCollector defaultCollector]; + if (collector == nil) return 0; + + START_SET("Garbage collection"); + + PASS([collector zone] == NSDefaultMallocZone(), + "collector zone is default") + PASS([[NSObject new] zone] == NSDefaultMallocZone(), + "object zone is default") + PASS((z = NSCreateZone(1024, 128, YES)) == NSDefaultMallocZone(), + "created zone is default") + PASS((z = NSCreateZone(1024, 128, YES)) == NSDefaultMallocZone(), + "created zone is default") + PASS_RUNS(NSRecycleZone(z), "zone recycling works") + + END_SET("Garbage collection"); + + return 0; +} diff --git a/Tests/base/GarbageCollection/notifications.m b/Tests/base/GarbageCollection/notifications.m new file mode 100644 index 000000000..a571b17d3 --- /dev/null +++ b/Tests/base/GarbageCollection/notifications.m @@ -0,0 +1,59 @@ +#import +#import "ObjectTesting.h" + +@interface MyClass : NSObject ++ (unsigned) finalisationCounter; ++ (unsigned) notificationCounter; +- (void) notified: (NSNotification*)n; +@end + +@implementation MyClass +static unsigned notificationCounter = 0; +static unsigned finalisationCounter = 0; ++ (unsigned) finalisationCounter +{ + return finalisationCounter; +} ++ (unsigned) notificationCounter +{ + return notificationCounter; +} +- (void) finalize +{ + finalisationCounter++; +} +- (void) notified: (NSNotification*)n +{ + notificationCounter++; +} +@end + +int +main() +{ + NSGarbageCollector *collector; + NSNotificationCenter *center; + MyClass *object; + + collector = [NSGarbageCollector defaultCollector]; + if (collector == nil) return 0; + + START_SET("Garbage Collection"); + center = [NSNotificationCenter defaultCenter]; + object = [MyClass new]; + [center addObserver: object + selector: @selector(notified:) + name: @"Notification" + object: nil]; + + [center postNotificationName: @"Notification" object: nil]; + PASS([MyClass notificationCounter] == 1, "simple notification works") + object = nil; + [collector collectExhaustively]; + PASS([MyClass finalisationCounter] == 1, "finalisation done") + [center postNotificationName: @"Notification" object: nil]; + PASS([MyClass notificationCounter] == 1, "automatic removal works") + + END_SET("Garbage Collection"); + return 0; +} diff --git a/Tests/base/GenericTests/GNUmakefile b/Tests/base/GenericTests/GNUmakefile new file mode 100644 index 000000000..04d6754c9 --- /dev/null +++ b/Tests/base/GenericTests/GNUmakefile @@ -0,0 +1,11 @@ +# +# +# + +include $(GNUSTEP_MAKEFILES)/common.make + +SUBPROJECT_NAME=generictests + +generictests_OBJC_FILES=generic.m + +include $(GNUSTEP_MAKEFILES)/subproject.make diff --git a/Tests/base/GenericTests/generic.h b/Tests/base/GenericTests/generic.h new file mode 100644 index 000000000..9b47bf1bc --- /dev/null +++ b/Tests/base/GenericTests/generic.h @@ -0,0 +1,10 @@ + +#import +#import + +@interface NSObject(TestsAdditions) +-(BOOL)testEquals: (id)anObject; +-(BOOL)testForString; +-(BOOL)testForClass; +@end + diff --git a/Tests/base/GenericTests/generic.m b/Tests/base/GenericTests/generic.m new file mode 100644 index 000000000..700bfa036 --- /dev/null +++ b/Tests/base/GenericTests/generic.m @@ -0,0 +1,20 @@ +#import "generic.h" + +@interface NSObject (PretendToBeNSString) +- (NSUInteger)length; +@end + +@implementation NSObject(TestAdditions) +-(BOOL)testEquals:(id)anObject +{ + return ([self isEqual:anObject] && [anObject isEqual:self]); +} +- (int) length +{ + return 0; +} +-(BOOL)testForString +{ + return ([self isKindOfClass:[NSString class]] && [self length]); +} +@end diff --git a/Tests/base/KVC/TestInfo b/Tests/base/KVC/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/KVC/array.m b/Tests/base/KVC/array.m new file mode 100644 index 000000000..7f1974518 --- /dev/null +++ b/Tests/base/KVC/array.m @@ -0,0 +1,69 @@ +#import "ObjectTesting.h" +#import + +@interface ArrayIVar : NSObject +{ + NSArray *_testArray; +} +- (void) setTestArray: (NSArray*)array; +- (NSArray*) testArray; +@end + +@implementation ArrayIVar +- (void) setTestArray: (NSArray*)array +{ + [array retain]; + [_testArray release]; + _testArray = array; +} +- (NSArray*) testArray +{ + return _testArray; +} +@end + +int main(int argc,char **argv) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + volatile BOOL result = NO; + NSDictionary *root; + NSArray *array; + NSArray *ivar; + ArrayIVar *aiv; + NSString *plist; + id tmp = nil; + + array = [@"({value=10;},{value=12;})" propertyList]; + plist = @"{displayGroup={allObjects=({detailArray=({value=4;},{value=2;});},{detailArray=({value=8;},{value=10;});});};}"; + root = [plist propertyList]; + + result = [[array valueForKeyPath:@"@sum.value"] intValue] == 22; + PASS(result, "-[NSArray valueForKeyPath: @\"@sum.value\"]"); + + result = [[array valueForKeyPath:@"@count.value"] intValue] == 2; + PASS(result, "-[NSArray valueForKeyPath: @\"@count.value\"]"); + + result = [[array valueForKeyPath:@"@count"] intValue] == 2; + PASS(result, "-[NSArray valueForKeyPath: @\"@count\"]"); + + aiv = [ArrayIVar new]; + ivar = [NSArray arrayWithObjects: @"Joe", @"Foo", @"Bar", @"Cat", nil]; + [aiv setTestArray: ivar]; + + PASS([aiv valueForKeyPath: @"testArray.@count"] + == [ivar valueForKey: @"@count"], "valueForKey: matches valueForKeypath:"); + + /* Advanced KVC */ + + result = [[root valueForKeyPath:@"displayGroup.allObjects.@sum.detailArray.@avg.value"] intValue] == 12; + PASS(result, "-[NSArray valueForKeyPath: @\"displayGroup.allObjects.@sum.detailArray.@avg.value\"]"); + + result = [[root valueForKeyPath:@"displayGroup.allObjects.@sum.detailArray.@count.value"] intValue] == 4; + PASS(result, "-[NSArray valueForKeyPath: @\"displayGroup.allObjects.@sum.detailArray.@count.value\"]"); + + result = [[root valueForKeyPath:@"displayGroup.allObjects.@sum.detailArray.@count"] intValue] == 4; + PASS(result, "-[NSArray valueForKeyPath: @\"displayGroup.allObjects.@sum.detailArray.@count\"]"); + + [pool release]; + return (0); +} diff --git a/Tests/base/KVC/basic.m b/Tests/base/KVC/basic.m new file mode 100644 index 000000000..3e3e7ec99 --- /dev/null +++ b/Tests/base/KVC/basic.m @@ -0,0 +1,260 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import +#import + +typedef struct { + int i; + char c; +} myStruct; + +@interface TestClass : NSObject +{ + NSString *name; + NSDate *date; + int num1; + double num2; + int num3; + int num4; + TestClass *child; + myStruct s; +} + +- (void) setNum3:(int) num; +- (int) num3; +- (void) _setNum4:(int) num; +- (int) _num4; +- (char) sc; +- (int) si; +- (myStruct) sv; +- (void) setSv: (myStruct)v; + +@end + +@implementation TestClass + +- (id) init +{ + s.i = 1; + s.c = 2; + return self; +} + +- (void) setNum3:(int) num +{ + num3 = num; + if (num3 == 8) num3 = 7; +} + +- (int) num3 +{ + return num3; +} + +- (void) _setNum4:(int) num +{ + num4 = num; + if (num4 == 8) num4 = 7; +} + +- (int) _num4 +{ + return num4; +} + +- (char) sc +{ + return s.c; +} + +- (int) si +{ + return s.i; +} + +- (myStruct) sv +{ + return s; +} + +- (void) setSv: (myStruct)v +{ + s = v; +} +@end + +@interface UndefinedKey : NSObject +{ + int num1; + NSString *string; +} +@end + +@implementation UndefinedKey +- (void) dealloc +{ + [string release]; + [super dealloc]; +} + +- (void) setValue:(id) value forUndefinedKey:(NSString *) key +{ + if ([key isEqualToString: @"Lxcke"]) { + [string release]; + string = [value copy]; + } +} + +- (id) valueForUndefinedKey:(NSString *) key +{ + if ([key isEqualToString: @"Lxcke"]) { + return string; + } + return nil; +} + +@end + +@interface UndefinedKey2 : NSObject +{ + int num1; + NSString *string; +} +@end + +@implementation UndefinedKey2 +- (void) dealloc +{ + [string release]; + [super dealloc]; +} + +- (void) handleTakeValue:(id) value forUnboundKey:(NSString *) key +{ + if ([key isEqualToString: @"Lxcke"]) { + [string release]; + string = [value copy]; + } +} + +- (id) handleQueryWithUnboundKey:(NSString *) key +{ + if ([key isEqualToString: @"Lxcke"]) { + return string; + } + return nil; +} + +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableString *m = [NSMutableString string]; + TestClass *tester = [[[TestClass alloc] init] autorelease]; + NSUInteger rc; + NSValue *v; + myStruct s; + + [m appendString: @"testing"]; + + [tester setValue:[[[TestClass alloc] init] autorelease] forKey: @"child"]; + UndefinedKey *undefinedKey = [[[UndefinedKey alloc] init] autorelease]; + UndefinedKey2 *undefinedKey2 = [[[UndefinedKey2 alloc] init] autorelease]; + + NSNumber *n = [NSNumber numberWithInt:8]; + NSNumber *adjustedN = [NSNumber numberWithInt:7]; + NSNumber *n2 = [NSNumber numberWithDouble:87.999]; + + [tester setValue: @"tester" forKey: @"name"]; + PASS([[tester valueForKey: @"name"] isEqualToString: @"tester"], + "KVC works with strings"); + + rc = [m retainCount]; + [tester setValue: m forKey: @"name"]; + PASS([tester valueForKey: @"name"] == m, + "KVC works with mutable string"); + if (nil == [NSGarbageCollector defaultCollector]) + { + PASS(rc + 1 == [m retainCount], "KVC retains object values"); + } + + [tester setValue:n forKey: @"num1"]; + PASS([[tester valueForKey: @"num1"] isEqualToNumber:n], + "KVC works with ints"); + + [tester setValue:n2 forKey: @"num2"]; + PASS([[tester valueForKey: @"num2"] isEqualToNumber:n2], + "KVC works with doubles"); + + [tester setValue:n forKey: @"num3"]; + PASS([[tester valueForKey: @"num3"] isEqualToNumber:adjustedN], + "KVC works with setKey:"); + + [tester setValue:n forKey: @"num4"]; + PASS([[tester valueForKey: @"num4"] isEqualToNumber:adjustedN], + "KVC works with _setKey:"); + + v = [tester valueForKey: @"s"]; + s.i = 0; + s.c = 0; + [v getValue: &s]; + PASS(s.i == 1 && s.c == 2, "KVC valueForKey: works for a struct (direct)"); + + v = [tester valueForKey: @"sv"]; + s.i = 0; + s.c = 0; + [v getValue: &s]; + PASS(s.i == 1 && s.c == 2, "KVC valueForKey: works for a struct (getter)"); + + s.i = 3; + s.c = 4; + v = [NSValue valueWithBytes: &s objCType: @encode(myStruct)]; + [tester setValue: v forKey: @"s"]; + PASS([tester si] == s.i && [tester sc] == s.c, + "KVC setValue:forKey: works for a struct (direct)"); + + s.i = 5; + s.c = 6; + v = [NSValue valueWithBytes: &s objCType: @encode(myStruct)]; + [tester setValue: v forKey: @"sv"]; + PASS([tester si] == s.i && [tester sc] == s.c, + "KVC setValue:forKey: works for a struct (setter)"); + + [undefinedKey setValue: @"GNUstep" forKey: @"Lxcke"]; + PASS([[undefinedKey valueForKey: @"Lxcke"] isEqualToString: @"GNUstep"], + "KVC works with undefined keys"); + + [undefinedKey2 setValue: @"GNUstep" forKey: @"Lxcke"]; + PASS([[undefinedKey2 valueForKey: @"Lxcke"] isEqualToString: @"GNUstep"], + "KVC works with undefined keys (using deprecated methods) "); + + PASS_EXCEPTION( + [tester setValue: @"" forKey: @"nonexistent"], + NSUndefinedKeyException, + "KVC properly throws @\"NSUnknownKeyException\""); + + PASS_EXCEPTION( + [tester setValue: @"" forKey: @"nonexistent"], + NSUndefinedKeyException, + "KVC properly throws NSUndefinedKeyException"); + + PASS_EXCEPTION( + [tester setValue: @"" forKeyPath: @"child.nonexistent"], + @"NSUnknownKeyException", + "KVC properly throws @\"NSUnknownKeyException\" with key paths"); + + PASS_EXCEPTION( + [tester setValue: @"" forKeyPath: @"child.nonexistent"], + NSUndefinedKeyException, + "KVC properly throws NSUndefinedKeyException with key paths"); + + PASS(sel_getUid(0) == 0, "null string gives null selector"); + PASS(sel_registerName(0) == 0, "register null string gives null selector"); + PASS(strcmp(sel_getName(0) , "") == 0, "null selector name"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/KVC/mutable.m b/Tests/base/KVC/mutable.m new file mode 100644 index 000000000..54e29072d --- /dev/null +++ b/Tests/base/KVC/mutable.m @@ -0,0 +1,250 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +@interface Observer : NSObject +- (void) observeValueForKeyPath: (NSString *)keyPath + ofObject: (id)object + change: (NSDictionary *)change + context: (void *)context; +@end + +@implementation Observer +- (void) observeValueForKeyPath: (NSString *)keyPath + ofObject: (id)object + change: (NSDictionary *)change + context: (void *)context +{ + NSLog(@"observeValueForKeyPath: %@\nofObject:%@\nchange:%@\ncontext:%p", + keyPath, object, change, context); +} +@end + +@interface Lists : NSObject +{ + NSMutableArray * cities; + NSMutableArray * numbers; + NSMutableArray * third; + NSString *string; +} + +@end + + +@implementation Lists + +- (id)init +{ + cities = [[NSMutableArray alloc] initWithObjects: + @"Grand Rapids", + @"Chicago", + nil]; + numbers = [[NSMutableArray alloc] initWithObjects: + @"One", + @"Ten", + @"Three", + @"Ninety", + nil]; + third = [[NSMutableArray alloc] initWithObjects: + @"a", + @"b", + @"c", + nil]; + + return self; +} + +- (void)insertObject:(id)obj inNumbersAtIndex:(unsigned int)index +{ + if (![obj isEqualToString:@"NaN"]) + { + [numbers addObject:obj]; + } +} + +- (void)removeObjectFromNumbersAtIndex:(unsigned int)index +{ + if (![[numbers objectAtIndex:index] isEqualToString:@"One"]) + [numbers removeObjectAtIndex:index]; +} + +- (void)replaceObjectInNumbersAtIndex:(unsigned int)index withObject:(id)obj +{ + if (index == 1) + obj = @"Two"; + [numbers replaceObjectAtIndex:index withObject:obj]; +} + +- (void)setCities:(NSArray *)other +{ + [cities setArray:other]; +} + +- (void) didChangeValueForKey: (NSString*)k +{ + NSLog(@"%@ %@", NSStringFromSelector(_cmd), k); + [super didChangeValueForKey: k]; +} + +- (void) willChangeValueForKey: (NSString*)k +{ + [super willChangeValueForKey: k]; + NSLog(@"%@ %@", NSStringFromSelector(_cmd), k); +} +@end + +@interface Sets : NSObject +{ + NSMutableSet * one; + NSMutableSet * two; + NSMutableSet * three; +} +@end + +@implementation Sets + +- (id)init +{ + [super init]; + + one = [[NSMutableSet alloc] initWithObjects: + @"one", + @"two", + @"eight", + nil]; + two = [[NSMutableSet alloc] initWithSet:one]; + three = [[NSMutableSet alloc] initWithSet:one]; + + return self; +} + +- (void)addOneObject:(id)anObject +{ + if (![anObject isEqualToString:@"ten"]) + [one addObject:anObject]; +} + +- (void)removeOneObject:(id)anObject +{ + if (![anObject isEqualToString:@"one"]) + { + [one removeObject:anObject]; + } +} + +- (void)setTwo:(NSMutableSet *)set +{ + [two setSet:set]; +} + +@end + +int main(void) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + Lists *list = [[[Lists alloc] init] autorelease]; + Observer *observer = [Observer new]; + id o; + NSMutableArray * proxy; + NSDictionary * temp; + + [list addObserver: observer forKeyPath: @"numbers" options: 15 context: 0]; + [list addObserver: observer forKeyPath: @"string" options: 15 context: 0]; + + [list setValue: @"x" forKey: @"string"]; + + proxy = [list mutableArrayValueForKey:@"numbers"]; + PASS([proxy isKindOfClass:[NSMutableArray class]], + "proxy is a kind of NSMutableArray") + [proxy removeLastObject]; + PASS_EXCEPTION([proxy addObject:@"NaN"];, + NSRangeException,"bad removal causes range exception when observing") + [proxy replaceObjectAtIndex:1 withObject:@"Seven"]; + [proxy addObject:@"Four"]; + [proxy removeObject:@"One"]; + + o = [NSArray arrayWithObjects: + @"One", + @"Two", + @"Three", + @"Four", + nil]; + PASS([[list valueForKey:@"numbers"] isEqualToArray: o], + "KVC mutableArrayValueForKey: proxy works with array proxy methods") + + proxy = [list mutableArrayValueForKey:@"cities"]; + PASS([proxy isKindOfClass:[NSMutableArray class]], + "proxy is a kind of NSMutableArray") + [proxy addObject:@"Lima"]; + o = [NSArray arrayWithObjects: + @"Grand Rapids", + @"Chicago", + @"Lima", + nil]; + PASS([[list valueForKey:@"cities"] isEqualToArray: o], + "KVC mutableArrayValueForKey: proxy works with set:") + + proxy = [list mutableArrayValueForKey:@"third"]; + PASS([proxy isKindOfClass:[NSMutableArray class]], + "proxy is a kind of NSMutableArray") + + PASS(proxy != [list valueForKey:@"third"], + "KVC mutableArrayValueForKey: returns a proxy array for the ivar") + PASS([[proxy objectAtIndex:1] isEqualToString:@"b"], + "This proxy works") + + temp = [NSDictionary dictionaryWithObject:list forKey:@"list"]; + proxy = [temp mutableArrayValueForKeyPath:@"list.numbers"]; + PASS([proxy isKindOfClass:NSClassFromString(@"NSKeyValueMutableArray")], + "mutableArrayValueForKey: works") + + + Sets * set = [[[Sets alloc] init] autorelease]; + NSMutableSet * setProxy; + + setProxy = [set mutableSetValueForKey:@"one"]; + PASS([setProxy isKindOfClass:[NSMutableSet class]], + "proxy is a kind of NSMutableSet") + + [setProxy removeObject:@"one"]; + [setProxy addObject:@"ten"]; + [setProxy removeObject:@"eight"]; + [setProxy addObject:@"three"]; + + o = [NSSet setWithObjects:@"one", @"two", @"three", nil]; + PASS([setProxy isEqualToSet: o], + "KVC mutableSetValueForKey: proxy uses methods") + + setProxy = [set mutableSetValueForKey:@"two"]; + PASS([setProxy isKindOfClass:[NSMutableSet class]], + "proxy is a kind of NSMutableSet") + [setProxy addObject:@"seven"]; + [setProxy minusSet:[NSSet setWithObject:@"eight"]]; + o = [NSSet setWithObjects:@"one", @"two", @"seven", nil]; + PASS([setProxy isEqualToSet: o], + "KVC mutableSetValueForKey: proxy works with set:") + + setProxy = [set mutableSetValueForKey:@"three"]; + PASS([setProxy isKindOfClass:[NSMutableSet class]], + "proxy is kind of NSMutableSet") + PASS(setProxy != [set valueForKey:@"three"], + "KVC mutableSetValueForKey: returns a proxy set for the ivar") + [setProxy addObject:@"seven"]; + [setProxy removeObject:@"eight"]; + o = [NSSet setWithObjects:@"one", @"two", @"seven", nil]; + PASS([setProxy isEqualToSet: o], "this proxy works") + + temp = [NSDictionary dictionaryWithObject:set forKey:@"set"]; + setProxy = [temp mutableSetValueForKeyPath:@"set.three"]; + PASS([setProxy isKindOfClass:NSClassFromString(@"NSKeyValueMutableSet")], + "mutableSetValueForKey: works") + + [list removeObserver: observer forKeyPath: @"numbers"]; + [list removeObserver: observer forKeyPath: @"string"]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/KVC/nil.m b/Tests/base/KVC/nil.m new file mode 100644 index 000000000..457b555e7 --- /dev/null +++ b/Tests/base/KVC/nil.m @@ -0,0 +1,67 @@ +#import "ObjectTesting.h" +#import +#import + +@interface DefaultNil : NSObject +{ + int num; +} +@end + +@implementation DefaultNil +- (id)init +{ + num = 7; + return self; +} +@end + +@interface DeprecatedNil : DefaultNil +- (void)unableToSetNilForKey:(NSString *)key; +@end + +@implementation DeprecatedNil +- (void)unableToSetNilForKey:(NSString *)key +{ + num = 0; +} +@end + +@interface SetNil : DefaultNil +- (void)setNilValueForKey:(NSString *)key; +@end + +@implementation SetNil +- (void)setNilValueForKey:(NSString *)key +{ + num = 0; +} +@end + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + DefaultNil * defaultNil = [DefaultNil new]; + DeprecatedNil * deprecatedNil = [DeprecatedNil new]; + SetNil * setNil = [SetNil new]; + + PASS_EXCEPTION([defaultNil setValue: nil forKey: @"num"], + NSInvalidArgumentException, "KVC handles setting nil for a scalar") + + PASS_EXCEPTION([defaultNil takeValue: nil forKey: @"num"], + NSInvalidArgumentException, + "KVC handles setting nil for a scalar via takeValue:") + + [setNil setValue:nil forKey: @"num"]; + PASS([[setNil valueForKey: @"num"] intValue] == 0, + "KVC uses setNilValueForKey:") + + [deprecatedNil setValue:nil forKey: @"num"]; + PASS([[deprecatedNil valueForKey: @"num"] intValue] == 0, + "KVC uses deprecated unableToSetNilForKey:") + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/KVC/path.m b/Tests/base/KVC/path.m new file mode 100644 index 000000000..46f1d48ea --- /dev/null +++ b/Tests/base/KVC/path.m @@ -0,0 +1,139 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import +#import + +@interface Tester : NSObject +{ + int num1; + double num2; + id child; + NSMutableDictionary * dict; +} + +@end + +@implementation Tester +@end + +@interface CustomKVC : NSObject +{ + int num1; + NSString * string; +} +@end + +@implementation CustomKVC +- (void)dealloc +{ + [string release]; + [super dealloc]; +} + +- (void)setValue:(id)value forKey:(NSString *)key +{ + if ([key isEqualToString:@"num1"]) { + num1 = [value intValue]; + } else if ([key isEqualToString:@"Lücke"]) { + [string release]; + string = [value copy]; + } +} + +- (id)valueForKey:(NSString *)key +{ + if ([key isEqualToString:@"num1"]) { + return [NSNumber numberWithInt:num1]; + } else if ([key isEqualToString:@"Lücke"]) { + return string; + } +} + +@end + +@interface DeprecatedCustomKVC : NSObject +{ + NSMutableDictionary * storage; +} + +- (id)init; +- (id)valueForKey:(NSString *)key; +- (void)takeValue:(id)value forKey:(NSString *)key; +@end + +@implementation DeprecatedCustomKVC +- (id)init +{ + self = [super init]; + storage = [[NSMutableDictionary alloc] init]; + + return self; +} + +- (id)valueForKey:(NSString *)key +{ + if ([key isEqualToString:@"dict"]) { + return storage; + } + return nil; +} + +- (void)takeValue:(id)value forKey:(NSString *)key +{ + if ([key isEqualToString:@"dict"]) { + [storage release]; + storage = [value retain]; + } +} + +@end + +int main(void) { + NSAutoreleasePool * arp = [NSAutoreleasePool new]; + + NSString * string = @"GNUstep"; + + Tester * tester = [[[Tester alloc] init] autorelease]; + [tester setValue:[NSMutableDictionary dictionary] forKey:@"dict"]; + [tester setValue:[[[Tester alloc] init] autorelease] forKey:@"child"]; + [tester setValue:[[CustomKVC new] autorelease] + forKeyPath:@"child.child"]; + DeprecatedCustomKVC * deprecated = [[[DeprecatedCustomKVC alloc] init] + autorelease]; + NSNumber * n = [NSNumber numberWithInt:8]; + NSNumber * adjustedN = [NSNumber numberWithInt:7]; + NSNumber * n2 = [NSNumber numberWithDouble:87.999]; + + [tester setValue:n2 forKeyPath:@"child.num2"]; + PASS([[tester valueForKeyPath:@"child.num2"] isEqualToNumber:n2], + "KVC works with simple paths"); + + [deprecated takeValue:[NSDictionary dictionaryWithObject:@"test" + forKey:@"key"] + forKey:@"dict"]; + + PASS_RUNS( + [tester setValue:n forKeyPath:@"child.child.num1"], + "KVC appears to work with key path"); + PASS([[tester valueForKeyPath:@"child.child.num1"] isEqualToNumber:n], + "KVC works with key paths"); + + NSLog(@"tester.child.child = %@", [tester valueForKeyPath: + @"child.child"]); + PASS_RUNS( + [tester setValue:string forKeyPath:@"child.child.Lücke"], + "KVC appears to work with a unicode key path"); + PASS([[tester valueForKeyPath:@"child.child.Lücke"] isEqualToString:string], + "KVC works with unicode path"); + + PASS_RUNS( + [tester setValue:string forKeyPath:@"dict.Lücke"], + "KVC appears to work with a unicode key path (test2)"); + PASS([[tester valueForKeyPath:@"dict.Lücke"] isEqualToString:string], + "KVC works with unicode path (test2)"); + + [arp release]; + return 0; +} diff --git a/Tests/base/NSAffineTransform/TestInfo b/Tests/base/NSAffineTransform/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSAffineTransform/basic.m b/Tests/base/NSAffineTransform/basic.m new file mode 100644 index 000000000..5a18de245 --- /dev/null +++ b/Tests/base/NSAffineTransform/basic.m @@ -0,0 +1,152 @@ +#import "ObjectTesting.h" +#import +#import + +#include +static BOOL eq(double d1, double d2) +{ + if (abs(d1 - d2) < 0.000001) + return YES; + return NO; +} + +static BOOL +is_equal_struct(NSAffineTransformStruct as, NSAffineTransformStruct bs) +{ + if (eq(as.m11, bs.m11) && eq(as.m12, bs.m12) && eq(as.m21, bs.m21) + && eq(as.m22, bs.m22) && eq(as.tX, bs.tX) && eq(as.tY, bs.tY)) + return YES; + return NO; +} + +#if 0 +static void +print_matrix (const char *str, NSAffineTransformStruct MM) +{ + printf("%s = %f %f %f %f %f %f\n", str, MM.m11, MM.m12, + MM.m21, MM.m22, MM.tX, MM.tY); +} +#endif + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSAffineTransform *testObj; + NSAffineTransformStruct flip = {1.0,0.0,0.0,-1.0,0.0,0.0}; + NSMutableArray *testObjs = [NSMutableArray new]; + NSAffineTransform *aa, *bb, *cc; + NSAffineTransformStruct as = {2, 3, 4, 5, 10, 20}; + NSAffineTransformStruct bs = {6, 7, 8, 9, 14, 15}; + NSAffineTransformStruct cs; + NSAffineTransformStruct answer1 = + {36.000000, 41.000000, 64.000000, 73.000000, 234.000000, 265.000000}; + NSAffineTransformStruct answer2 = + {40.000000, 53.000000, 52.000000, 69.000000, 98.000000, 137.000000}; + NSAffineTransformStruct answer3 = + {6.000000, 9.000000, 8.000000, 10.000000, 10.000000, 20.000000}; + NSAffineTransformStruct answer4 = + {6.000000, 9.000000, 8.000000, 10.000000, 194.000000, 268.000000}; + NSAffineTransformStruct answer5 = + {2.172574, 3.215242, 3.908954, 4.864383, 10.000000, 20.000000}; + NSAffineTransformStruct answer6 = + {2.172574, 3.215242, 3.908954, 4.864383, 90.796249, 126.684265}; + NSAffineTransformStruct answer7 = + {1.651156, 2.443584, 1.329044, 1.653890, 90.796249, 126.684265}; + NSPoint p; + NSSize s; + + testObj = [NSAffineTransform new]; + [testObjs addObject:testObj]; + PASS(testObj != nil, "can create a new transfor"); + + test_NSObject(@"NSAffineTransform", testObjs); + test_NSCoding(testObjs); + test_NSCopying(@"NSAffineTransform", @"NSAffineTransform", testObjs, NO, YES); + + testObj = [NSAffineTransform transform]; + PASS(testObj != nil, "can create an autoreleased transform"); + + [testObj setTransformStruct: flip]; + p = [testObj transformPoint: NSMakePoint(10,10)]; + PASS(eq(p.x, 10) && eq(p.y, -10), "flip transform inverts point y"); + + s = [testObj transformSize: NSMakeSize(10,10)]; + PASS(s.width == 10 && s.height == -10, "flip transform inverts size height"); + + p = [testObj transformPoint: p]; + s = [testObj transformSize: s]; + PASS(eq(p.x, 10) && eq(p.y, 10) && s.width == 10 && s.height == 10, + "flip is reversible"); + + testObj = [NSAffineTransform transform]; + [testObj translateXBy: 5.0 yBy: 6.0]; + p = [testObj transformPoint: NSMakePoint(10,10)]; + PASS(eq(p.x, 15.0) && eq(p.y, 16.0), "simple translate works"); + + [testObj translateXBy: 5.0 yBy: 4.0]; + p = [testObj transformPoint: NSMakePoint(10,10)]; + PASS(eq(p.x, 20.0) && eq(p.y, 20.0), "two simple translates work"); + + [testObj rotateByDegrees: 90.0]; + p = [testObj transformPoint: NSMakePoint(10,10)]; + PASS(eq(p.x, 0.0) && eq(p.y, 20.0), "translate and rotate works"); + + testObj = [NSAffineTransform transform]; + + [testObj rotateByDegrees: 90.0]; + p = [testObj transformPoint: NSMakePoint(10,10)]; + PASS(eq(p.x, -10.0) && eq(p.y, 10.0), "simple rotate works"); + + [testObj translateXBy: 5.0 yBy: 6.0]; + p = [testObj transformPoint: NSMakePoint(10,10)]; + PASS(eq(p.x, -16.0) && eq(p.y, 15.0), "rotate and translate works"); + + + aa = [NSAffineTransform transform]; + bb = [NSAffineTransform transform]; + [aa setTransformStruct: as]; + [bb setTransformStruct: bs]; + + /* Append matrix */ + cc = [aa copy]; + [cc appendTransform: bb]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer1)), "appendTransform:") + + /* Prepend matrix */ + cc = [aa copy]; + [cc prependTransform: bb]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer2)), "prependTransform:") + + /* scaling */ + cc = [aa copy]; + [cc scaleXBy: 3 yBy: 2]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer3)), "scaleXBy:yBy:") + //print_matrix ("Scale X A", cs); + [cc translateXBy: 12 yBy: 14]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer4)), "translateXBy:yBy:") + //print_matrix ("Trans X Scale X A", cs); + + /* rotation */ + cc = [aa copy]; + [cc rotateByDegrees: 2.5]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer5)), "rotateByDegrees") + //print_matrix ("Rotate X A", cs); + [cc translateXBy: 12 yBy: 14]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer6)), "Translate X Rotate X A") + //print_matrix ("Trans X Rotate X A", cs); + + /* multiple */ + [cc scaleXBy: .76 yBy: .34]; + cs = [cc transformStruct]; + PASS((is_equal_struct(cs, answer7)), "Scale X Translate X Rotate X A") + //print_matrix ("Scale X Trans X Rotate X A", cs); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSArchiver/TestInfo b/Tests/base/NSArchiver/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSArchiver/basic.m b/Tests/base/NSArchiver/basic.m new file mode 100644 index 000000000..743dd6a1f --- /dev/null +++ b/Tests/base/NSArchiver/basic.m @@ -0,0 +1,13 @@ +#import +#import "ObjectTesting.h" +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_alloc(@"NSArchiver"); + test_NSObject(@"NSArchiver",[NSArray arrayWithObject:[[NSArchiver alloc] init]]); + test_alloc(@"NSUnarchiver"); + test_NSObject(@"NSUnarchiver",[NSArray arrayWithObject:[[NSUnarchiver alloc] init]]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSArchiver/create.m b/Tests/base/NSArchiver/create.m new file mode 100644 index 000000000..d2b535da5 --- /dev/null +++ b/Tests/base/NSArchiver/create.m @@ -0,0 +1,30 @@ +#import +#import +#import +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id obj = [NSArchiver new]; + NSMutableData *data1; + + PASS((obj != nil && [obj isKindOfClass:[NSArchiver class]] && + [obj archiverData] != nil), "+new creates an empty NSArchiver"); + [obj release]; + obj = [NSArchiver alloc]; + data1 = [NSMutableData dataWithLength: 0]; + obj = [obj initForWritingWithMutableData: data1]; + PASS((obj != nil && [obj isKindOfClass:[NSArchiver class]] && data1 == [obj archiverData]), "-initForWritingWithMutableData seems ok"); + + PASS_EXCEPTION([[NSUnarchiver alloc] initForReadingWithData:nil];, + @"NSInvalidArgumentException", + "Creating an NSUnarchiver with nil data throws an exception"); + + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSArchiver/general.m b/Tests/base/NSArchiver/general.m new file mode 100644 index 000000000..8315e5482 --- /dev/null +++ b/Tests/base/NSArchiver/general.m @@ -0,0 +1,44 @@ +#import +#import +#import +#import +#import +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val1, *val2, *val3; + NSArray *vals1, *vals2; + NSData *data1; + NSArray *a; + + PASS_RUNS(val1 = [NSString stringWithCString:"Archiver.dat"]; + val2 = [NSString stringWithCString:"A Goodbye"]; + val3 = [NSString stringWithCString:"Testing all strings"]; + vals1 = [[NSArray arrayWithObject:val1] arrayByAddingObject:val2]; + vals2 = [vals1 arrayByAddingObject:val2];, + "We can build basic strings and arrays for tests"); + + data1 = [NSArchiver archivedDataWithRootObject:vals2]; + PASS((data1 != nil && [data1 length] != 0), + "archivedDataWithRootObject: seems ok"); + + PASS([NSArchiver archiveRootObject:vals2 toFile:val1], + "archiveRootObject:toFile: seems ok"); + + a = [NSUnarchiver unarchiveObjectWithData:data1]; + PASS((a != nil && [a isKindOfClass:[NSArray class]] && [a isEqual:vals2]), + "unarchiveObjectWithData: seems ok"); + + a = [NSUnarchiver unarchiveObjectWithFile:val1]; + PASS((a != nil && [a isKindOfClass:[NSArray class]] && [a isEqual:vals2]), + "unarchiveObjectWithFile: seems ok"); + + [[NSFileManager defaultManager] removeFileAtPath: val1 handler: nil]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSArray/TestInfo b/Tests/base/NSArray/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSArray/basic.m b/Tests/base/NSArray/basic.m new file mode 100644 index 000000000..9ec83722b --- /dev/null +++ b/Tests/base/NSArray/basic.m @@ -0,0 +1,39 @@ +#import +#import +#import "ObjectTesting.h" + +int main() +{ + NSArray *obj; + NSMutableArray *testObjs = [[NSMutableArray alloc] init]; + NSString *str; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_alloc(@"NSArray"); + obj = [NSArray new]; + PASS((obj != nil && [obj count] == 0),"can create an empty array"); + str = @"hello"; + [testObjs addObject: obj]; + obj = [NSArray arrayWithObject:str]; + PASS((obj != nil && [obj count] == 1), "can create an array with one element"); + [testObjs addObject: obj]; + test_NSObject(@"NSArray", testObjs); + test_NSCoding(testObjs); + test_NSCopying(@"NSArray",@"NSMutableArray",testObjs,YES,NO); + test_NSMutableCopying(@"NSArray",@"NSMutableArray",testObjs); + + obj = [NSArray arrayWithContentsOfFile: @"test.plist"]; + PASS((obj != nil && [obj count] > 0),"can create an array from file"); +#if 1 + /* The apple foundation is arguably buggy in that it seems to create a + * mutable array ... we currently copy that + */ + PASS([obj isKindOfClass: [NSMutableArray class]] == YES,"array mutable"); + PASS_RUNS([obj addObject: @"x"],"can add to array"); +#else + PASS([obj isKindOfClass: [NSMutableArray class]] == NO,"array immutable"); +#endif + obj = [obj objectAtIndex: 0]; + PASS([obj isKindOfClass: [NSMutableArray class]] == YES,"array mutable"); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSArray/create.m b/Tests/base/NSArray/create.m new file mode 100644 index 000000000..b0e7d6c11 --- /dev/null +++ b/Tests/base/NSArray/create.m @@ -0,0 +1,45 @@ +#import +#import +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id val1,val2,val3; + id ptrvals[3]; + NSArray *obj, *old; + val1 = @"Tom"; + val2 = @"Petty"; + val3 = @"doesn't want to live like a refugee"; + + ptrvals[0] = val1; + ptrvals[1] = val2; + ptrvals[2] = val3; + + obj = [NSArray new]; + PASS((obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 0), + "+new creates an empty array"); + [obj release]; + obj = [NSArray array]; + PASS((obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 0), + "+array creates an empty array"); + PASS_EXCEPTION([NSArray arrayWithObject:nil];, @"NSInvalidArgumentException", + "+arrayWithObject with nil argument throws exception"); + + obj = [NSArray arrayWithObject:val1]; + PASS(obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 1, + "+arrayWithObject: builds a minimal array"); + + obj = [NSArray arrayWithObjects:ptrvals count:3]; + old = obj; + PASS(obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 3, + "+arrayWithObjects: builds an array"); + + obj = [NSArray arrayWithArray:old]; + PASS(obj != nil && [old isEqual:obj], "+arrayWithArray: copies array"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSArray/general.m b/Tests/base/NSArray/general.m new file mode 100644 index 000000000..e4cbfca6a --- /dev/null +++ b/Tests/base/NSArray/general.m @@ -0,0 +1,91 @@ +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id val1,val2,val3,obj; + NSArray *arr,*vals1,*vals2,*vals3; + + val1 = @"Hello"; + val2 = @"A Goodbye"; + val3 = @"Testing all strings"; + vals1 = [[[NSArray arrayWithObject:val1] arrayByAddingObject:val2] retain]; + vals2 = [[vals1 arrayByAddingObject:val2] retain]; + vals3 = [[vals1 arrayByAddingObject:val3] retain]; + + obj = [NSArray new]; + arr = obj; + PASS(obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 0, + "-count returns zero for an empty array"); + PASS([arr hash] == 0, "-hash returns zero for an empty array"); + PASS(vals3 != nil && [vals3 containsObject:val2], "-containsObject works"); + PASS(vals3 != nil && [vals3 indexOfObject:@"A Goodbye"] == 1, + "-indexOfObject: finds object"); + PASS(vals3 != nil && [vals3 indexOfObjectIdenticalTo:val2], + "-indexOfObjectIdenticalTo: finds identical object"); + { + NSEnumerator *e; + id v1, v2, v3; + e = [arr objectEnumerator]; + v1 = [e nextObject]; + v2 = [e nextObject]; + PASS(e != nil && v1 == nil && v2 == nil, + "-objectEnumerator: is ok for empty array"); + e = [vals1 objectEnumerator]; + v1 = [e nextObject]; + v2 = [e nextObject]; + v3 = [e nextObject]; + PASS(v1 != nil && v2 != nil && v3 == nil && [vals1 containsObject:v1] && + [vals1 containsObject:v2] && [v1 isEqual:val1] && [v2 isEqual: val2], + "-objectEnumerator: enumerates the array"); + } + { + obj = [arr description]; + obj = [obj propertyList]; + PASS(obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 0, + "-description gives us a text property-list (empty array)"); + obj = [arr description]; + obj = [obj propertyList]; + PASS(obj != nil && [obj isKindOfClass:[NSArray class]] && [obj isEqual:arr], + "-description gives us a text property-list"); + } + PASS(vals1 != nil && [vals1 isKindOfClass: [NSArray class]] && + [vals1 count] == 2, "-count returns two for an array with two objects"); + PASS([vals1 hash] == 2, "-hash returns two for an array with two objects"); + PASS([vals1 indexOfObject:nil] == NSNotFound, + "-indexOfObject: gives NSNotFound for a nil object"); + PASS([vals1 indexOfObject:val3] == NSNotFound, + "-indexOfObject: gives NSNotFound for a object not in the array"); + PASS([vals1 isEqualToArray:vals1], + "Array is equal to itself using -isEqualToArray:"); + PASS(![vals1 isEqualToArray:vals2],"Similar arrays are not equal using -isEqualToArray:"); + + { + NSArray *a; + NSRange r = NSMakeRange(0,2); + a = [vals2 subarrayWithRange:r]; + PASS(a != nil && [a isKindOfClass:[NSArray class]] && [a count] == 2 && + [a objectAtIndex:0] == val1 && [a objectAtIndex:1] == val2, + "-subarrayWithRange: seems ok"); + r = NSMakeRange(1,2); + PASS_EXCEPTION([arr subarrayWithRange:r];,@"NSRangeException","-subarrayWithRange with invalid range"); + } + + { + NSString *c = @"/"; + NSString *s = @"Hello/A Goodbye"; + NSString *a = [vals1 componentsJoinedByString: c]; + PASS(a != nil && [a isKindOfClass:[NSString class]] && [a isEqual:s], + "-componentsJoinedByString: seems ok"); + } + { + NSArray *a = [vals1 sortedArrayUsingSelector:@selector(compare:)]; + PASS(a != nil && [a isKindOfClass:[NSArray class]] && [a count] == 2 && + [a objectAtIndex:0] == val2 && [a objectAtIndex:1] == val1, + "-sortedArrayUsingSelector: seems ok"); + + } + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSArray/test.plist b/Tests/base/NSArray/test.plist new file mode 100644 index 000000000..8bf8b3d23 --- /dev/null +++ b/Tests/base/NSArray/test.plist @@ -0,0 +1,3 @@ +( + (1, 2, 3) +) diff --git a/Tests/base/NSAttributedString/TestInfo b/Tests/base/NSAttributedString/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSAttributedString/basic.m b/Tests/base/NSAttributedString/basic.m new file mode 100644 index 000000000..b24280e31 --- /dev/null +++ b/Tests/base/NSAttributedString/basic.m @@ -0,0 +1,18 @@ +#import +#import +#import "ObjectTesting.h" +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *arr = [NSArray arrayWithObject:[NSAttributedString new]]; + + test_alloc(@"NSAttributedString"); + test_NSObject(@"NSAttributedString", arr); + test_NSCoding(arr); + test_NSCopying(@"NSAttributedString",@"NSMutableAttributedString",arr,NO, NO); + test_NSMutableCopying(@"NSAttributedString",@"NSMutableAttributedString",arr); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSAttributedString/test00.m b/Tests/base/NSAttributedString/test00.m new file mode 100644 index 000000000..dc79526ea --- /dev/null +++ b/Tests/base/NSAttributedString/test00.m @@ -0,0 +1,45 @@ +#import +#import +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *key1, *val1, *str1; + NSRange r = NSMakeRange(0,6); + NSAttributedString *astr1, *astr2; + NSDictionary *dict1; + NSRange range = NSMakeRange(0,0); + id obj; + + key1 = @"Helvetica 12-point"; + val1 = @"NSFontAttributeName"; + str1 = @"Attributed string test"; + dict1 = [NSDictionary dictionaryWithObject:val1 forKey:key1]; + + astr1 = [[NSAttributedString alloc] initWithString:str1 attributes:dict1]; + PASS(astr1 != nil && [astr1 isKindOfClass:[NSAttributedString class]] && + [[astr1 string] isEqual: str1],"-initWithString:attributes: works"); + + obj = [astr1 attributesAtIndex:0 effectiveRange:&range]; + PASS(obj != nil && [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 1 && range.length != 0, + "-attributesAtIndex:effectiveRange: works"); + + obj = [astr1 attribute:key1 atIndex:0 effectiveRange:&range]; + PASS(obj != nil && [obj isEqual:val1] && range.length != 0, + "-attribute:atIndex:effectiveRange: works"); + obj = [astr1 attributedSubstringFromRange:r]; + PASS(obj != nil && [obj isKindOfClass:[NSAttributedString class]] && + [obj length] == r.length,"-attributedSubstringFromRange works"); + + r = NSMakeRange(0,[astr1 length]); + astr2 = [astr1 attributedSubstringFromRange:r]; + PASS(astr2 != nil && [astr1 isEqualToAttributedString:astr2], + "extract and compare using -isEqualToAttributedString works"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSBlock/blockassign.m b/Tests/base/NSBlock/blockassign.m new file mode 100644 index 000000000..13fd1d485 --- /dev/null +++ b/Tests/base/NSBlock/blockassign.m @@ -0,0 +1,27 @@ +#import "Testing.h" +#import + +int main (int argc, char **argv) +{ + START_SET("NSBlock") +#if __has_feature(blocks) + BOOL (^hello)(void) = ^() { return YES; }; + PASS(hello(), "Calling a block"); + BOOL (^helloCopy)(void) = Block_copy(hello); + Block_release(hello); + PASS(helloCopy(), "Calling a copy of a block"); + NSArray *blockArr = [NSArray arrayWithObject:helloCopy]; + PASS([blockArr count] == 1, "Block used as object in an array"); + void (^helloArr)(void) = [blockArr objectAtIndex:0]; + PASS(helloCopy(), "Block successfully retrived from array"); + Block_release(helloCopy); +#elif defined(__clang__) + SKIP("Your compiler supports blocks, but this support was disabled for some reason.") +#else + SKIP("Your compiler does not support blocks.") +#endif + END_SET("NSBlock") + + return 0; +} + diff --git a/Tests/base/NSBundle/GNUmakefile.preamble b/Tests/base/NSBundle/GNUmakefile.preamble new file mode 100644 index 000000000..622b4bf9f --- /dev/null +++ b/Tests/base/NSBundle/GNUmakefile.preamble @@ -0,0 +1,9 @@ + +ADDITIONAL_OBJCFLAGS += -I../GenericTests/ -I../../.. -Wall + +$(GNUSTEP_INSTANCE)_SUBPROJECTS = ../GenericTests + +SUBPROJECTS = ../GenericTests Resources + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSBundle/Resources/English.lproj/TextRes.txt b/Tests/base/NSBundle/Resources/English.lproj/TextRes.txt new file mode 100644 index 000000000..7560cc951 --- /dev/null +++ b/Tests/base/NSBundle/Resources/English.lproj/TextRes.txt @@ -0,0 +1 @@ +English resource diff --git a/Tests/base/NSBundle/Resources/French.lproj/TextRes.txt b/Tests/base/NSBundle/Resources/French.lproj/TextRes.txt new file mode 100644 index 000000000..d65ff95ac --- /dev/null +++ b/Tests/base/NSBundle/Resources/French.lproj/TextRes.txt @@ -0,0 +1 @@ +French resource diff --git a/Tests/base/NSBundle/Resources/GNUmakefile b/Tests/base/NSBundle/Resources/GNUmakefile new file mode 100644 index 000000000..c800e09d6 --- /dev/null +++ b/Tests/base/NSBundle/Resources/GNUmakefile @@ -0,0 +1,14 @@ + +include $(GNUSTEP_MAKEFILES)/common.make + +BUNDLE_NAME = TestBundle + +TestBundle_OBJC_FILES = TestBundle.m +TestBundle_RESOURCE_FILES = NonLocalRes.txt +TestBundle_LANGUAGES = English French +TestBundle_LOCALIZED_RESOURCE_FILES = TextRes.txt +TestBundle_NEEDS_GUI = NO + +include $(GNUSTEP_MAKEFILES)/bundle.make + +check:: all diff --git a/Tests/base/NSBundle/Resources/NonLocalRes.txt b/Tests/base/NSBundle/Resources/NonLocalRes.txt new file mode 100644 index 000000000..036b851fe --- /dev/null +++ b/Tests/base/NSBundle/Resources/NonLocalRes.txt @@ -0,0 +1 @@ +Non-localized Text resource diff --git a/Tests/base/NSBundle/Resources/TestBundle.m b/Tests/base/NSBundle/Resources/TestBundle.m new file mode 100644 index 000000000..b7002a22b --- /dev/null +++ b/Tests/base/NSBundle/Resources/TestBundle.m @@ -0,0 +1,16 @@ +#import +#import + +@interface TestBundle : NSObject +{ + +} +-(NSString *)test; +@end + +@implementation TestBundle +-(NSString *)test +{ + return @"Something"; +} +@end diff --git a/Tests/base/NSBundle/Resources/TestBundleInfo.plist b/Tests/base/NSBundle/Resources/TestBundleInfo.plist new file mode 100644 index 000000000..0b380140d --- /dev/null +++ b/Tests/base/NSBundle/Resources/TestBundleInfo.plist @@ -0,0 +1,3 @@ +{ + CFBundleIdentifier = "Test Bundle Identifier 1"; +} diff --git a/Tests/base/NSBundle/TestInfo b/Tests/base/NSBundle/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSBundle/basic.m b/Tests/base/NSBundle/basic.m new file mode 100644 index 000000000..a15dd605c --- /dev/null +++ b/Tests/base/NSBundle/basic.m @@ -0,0 +1,13 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + test_alloc(@"NSBundle"); + test_NSObject(@"NSBundle", [NSArray arrayWithObject:[NSBundle new]]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSBundle/create.m b/Tests/base/NSBundle/create.m new file mode 100644 index 000000000..7fb6a7f4f --- /dev/null +++ b/Tests/base/NSBundle/create.m @@ -0,0 +1,43 @@ +#import +#import +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *path; + NSBundle *bundle; + + path = [[[NSFileManager defaultManager] currentDirectoryPath] + stringByAppendingPathComponent:@"Resources"]; + + PASS([NSBundle mainBundle] != nil, + "+mainBundle returns non-nil if the tool has no bundle"); + + bundle = [NSBundle bundleWithPath:path]; + [bundle retain]; + + TEST_FOR_CLASS(@"NSBundle", bundle, "+bundleWithPath returns a bundle"); + + TEST_STRING([bundle bundlePath],"a bundle has a path"); + + PASS([path isEqual:[bundle bundlePath]] && + [[bundle bundlePath] isEqual:path], + "bundlePath returns the correct path"); + + TEST_FOR_CLASS(@"NSDictionary",[bundle infoDictionary], + "a bundle has an infoDictionary"); + + PASS([NSBundle bundleWithPath: + [path stringByAppendingPathComponent:@"nonexistent"]] == nil, + "+bundleWithPath returns nil for a non-existing path"); + + { + NSArray *arr = [NSBundle allBundles]; + PASS(arr != nil && [arr isKindOfClass:[NSArray class]] && [arr count] != 0, + "+allBundles returns an array"); + } + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSBundle/general.m b/Tests/base/NSBundle/general.m new file mode 100644 index 000000000..a54f4b7ca --- /dev/null +++ b/Tests/base/NSBundle/general.m @@ -0,0 +1,91 @@ +#import "ObjectTesting.h" +#import + +@interface TestClass : NSObject +@end + +@implementation TestClass +@end + +int main() +{ + START_SET("NSBundle general") + NSFileManager *fm; + NSBundle *classBundle, *identifierBundle, *bundle; + NSString *path, *exepath; + + fm = [NSFileManager defaultManager]; + +#if defined(GNUSTEP) + START_SET("NSBundle GNUstep general") + NSBundle *gnustepBundle; + + gnustepBundle = [NSBundle bundleForLibrary: @"gnustep-base"]; + if (nil == gnustepBundle) + SKIP("it looks like GNUstep-base is not yet installed") + + PASS(( + [(gnustepBundle = [NSBundle bundleForLibrary: @"gnustep-base"]) + isKindOfClass: [NSBundle class]]), + "+bundleForLibrary: makes a bundle for us") + + PASS([gnustepBundle principalClass] == [NSObject class], + "-principalClass returns NSObject for the +bundleForLibrary:gnustep-base"); + + PASS([[gnustepBundle classNamed: @"NSArray"] isEqual: [NSArray class]] + && [[NSArray class] isEqual: [gnustepBundle classNamed: @"NSArray"]], + "-classNamed returns the correct class"); + + TEST_STRING([gnustepBundle resourcePath],"-resourcePath returns a string"); + + [gnustepBundle setBundleVersion:42]; + PASS([gnustepBundle bundleVersion] == 42, + "we can set and get gnustep bundle version"); + + PASS([gnustepBundle load], "-load behaves properly on the gnustep bundle"); + + exepath = [gnustepBundle executablePath]; + PASS([fm fileExistsAtPath: exepath], + "-executablePath returns an executable path (gnustep bundle)"); + + END_SET("NSBundle GNUstep general") +#endif + + classBundle = [NSBundle bundleForClass: [TestClass class]]; + + TEST_FOR_CLASS(@"NSBundle",classBundle, + "+bundleForClass: makes a bundle for us"); + + NSLog(@"%@", [classBundle principalClass]); + PASS([classBundle principalClass] == [TestClass class], + "-principalClass returns TestClass for +bundleForClass:[TestClass class]"); + + PASS(classBundle == [NSBundle mainBundle], + "-mainBundle is the same as +bundleForClass:[TestClass class]"); + + path = [[[fm currentDirectoryPath] + stringByAppendingPathComponent:@"Resources"] + stringByAppendingPathComponent: @"TestBundle.bundle"]; + + bundle = [NSBundle bundleWithPath: path]; + PASS([bundle isKindOfClass:[NSBundle class]], + "+bundleWithPath returns an NSBundle"); + + exepath = [bundle executablePath]; + PASS([fm fileExistsAtPath: exepath], + "-executablePath returns an executable path (real bundle)"); + + identifierBundle + = [NSBundle bundleWithIdentifier: @"Test Bundle Identifier 1"]; + PASS(identifierBundle == bundle, + "+bundleWithIdentifier returns correct bundle"); + + identifierBundle + = [NSBundle bundleWithIdentifier: @"Test Bundle Identifier 2"]; + PASS(identifierBundle == nil, + "+bundleWithIdentifier returns nil for non-existent identifier"); + + END_SET("NSBundle general") + + return 0; +} diff --git a/Tests/base/NSBundle/load/GNUmakefile.preamble b/Tests/base/NSBundle/load/GNUmakefile.preamble new file mode 100644 index 000000000..f2796a3b7 --- /dev/null +++ b/Tests/base/NSBundle/load/GNUmakefile.preamble @@ -0,0 +1,9 @@ + +ADDITIONAL_OBJCFLAGS += -I../../GenericTests/ -I../../../.. -Wall + +$(GNUSTEP_INSTANCE)_SUBPROJECTS = ../../GenericTests + +SUBPROJECTS=../../GenericTests ../Resources + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSBundle/load/load.m b/Tests/base/NSBundle/load/load.m new file mode 100644 index 000000000..d59732ce6 --- /dev/null +++ b/Tests/base/NSBundle/load/load.m @@ -0,0 +1,56 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *path; + NSBundle *bundle; + Class aClass; + id anObj; + + path = RETAIN([[[[[NSFileManager defaultManager] currentDirectoryPath] + stringByDeletingLastPathComponent] + stringByAppendingPathComponent:@"Resources"] + stringByAppendingPathComponent: @"TestBundle.bundle"]); + + bundle = RETAIN([NSBundle bundleWithPath: path]); + + pass([bundle isKindOfClass:[NSBundle class]], + "+bundleWithPath returns a bundle"); + + pass([[bundle bundlePath] testForString],"the bundle has a path"); + + pass([path testEquals: [bundle bundlePath]], + "bundlePath returns the correct path"); + + pass([[bundle resourcePath] testForString],"a bundle has a resource path"); + pass([[bundle infoDictionary] isKindOfClass:[NSDictionary class]], + "a bundle has an infoDictionary"); + + pass([bundle load],"bundle -load returns YES"); + aClass = NSClassFromString(@"TestBundle"); + pass(aClass != Nil,"-load actually loaded the class"); + anObj = [aClass new]; + pass(anObj != nil, "we can instantiate a loaded class"); + pass([bundle principalClass] != nil, "-principalClass is not nil"); + pass([[[bundle principalClass] description] testEquals:@"TestBundle"], + "-principalClass works"); + pass([[bundle principalClass] new] != nil, "we can instantiate -principalClass"); + pass([[bundle classNamed:@"TestBundle"] testEquals:[bundle principalClass]], + "-classNamed works"); + pass([bundle testEquals: [NSBundle bundleForClass: NSClassFromString(@"TestBundle")]], + "+bundleForClass works"); + [bundle setBundleVersion:42]; + pass([bundle bundleVersion] == 42, "we can set and get a bundle version"); + pass([[NSBundle allBundles] containsObject:bundle], + "+allBundles contains a bundle after we loaded it"); + + RELEASE(bundle); + RELEASE(path); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSBundle/resources.m b/Tests/base/NSBundle/resources.m new file mode 100644 index 000000000..55844403d --- /dev/null +++ b/Tests/base/NSBundle/resources.m @@ -0,0 +1,95 @@ +#import "Testing.h" +#import +#import +#import +#import +#import + +int main() +{ + START_SET("NSBundle resources") + NSBundle *bundle; + NSArray *arr; + + bundle = [NSBundle bundleWithPath: [[NSFileManager defaultManager] + currentDirectoryPath]]; + + PASS([bundle isKindOfClass: [NSBundle class]], + "+bundleWithPath returns anNSBundle"); + arr = [bundle pathsForResourcesOfType: @"m" inDirectory: nil]; + PASS([arr isKindOfClass: [NSArray class]] && [arr count], + "-pathsForResourcesOfType: inDirectory: returns an array"); + PASS([bundle pathForResource: @"hiwelf0-2" + ofType: nil + inDirectory: nil] == nil, + "-pathForResource:ofType:inDirectory: works with nil args"); + PASS([bundle pathForResource: @"hiwelf0-2" ofType: nil] == nil, + "-pathForResource:ofType: works with nil type"); + PASS([bundle pathForResource: nil ofType: @"tiff"] == nil, + "-pathForResource:ofType: works with nil name"); + PASS([bundle pathForResource: @"hiwelf0-2" ofType: @""] == nil, + "-pathForResource:ofType: works with empty type"); + PASS([bundle pathForResource: @"" ofType: @"tiff"] == nil, + "-pathForResource:ofType: works with empty name"); + PASS([[bundle resourcePath] testEquals: [[bundle bundlePath] + stringByAppendingPathComponent: @"Resources"]], + "-resourcePath returns the correct path"); + +#if defined(GNUSTEP) + START_SET("NSBundle GNUstep general") + NSBundle *gnustepBundle; + + gnustepBundle = [NSBundle bundleForLibrary: @"gnustep-base"]; + if (nil == gnustepBundle) + SKIP("it looks like GNUstep-base is not yet installed") + + PASS([[NSBundle pathForResource: @"abbreviations" + ofType: @"plist" + inDirectory: [[gnustepBundle bundlePath] + stringByAppendingPathComponent: @"NSTimeZones"]] testForString], + "+pathForResource:ofType:inDirectory: works"); + + PASS([[NSBundle pathForResource: @"abbreviations" + ofType: @"plist" + inDirectory: [[gnustepBundle bundlePath] + stringByAppendingPathComponent: @"NSTimeZones"] withVersion: 0] + testForString], + "+pathForResource:ofType:inDirectory:withVersion: works"); + + arr = [gnustepBundle pathsForResourcesOfType: @"m" + inDirectory: @"NSTimeZones"]; + PASS(([arr isKindOfClass: [NSArray class]] && [arr count] > 0), + "-pathsForResourcesOfType:inDirectory: returns an array"); + PASS([[gnustepBundle pathForResource: @"abbreviations" + ofType: @"plist" + inDirectory: @"NSTimeZones"] testForString], + "-pathForResource:ofType:inDirectory: finds a file"); + PASS([gnustepBundle pathForResource: @"abbreviations" + ofType: @"8nicola8" + inDirectory: @"NSTimeZones"] == nil, + "-pathForResource:ofType:inDirectory: doesn't find non-existing file"); + PASS([gnustepBundle pathForResource: @"abbreviations" + ofType: @"plist" + inDirectory: @"NSTimeZones_dummy"] == nil, + "-pathForResource:ofType:inDirectory: doesn't find files in" + "a non-existing dir"); + PASS([[gnustepBundle pathForResource: @"abbreviations" + ofType: nil + inDirectory: @"NSTimeZones"] testForString], + "-pathForResource:ofType:inDirectory: with nil type finds a file"); + PASS([gnustepBundle pathForResource: @"whasssdlkf" + ofType: nil + inDirectory: @"NSTimeZones"] == nil, + "-pathForResource:ofType:inDirectory: with nil type doesn't find" + "non-existing files"); + + PASS([[gnustepBundle pathForResource: @"NSTimeZones" ofType: nil] + testForString], + "-pathForResource:ofType: finds a file"); + + END_SET("NSBundle GNUstep resources") +#endif + END_SET("NSBundle resources") + + return 0; +} diff --git a/Tests/base/NSBundle/resources2.m b/Tests/base/NSBundle/resources2.m new file mode 100644 index 000000000..16c2af28a --- /dev/null +++ b/Tests/base/NSBundle/resources2.m @@ -0,0 +1,43 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *path, *localPath; + NSBundle *bundle; + NSArray *arr, *carr; + + path = [[[[NSFileManager defaultManager] currentDirectoryPath] + stringByAppendingPathComponent:@"Resources"] + stringByAppendingPathComponent: @"TestBundle.bundle"]; + + /* --- [NSBundle -pathsForResourcesOfType:inDirectory:] --- */ + bundle = [NSBundle bundleWithPath: path]; + arr = [bundle pathsForResourcesOfType:@"txt" inDirectory: nil]; + PASS((arr && [arr count]), "-pathsForResourcesOfType:inDirectory: returns an array"); + localPath = [path stringByAppendingPathComponent: @"Resources/NonLocalRes.txt"]; + PASS([arr containsObject: localPath], "Returned array contains non-localized resource"); + localPath = [path stringByAppendingPathComponent: @"Resources/English.lproj/TextRes.txt"]; + PASS([arr containsObject: localPath], "Returned array contains localized resource"); + + /* --- [NSBundle +pathsForResourcesOfType:inDirectory:] --- */ + carr = [NSBundle pathsForResourcesOfType:@"txt" inDirectory: path]; + PASS([arr isEqual: carr], "+pathsForResourcesOfType:inDirectory: returns same array"); + + /* --- [NSBundle -pathsForResourcesOfType:inDirectory:forLocalization:] --- */ + arr = [bundle pathsForResourcesOfType:@"txt" inDirectory: nil forLocalization: @"English"]; + PASS((arr && [arr count]), "-pathsForResourcesOfType:inDirectory:forLocalization returns an array"); + localPath = [path stringByAppendingPathComponent: @"Resources/NonLocalRes.txt"]; + PASS([arr containsObject: localPath], "Returned array contains non-localized resource"); + localPath = [path stringByAppendingPathComponent: @"Resources/English.lproj/TextRes.txt"]; + PASS([arr containsObject: localPath], "Returned array contains localized resource"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCalendar/TestInfo b/Tests/base/NSCalendar/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSCalendar/basic.m b/Tests/base/NSCalendar/basic.m new file mode 100644 index 000000000..2b3525d7d --- /dev/null +++ b/Tests/base/NSCalendar/basic.m @@ -0,0 +1,25 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import + +#if defined(GS_USE_ICU) +#define NSCALENDAR_SUPPORTED GS_USE_ICU +#else +#define NSCALENDAR_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main() +{ + START_SET("NSCalendar basic") + if (!NSCALENDAR_SUPPORTED) + SKIP("NSCalendar not supported\nThe ICU library was not available when GNUstep-base was built") + id testObj = [NSCalendar currentCalendar]; + + test_NSObject(@"NSCalendar", [NSArray arrayWithObject: testObj]); + test_NSCoding([NSArray arrayWithObject: testObj]); + test_NSCopying(@"NSCalendar", @"NSCalendar", + [NSArray arrayWithObject: testObj], NO, NO); + + END_SET("NSCalendar basic") + return 0; +} diff --git a/Tests/base/NSCalendar/create.m b/Tests/base/NSCalendar/create.m new file mode 100644 index 000000000..f18b32f19 --- /dev/null +++ b/Tests/base/NSCalendar/create.m @@ -0,0 +1,32 @@ +#import +#import +#import +#import "ObjectTesting.h" + +#if defined(GS_USE_ICU) +#define NSCALENDAR_SUPPORTED GS_USE_ICU +#else +#define NSCALENDAR_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main(void) +{ + START_SET("NSCalendar create") + NSCalendar *cal; + + if (!NSCALENDAR_SUPPORTED) + SKIP("NSCalendar not supported\nThe ICU library was not available when GNUstep-base was built") + + cal = [NSCalendar currentCalendar]; + PASS (cal != nil, "+currentCalendar returns non-nil"); + TEST_FOR_CLASS(@"NSCalendar", cal, "+currentCalendar return a NSCalendar"); + + cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]; + PASS (cal != nil, "-initWithCalendarIdentifier: return non-nil"); + TEST_FOR_CLASS(@"NSCalendar", cal, + "-initWithCalendarIdentifier: return a NSCalendar"); + RELEASE(cal); + + END_SET("NSCalendar create") + return 0; +} diff --git a/Tests/base/NSCalendarDate/TestInfo b/Tests/base/NSCalendarDate/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSCalendarDate/basic.m b/Tests/base/NSCalendarDate/basic.m new file mode 100644 index 000000000..1ebe64629 --- /dev/null +++ b/Tests/base/NSCalendarDate/basic.m @@ -0,0 +1,18 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObj = [NSCalendarDate new]; + + test_NSObject(@"NSCalendarDate", [NSArray arrayWithObject: testObj]); + test_NSCoding([NSArray arrayWithObject: testObj]); + test_NSCopying(@"NSCalendarDate", @"NSCalendarDate", + [NSArray arrayWithObject: testObj], NO, NO); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCalendarDate/test00.m b/Tests/base/NSCalendarDate/test00.m new file mode 100644 index 000000000..6f27a9a5b --- /dev/null +++ b/Tests/base/NSCalendarDate/test00.m @@ -0,0 +1,414 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +#include "./western.h" + +@interface NSCalendarDate(TestAdditions) +-(BOOL) testDateValues: (int)y : (int)m : (int)d : (int)h : (int)i : (int)s; +@end +@implementation NSCalendarDate(TestAdditions) +-(BOOL) testDateValues: (int)y : (int)m : (int)d : (int)h : (int)i : (int)s +{ + return (y == [self yearOfCommonEra] && m == [self monthOfYear] + && d == [self dayOfMonth] && h == [self hourOfDay] + && i == [self minuteOfHour] && s == [self secondOfMinute]); +} +@end +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val1, *val2; + NSCalendarDate *date1, *date2; + NSDictionary *locale; + NSTimeZone *tz; + + val1 = @"1999-12-31 23:59:59"; + val2 = @"%Y-%m-%d %H:%M:%S"; + + /* Y2K checks */ + date1 = [NSCalendarDate calendarDate]; + PASS(date1 != nil && [date1 isKindOfClass: [NSCalendarDate class]], + "+calendarDate works"); + + date1 = [NSCalendarDate dateWithString: val1 calendarFormat: val2]; + PASS(date1 != nil, "+dateWithString:calendarFormat: works"); + + locale = westernLocale(); + date1 = [NSCalendarDate dateWithString: @"Fri Oct 27 08:41:14GMT 2000" + calendarFormat: nil + locale: locale]; + PASS(date1 != nil, + "+dateWithString:calendarFormat:locale: with nil format works"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 23:59:" + calendarFormat: val2 + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to missing seconds"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 23::00" + calendarFormat: val2 + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to missing minutes"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 :00:00" + calendarFormat: val2 + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to missing hours"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-00 00:00:00" + calendarFormat: val2 + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to zero day"); + + date1 = [NSCalendarDate dateWithString: @"1999-00-01 00:00:00" + calendarFormat: val2 + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to zero month"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z" + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to missing timezone"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 this_is_a_ridiculously_long_timezone_name_and_is_in_fact_designed_to_exceed_the_one_hundred_and_twenty_bytes_temporary_data_buffer_size_used_within_the_gnustep_base_method_which_parses_it" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z" + locale: locale]; + PASS(date1 == nil, + "+dateWithString:calendarFormat:locale: objects to long timezone"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 GMT+0100" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z" + locale: locale]; + PASS(date1 != nil, + "+dateWithString:calendarFormat:locale: handles GMT+0100 timezone"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 GMT-0100" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z" + locale: locale]; + PASS(date1 != nil, + "+dateWithString:calendarFormat:locale: handles GMT-0100 timezone"); + + date1 = [NSCalendarDate dateWithString: + @"1999-12-31 00:00:00 Africa/Addis_Ababa" + calendarFormat: @"%Y-%m-%d %H:%M:%S %Z" + locale: locale]; + PASS(date1 != nil, + "+dateWithString:calendarFormat:locale: handles Africa/Addis_Ababa"); + + date1 = [NSCalendarDate dateWithString: @"1999-12-31 23:59:59" + calendarFormat: val2 + locale: locale]; + PASS([date1 testDateValues: 1999 : 12 : 31 : 23 : 59 : 59], + "date check with %s", [[date1 description] cString]); + date2 = [date1 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2000 : 01 : 01 : 01 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 1999 : 12 : 31 : 23 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + /* Y2K is a leap year checks */ + date2 = [NSCalendarDate dateWithString: @"2000-2-28 23:59:59" + calendarFormat: val2 + locale: locale]; + + PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 59 : 59], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2000 : 02 : 29 : 01 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 5 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2000 : 02 : 29 : 04 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 1 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2001 : 03 : 01 : 04 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: -1 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2001 : 02 : 28 : 04 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 1 + months: 0 days: 1 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 03 : 01 : 04 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + /* 2004 is a year leap check */ + date2 = [NSCalendarDate dateWithString: @"2004-2-28 23:59:59" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 59 : 59], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 01], + "date check with %s", [[date2 description] cString]); + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2004 : 02 : 29 : 01 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + /* 2100 is not a leap year */ + + date2 = [NSCalendarDate dateWithString: @"2100-2-28 23:59:59" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 59 : 59], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 00], + "date check with %s", [[date2 description] cString]); + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 01], + "date check with %s", [[date2 description] cString]); + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2100 : 03 : 01 : 01 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 00 : 01], + "date check with %s", [[date2 description] cString]); + + /* daylight savings time checks */ + [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GB"]]; + + date2 = [NSCalendarDate dateWithString: @"2002-3-31 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 2 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00], + "date check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00], + "date check with %s", [[date2 description] cString]); + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 03 : 30 : 23 : 30 : 00], + "date check with %s", [[date2 description] cString]); + /* End daylight savings checks */ + + /* Seconds calculation checks */ + date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date second calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: -1]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 59], + "date second calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date second calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 2]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 02], + "date second calculation check with %s", [[date2 description] cString]); + + /* Minutes calculation checks */ + date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date minute calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: -1 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 00], + "date minute calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 1 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date minute calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 0 minutes: 1 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 31 : 00], + "date minute calculation check with %s", [[date2 description] cString]); + + /* Hour calculation checks */ + date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date hour calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 26 : 23 : 30 : 00], + "date hour calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date hour calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 0 hours: 2 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 02 : 30 : 00], + "date hour calculation check with %s", [[date2 description] cString]); + + /* Days calculation checks */ + date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date day calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: -1 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 26 : 00 : 30 : 00], + "date day calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 1 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date day calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 0 days: 2 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 29 : 00 : 30 : 00], + "date day calculation check with %s", [[date2 description] cString]); + + /* Months calculation checks */ + date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date month calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: -1 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 9 : 27 : 00 : 30 : 00], + "date month calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 1 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date month calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 0 + months: 2 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 12 : 27 : 00 : 30 : 00], + "date month calculation check with %s", [[date2 description] cString]); + + /* Years calculation checks */ + date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" + calendarFormat: val2 + locale: locale]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date year calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: -1 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2001 : 10 : 27 : 00 : 30 : 00], + "date year calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 1 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], + "date year calculation check with %s", [[date2 description] cString]); + + date2 = [date2 dateByAddingYears: 2 + months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; + PASS([date2 testDateValues: 2004 : 10 : 27 : 00 : 30 : 00], + "date year calculation check with %s", [[date2 description] cString]); + + [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; + + tz = [NSTimeZone timeZoneWithName: @"GB"]; + date2 = [NSCalendarDate dateWithYear: 2006 + month: 10 day: 1 hour: 0 minute: 0 second: 0 timeZone: tz]; + date2 = [date2 dateByAddingYears: 0 + months: 1 days: 0 hours: 2 minutes: 10 seconds: 0]; + PASS([date2 testDateValues: 2006 : 11 : 1 : 2 : 10 : 00], + "date year calculation check with %s", [[date2 description] cString]); + PASS([[date2 timeZone] isEqual: tz], + "date year calculation preserves timezone"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCalendarDate/test01.m b/Tests/base/NSCalendarDate/test01.m new file mode 100644 index 000000000..0142a5478 --- /dev/null +++ b/Tests/base/NSCalendarDate/test01.m @@ -0,0 +1,94 @@ +#import "Testing.h" +#import +#import +#import +#import + +#include "./western.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSTimeInterval time1, time2, time3, time4, time5, time6, time7, time8, time9; + NSCalendarDate *date1; + NSDictionary *locale; + + locale = westernLocale(); + + time1 = [[NSCalendarDate dateWithString: @"Nov 20 02 01:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time2 = [[NSCalendarDate dateWithString: @"Nov 20 02 02:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time3 = [[NSCalendarDate dateWithString: @"Nov 20 02 03:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time4 = [[NSCalendarDate dateWithString: @"Nov 20 02 04:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time5 = [[NSCalendarDate dateWithString: @"Nov 20 02 05:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time6 = [[NSCalendarDate dateWithString: @"Nov 20 02 06:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time7 = [[NSCalendarDate dateWithString: @"Nov 20 02 07:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time8 = [[NSCalendarDate dateWithString: @"Nov 20 02 08:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + time9 = [[NSCalendarDate dateWithString: @"Nov 20 02 09:54:22" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale] + timeIntervalSinceReferenceDate]; + + PASS ((time1 < time2 && time2 < time3 && time3 < time4 && time4 < time5 + && time5 < time6 && time6 < time7 && time7 < time8 && time8 < time9), + "+dateWithString:calendarFormat: works if no time zone is specified"); + + date1 = [NSCalendarDate dateWithString: @"Nov 29 06 12:00am" + calendarFormat: @"%b %d %y %H:%M%p" + locale: locale]; + PASS(date1 != nil && [date1 hourOfDay] == 0, "12:00am is midnight"); + + date1 = [NSCalendarDate dateWithString: @"Nov 29 06 12:00pm" + calendarFormat: @"%b %d %y %H:%M%p" + locale: locale]; + PASS(date1 != nil && [date1 hourOfDay] == 12, "12:00pm is noon"); + + date1 = [NSCalendarDate dateWithString: @"Nov 29 06 01:25:38" + calendarFormat: @"%b %d %y %H:%M:%S" + locale: locale]; + PASS([date1 timeIntervalSinceReferenceDate] + 1 == [[date1 addTimeInterval:1] + timeIntervalSinceReferenceDate], + "-addTimeInterval: works on a NSCalendarDate parsed with no timezone"); + + { + NSString *fmt = @"%Y-%m-%d %H:%M:%S:%F"; + NSString *fmt2 = @"%Y-%m-%e %H:%M:%S:%F"; + NSString *dateString = @"2006-04-22 22:22:22:901"; + NSString *dateString2 = @"2006-04-2 22:22:22:901"; + NSCalendarDate *date = [NSCalendarDate + dateWithString:dateString calendarFormat:fmt locale:locale]; + NSCalendarDate *date2 = [NSCalendarDate + dateWithString:dateString2 calendarFormat:fmt2 locale:locale]; + NSLog(@"%@\n%@", dateString, [date descriptionWithCalendarFormat:fmt]); + PASS([dateString isEqual: [date descriptionWithCalendarFormat:fmt]], + "formatting milliseconds works"); + PASS([dateString2 isEqual: [date2 descriptionWithCalendarFormat:fmt2]], + "formatting with %%e works"); + } + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCalendarDate/test02.m b/Tests/base/NSCalendarDate/test02.m new file mode 100644 index 000000000..ac2d2cede --- /dev/null +++ b/Tests/base/NSCalendarDate/test02.m @@ -0,0 +1,209 @@ +#import "Testing.h" +#import +#import +#import +#import +#import + +#include "./western.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableArray *tmpArray; + NSMutableDictionary *myLocale; + NSCalendarDate *myBirthday; + NSCalendarDate *anotherDay; + + myLocale = westernLocale(); + + tmpArray = [NSMutableArray new]; + [tmpArray addObject: @"Gen"]; + [tmpArray addObject: @"Feb"]; + [tmpArray addObject: @"Mar"]; + [tmpArray addObject: @"Apr"]; + [tmpArray addObject: @"Mag"]; + [tmpArray addObject: @"Giu"]; + [tmpArray addObject: @"Lug"]; + [tmpArray addObject: @"Ago"]; + [tmpArray addObject: @"Set"]; + [tmpArray addObject: @"Ott"]; + [tmpArray addObject: @"Nov"]; + [tmpArray addObject: @"Dic"]; + [myLocale setObject: tmpArray forKey: NSShortMonthNameArray]; + + ASSIGN(tmpArray,[NSMutableArray new]); + [tmpArray addObject: @"Gennaio"]; + [tmpArray addObject: @"Febbraio"]; + [tmpArray addObject: @"Marzo"]; + [tmpArray addObject: @"Aprile"]; + [tmpArray addObject: @"Maggio"]; + [tmpArray addObject: @"Giugno"]; + [tmpArray addObject: @"Luglio"]; + [tmpArray addObject: @"Agosto"]; + [tmpArray addObject: @"Settembre"]; + [tmpArray addObject: @"Ottobre"]; + [tmpArray addObject: @"Novembre"]; + [tmpArray addObject: @"Dicembre"]; + [myLocale setObject: tmpArray forKey: NSMonthNameArray]; + + ASSIGN(tmpArray,[NSMutableArray new]); + [tmpArray addObject: @"Dom"]; + [tmpArray addObject: @"Lun"]; + [tmpArray addObject: @"Mar"]; + [tmpArray addObject: @"Mer"]; + [tmpArray addObject: @"Gio"]; + [tmpArray addObject: @"Ven"]; + [tmpArray addObject: @"Sab"]; + [myLocale setObject: tmpArray forKey: NSShortWeekDayNameArray]; + + ASSIGN(tmpArray,[NSMutableArray new]); + [tmpArray addObject: @"Domencia"]; + [tmpArray addObject: @"Lunedi"]; + [tmpArray addObject: @"Martedi"]; + [tmpArray addObject: @"Mercoledi"]; + [tmpArray addObject: @"Giovedi"]; + [tmpArray addObject: @"Venerdi"]; + [tmpArray addObject: @"Sabato"]; + [myLocale setObject: tmpArray forKey: NSWeekDayNameArray]; + + ASSIGN(tmpArray,[NSMutableArray new]); + [tmpArray addObject: @"AM"]; + [tmpArray addObject: @"PM"]; + [myLocale setObject: tmpArray forKey: NSAMPMDesignation]; + + myBirthday = [NSCalendarDate dateWithYear: 1974 + month: 11 + day: 20 + hour: 13 + minute: 0 + second: 0 + timeZone: [NSTimeZone timeZoneWithName: @"MET"]]; + + anotherDay = [NSCalendarDate dateWithYear: 1974 + month: 1 + day: 2 + hour: 3 + minute: 0 + second: 0 + timeZone: [NSTimeZone timeZoneWithName: @"MET"]]; + + PASS([[myBirthday descriptionWithCalendarFormat: @"%%" + locale: myLocale] isEqualToString: @"%"], + "%% format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%a" + locale: myLocale] isEqualToString: @"Mer"], + "%%a format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%A" + locale: myLocale] isEqualToString: @"Mercoledi"], + "%%A format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%b" + locale: myLocale] isEqualToString: @"Nov"], + "%%b format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%B" + locale: myLocale] isEqualToString: @"Novembre"], + "%%B format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%d" + locale: myLocale] isEqualToString: @"20"], + "%%d format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%e" + locale: myLocale] isEqualToString: @"20"], + "%%e format works in description"); + + PASS([[anotherDay descriptionWithCalendarFormat: @"%e" + locale: myLocale] isEqualToString: @"2"], + "%%e format has no leading space with single digit"); + + PASS([[anotherDay descriptionWithCalendarFormat: @"%2e" + locale: myLocale] isEqualToString: @" 2"], + "%%2e format has leading space with single digit"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%F" + locale: myLocale] isEqualToString: @"000"], + "%%F format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%H" + locale: myLocale] isEqualToString: @"13"], + "%%H format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%I" + locale: myLocale] isEqualToString: @"01"], + "%%I format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%j" + locale: myLocale] isEqualToString: @"324"], + "%%j format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%m" + locale: myLocale] isEqualToString: @"11"], + "%%m format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%M" + locale: myLocale] isEqualToString: @"00"], + "%%M format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%p" + locale: myLocale] isEqualToString: @"PM"], + "%%p format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%S" + locale: myLocale] isEqualToString: @"00"], + "%%S format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%w" + locale: myLocale] isEqualToString: @"3"], + "%%w format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%y" + locale: myLocale] isEqualToString: @"74"], + "%%y format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%Y" + locale: myLocale] isEqualToString: @"1974"], + "%%Y format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%Z" + locale: myLocale] isEqualToString: @"MET"], + "%%Z format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%z" + locale: myLocale] isEqualToString: @"+0100"], + "%%z format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%d %m %Y" + locale: myLocale] isEqualToString: @"20 11 1974"], + "%%d %%m %%Y format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%d %B %y" + locale: myLocale] isEqualToString: @"20 Novembre 74"], + "%%d %%B %%Y format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%H:%M:%S" + locale: myLocale] isEqualToString: @"13:00:00"], + "%%H:%%M:%%S format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%H%%%M%%%S" + locale: myLocale] isEqualToString: @"13%00%00"], + "%%H%%%%%%M%%%%%%S format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%H:%M (%Z)" + locale: myLocale] isEqualToString: @"13:00 (MET)"], + "%%H%%M format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%R" + locale: myLocale] isEqualToString: @"13:00"], + "%%R format works in description"); + + PASS([[myBirthday descriptionWithCalendarFormat: @"%r" + locale: myLocale] isEqualToString: @"01:00:00 PM"], + "%%r format works in description"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCalendarDate/western.h b/Tests/base/NSCalendarDate/western.h new file mode 100644 index 000000000..da376e06d --- /dev/null +++ b/Tests/base/NSCalendarDate/western.h @@ -0,0 +1,108 @@ +#import "Foundation/NSArray.h" +#import "Foundation/NSDictionary.h" +#import "Foundation/NSString.h" +#import "Foundation/NSUserDefaults.h" + +/* Function to return a standardised locale dictionary. + */ +static NSMutableDictionary * +westernLocale() +{ + NSArray *ampm; + NSArray *long_day; + NSArray *long_month; + NSArray *short_day; + NSArray *short_month; + NSArray *earlyt; + NSArray *latert; + NSArray *hour_names; + NSArray *ymw_names; + + ampm = [NSArray arrayWithObjects: @"AM", @"PM", nil]; + + short_month = [NSArray arrayWithObjects: + @"Jan", + @"Feb", + @"Mar", + @"Apr", + @"May", + @"Jun", + @"Jul", + @"Aug", + @"Sep", + @"Oct", + @"Nov", + @"Dec", + nil]; + + long_month = [NSArray arrayWithObjects: + @"January", + @"February", + @"March", + @"April", + @"May", + @"June", + @"July", + @"August", + @"September", + @"October", + @"November", + @"December", + nil]; + + short_day = [NSArray arrayWithObjects: + @"Sun", + @"Mon", + @"Tue", + @"Wed", + @"Thu", + @"Fri", + @"Sat", + nil]; + + long_day = [NSArray arrayWithObjects: + @"Sunday", + @"Monday", + @"Tuesday", + @"Wednesday", + @"Thursday", + @"Friday", + @"Saturday", + nil]; + + earlyt = [NSArray arrayWithObjects: + @"prior", + @"last", + @"past", + @"ago", + nil]; + + latert = [NSArray arrayWithObjects: @"next", nil]; + + ymw_names = [NSArray arrayWithObjects: @"year", @"month", @"week", nil]; + + hour_names = [NSArray arrayWithObjects: + [NSArray arrayWithObjects: @"0", @"midnight", nil], + [NSArray arrayWithObjects: @"12", @"noon", @"lunch", nil], + [NSArray arrayWithObjects: @"10", @"morning", nil], + [NSArray arrayWithObjects: @"14", @"afternoon", nil], + [NSArray arrayWithObjects: @"19", @"dinner", nil], + nil]; + + return [NSMutableDictionary dictionaryWithObjectsAndKeys: + ampm, NSAMPMDesignation, + long_month, NSMonthNameArray, + long_day, NSWeekDayNameArray, + short_month, NSShortMonthNameArray, + short_day, NSShortWeekDayNameArray, + @"DMYH", NSDateTimeOrdering, + [NSArray arrayWithObject: @"tomorrow"], NSNextDayDesignations, + [NSArray arrayWithObject: @"nextday"], NSNextNextDayDesignations, + [NSArray arrayWithObject: @"yesterday"], NSPriorDayDesignations, + [NSArray arrayWithObject: @"today"], NSThisDayDesignations, + earlyt, NSEarlierTimeDesignations, + latert, NSLaterTimeDesignations, + hour_names, NSHourNameDesignations, + ymw_names, NSYearMonthWeekDesignations, + nil]; +} diff --git a/Tests/base/NSCharacterSet/TestInfo b/Tests/base/NSCharacterSet/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSCharacterSet/basic.m b/Tests/base/NSCharacterSet/basic.m new file mode 100644 index 000000000..834191306 --- /dev/null +++ b/Tests/base/NSCharacterSet/basic.m @@ -0,0 +1,19 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObj = [NSCharacterSet alphanumericCharacterSet]; + test_alloc(@"NSCharacterSet"); + test_NSObject(@"NSCharacterSet", [NSArray arrayWithObject:testObj]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSCharacterSet", @"NSMutableCharacterSet", [NSArray arrayWithObject:testObj], NO, NO); + test_NSMutableCopying(@"NSCharacterSet",@"NSMutableCharacterSet", [NSArray arrayWithObject:testObj]); + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCharacterSet/class.m b/Tests/base/NSCharacterSet/class.m new file mode 100644 index 000000000..81f5e3ba0 --- /dev/null +++ b/Tests/base/NSCharacterSet/class.m @@ -0,0 +1,67 @@ +#import "Testing.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSCharacterSet *theSet = nil; + + theSet = [NSCharacterSet alphanumericCharacterSet]; + PASS(theSet != nil, "NSCharacterSet understands [+alphanumericCharacterSet]"); + PASS([NSCharacterSet alphanumericCharacterSet] == theSet, + "NSCharacterSet uniques alphanumericCharacterSet"); + + theSet = [NSCharacterSet controlCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+controlCharacterSet]"); + PASS([NSCharacterSet controlCharacterSet] == theSet, + "NSCharacterSet uniques controlCharacterSet"); + + theSet = [NSCharacterSet decimalDigitCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+decimalDigitCharacterSet]"); + PASS([NSCharacterSet decimalDigitCharacterSet] == theSet, + "NSCharacterSet uniques [+decimalDigitCharacterSet]"); + + theSet = [NSCharacterSet illegalCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+illegalCharacterSet]"); + PASS([NSCharacterSet illegalCharacterSet] == theSet, + "NSCharacterSet uniques [+illegalCharacterSet]"); + + theSet = [NSCharacterSet letterCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+letterCharacterSet]"); + PASS([NSCharacterSet letterCharacterSet] == theSet, + "NSCharacterSet uniques [+letterCharacterSet]"); + + theSet = [NSCharacterSet lowercaseLetterCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+lowercaseLetterCharacterSet]"); + PASS([NSCharacterSet lowercaseLetterCharacterSet] == theSet, + "NSCharacterSet uniques [+lowercaseLetterCharacterSet]"); + + theSet = [NSCharacterSet nonBaseCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+nonBaseCharacterSet]"); + PASS([NSCharacterSet nonBaseCharacterSet] == theSet, + "NSCharacterSet uniques [+nonBaseCharacterSet]"); + + theSet = [NSCharacterSet punctuationCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+punctuationCharacterSet]"); + PASS([NSCharacterSet punctuationCharacterSet] == theSet, + "NSCharacterSet uniques [+punctuationCharacterSet]"); + + theSet = [NSCharacterSet uppercaseLetterCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+uppercaseLetterCharacterSet]"); + PASS([NSCharacterSet uppercaseLetterCharacterSet] == theSet, + "NSCharacterSet uniques [+uppercaseLetterCharacterSet]"); + + theSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+whitespaceAndNewlineCharacterSet]"); + PASS([NSCharacterSet whitespaceAndNewlineCharacterSet] == theSet, + "NSCharacterSet uniques [+whitespaceAndNewlineCharacterSet]"); + + theSet = [NSCharacterSet whitespaceCharacterSet]; + PASS(theSet != nil,"NSCharacterSet understands [+whitespaceCharacterSet]"); + PASS([NSCharacterSet whitespaceCharacterSet] == theSet, + "NSCharacterSet uniques [+whitespaceCharacterSet]"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCharacterSet/general.m b/Tests/base/NSCharacterSet/general.m new file mode 100644 index 000000000..1bc67a6b7 --- /dev/null +++ b/Tests/base/NSCharacterSet/general.m @@ -0,0 +1,93 @@ +#import "Testing.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSCharacterSet *theSet,*iSet; + NSData *data1 = nil; + theSet = [NSCharacterSet alphanumericCharacterSet]; + PASS([theSet characterIsMember:'A'] && + [theSet characterIsMember:'Z'] && + [theSet characterIsMember:'a'] && + [theSet characterIsMember:'z'] && + [theSet characterIsMember:'9'] && + [theSet characterIsMember:'0'] && + ![theSet characterIsMember:'#'] && + ![theSet characterIsMember:' '] && + ![theSet characterIsMember:'\n'], + "Check some characters from alphanumericCharacterSet"); + + theSet = [NSCharacterSet lowercaseLetterCharacterSet]; + PASS(![theSet characterIsMember:'A'] && + ![theSet characterIsMember:'Z'] && + [theSet characterIsMember:'a'] && + [theSet characterIsMember:'z'] && + ![theSet characterIsMember:'9'] && + ![theSet characterIsMember:'0'] && + ![theSet characterIsMember:'#'] && + ![theSet characterIsMember:' '] && + ![theSet characterIsMember:'\n'], + "Check some characters from lowercaseLetterCharacterSet"); + + theSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + PASS(![theSet characterIsMember:'A'] && + ![theSet characterIsMember:'Z'] && + ![theSet characterIsMember:'a'] && + ![theSet characterIsMember:'z'] && + ![theSet characterIsMember:'9'] && + ![theSet characterIsMember:'0'] && + ![theSet characterIsMember:'#'] && + [theSet characterIsMember:' '] && + [theSet characterIsMember:'\n'] && + [theSet characterIsMember:'\t'], + "Check some characters from whitespaceAndNewlineCharacterSet"); + + data1 = [theSet bitmapRepresentation]; + PASS(data1 != nil && [data1 isKindOfClass:[NSData class]], + "-bitmapRepresentation works"); + + iSet = [theSet invertedSet]; + PASS([iSet characterIsMember:'A'] && + [iSet characterIsMember:'Z'] && + [iSet characterIsMember:'a'] && + [iSet characterIsMember:'z'] && + [iSet characterIsMember:'9'] && + [iSet characterIsMember:'0'] && + [iSet characterIsMember:'#'] && + ![iSet characterIsMember:' '] && + ![iSet characterIsMember:'\n'] && + ![iSet characterIsMember:'\t'], + "-invertedSet works"); + { + NSCharacterSet *firstSet,*secondSet,*thirdSet,*fourthSet; + firstSet = [NSCharacterSet decimalDigitCharacterSet]; + secondSet = [NSCharacterSet decimalDigitCharacterSet]; + thirdSet = nil; + fourthSet = [NSMutableCharacterSet decimalDigitCharacterSet]; + thirdSet = [[firstSet class] decimalDigitCharacterSet]; + PASS (firstSet == secondSet && + firstSet == thirdSet && + firstSet != fourthSet, + "Caching of standard sets"); + } + + theSet = [NSCharacterSet characterSetWithCharactersInString:@"Not a set"]; + PASS(theSet != nil && [theSet isKindOfClass:[NSCharacterSet class]], + "Create custom set with characterSetWithCharactersInString:"); + + PASS([theSet characterIsMember:' '] && + [theSet characterIsMember:'N'] && + [theSet characterIsMember:'o'] && + ![theSet characterIsMember:'A'] && + ![theSet characterIsMember:'#'], + "Check custom set"); + + + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSCharacterSet/illegalCharacterSet.m b/Tests/base/NSCharacterSet/illegalCharacterSet.m new file mode 100644 index 000000000..e101d4002 --- /dev/null +++ b/Tests/base/NSCharacterSet/illegalCharacterSet.m @@ -0,0 +1,59 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import + +int +main (int argc, char**argv) +{ + id pool = [NSAutoreleasePool new]; + NSCharacterSet *illegal = [NSCharacterSet illegalCharacterSet]; + NSCharacterSet *legal = [illegal invertedSet]; + NSMutableData *data; + NSString *s; + unichar cp; + + PASS([illegal characterIsMember: 0xfffe], "0xfffe is illegal"); + PASS(![legal characterIsMember: 0xfffe], "0xfffe is bnot legal"); + PASS([illegal characterIsMember: 0xffff], "0xffff is illegal"); + PASS(![legal characterIsMember: 0xffff], "0xffff is not legal"); + PASS([illegal characterIsMember: 0xfdd0], "0xfdd0 is illegal"); + PASS(![legal characterIsMember: 0xfdd0], "0xfdd0 is not legal"); + PASS([illegal longCharacterIsMember: 0x0010fffe], "0x0010fffe is illegal"); + PASS(![legal longCharacterIsMember: 0x0010fffe], "0x0010fffe is not legal"); + + // Null character + PASS(![illegal characterIsMember: 0x0000], "0x0000 is not illegal"); + PASS([legal characterIsMember: 0x0000], "0x0000 is legal"); + // First half of surrogate pair + PASS(![illegal characterIsMember: 0xd800], "0xd800 is not illegal"); + PASS([legal characterIsMember: 0xd800], "0xd800 is legal"); + // Second half of surrogate pair + PASS(![illegal characterIsMember: 0xdc00], "0xdc00 is not illegal"); + PASS([legal characterIsMember: 0xdc00], "0xdc00 is legal"); + // Private use character in code plane 16 + PASS([illegal longCharacterIsMember: 0x0010fffd], "0x0010fffd illegal"); + PASS(![legal longCharacterIsMember: 0x0010fffd], "0x0010fffd is illegal"); + + // Entire UCS-2 set (UTF-16 surrogates start above 0xD800) + // (still looking for official information on the range of UCS-2 code points, + // i.e. whether UCS-4/UCS-2 are actually official code point sets + // or whether they are just commonly used terms to differentiate + // the full UCS code point set from it's UTF-16 encoding.) + data = [NSMutableData dataWithCapacity: sizeof(cp) * 0xD800]; + // Do not start with 0x0000 otherwise a leading BOM could misinterpreted. + for (cp=0x0001;cp<0xFFFF;cp++) + { + /* Skip code points that are reserved for surrogate characters. */ + if (cp == 0xD800) cp = 0xF900; + if ([legal characterIsMember:cp]) + { + [data appendBytes: &cp length: sizeof(cp)]; + } + } + s = [[NSString alloc] initWithData: data encoding: NSUnicodeStringEncoding]; + PASS([s length],"legal UCS-2 set can be represented in an NSString."); + [s release]; + + [pool release]; + return (0); +} diff --git a/Tests/base/NSConnection/GNUmakefile.preamble b/Tests/base/NSConnection/GNUmakefile.preamble new file mode 100644 index 000000000..382fa2a2f --- /dev/null +++ b/Tests/base/NSConnection/GNUmakefile.preamble @@ -0,0 +1,9 @@ + +ADDITIONAL_OBJCFLAGS += -I../GenericTests/ -I../../.. -Wall + +$(GNUSTEP_INSTANCE)_SUBPROJECTS = ../GenericTests + +SUBPROJECTS= ../GenericTests Resources + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSConnection/Resources/Connection.m b/Tests/base/NSConnection/Resources/Connection.m new file mode 100644 index 000000000..a0337206a --- /dev/null +++ b/Tests/base/NSConnection/Resources/Connection.m @@ -0,0 +1,73 @@ +#include +#include + +id myServer; + +@interface Tester : NSObject +{ +} ++ (void) connectWithPorts: (NSArray*)portArray; ++ (void) setServer: (id)anObject; ++ (void) startup; +- (int) doIt; +@end + +@implementation Tester ++ (void) connectWithPorts: (NSArray*)portArray +{ + NSAutoreleasePool *pool; + NSConnection *serverConnection; + Tester *serverObject; + + pool = [[NSAutoreleasePool alloc] init]; + + serverConnection = [NSConnection + connectionWithReceivePort: [portArray objectAtIndex: 0] + sendPort: [portArray objectAtIndex: 1]]; + + serverObject = [[self alloc] init]; + [(id)[serverConnection rootProxy] setServer: serverObject]; + [serverObject release]; + + [[NSRunLoop currentRunLoop] run]; + [pool release]; + [NSThread exit]; + + return; +} + ++ (void) setServer: (id)anObject +{ + myServer = [anObject retain]; + NSLog(@"Got %d", [myServer doIt]); +} + ++ (void) startup +{ + NSPort *port1; + NSPort *port2; + NSArray *portArray; + NSConnection *conn; + + port1 = [NSPort port]; + port2 = [NSPort port]; + + conn = [[NSConnection alloc] initWithReceivePort: port1 sendPort: port2]; + [conn setRootObject: self]; + + /* Ports switched here. */ + portArray = [NSArray arrayWithObjects: port2, port1, nil]; + + [NSThread detachNewThreadSelector: @selector(connectWithPorts:) + toTarget: self + withObject: portArray]; + + return; +} + +- (int) doIt +{ + return 42; +} +@end + diff --git a/Tests/base/NSConnection/Resources/GNUmakefile b/Tests/base/NSConnection/Resources/GNUmakefile new file mode 100644 index 000000000..f09c5065b --- /dev/null +++ b/Tests/base/NSConnection/Resources/GNUmakefile @@ -0,0 +1,8 @@ +include $(GNUSTEP_MAKEFILES)/common.make +BUNDLE_NAME=TestConnection +TestConnection_NEEDS_GUI = NO +TestConnection_OBJC_FILES=Connection.m +include $(GNUSTEP_MAKEFILES)/bundle.make +include $(GNUSTEP_MAKEFILES)/test-tool.make + +check:: all diff --git a/Tests/base/NSConnection/TestInfo b/Tests/base/NSConnection/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSConnection/basic.m b/Tests/base/NSConnection/basic.m new file mode 100644 index 000000000..e083ad407 --- /dev/null +++ b/Tests/base/NSConnection/basic.m @@ -0,0 +1,20 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObject = nil; + test_alloc(@"NSConnection"); + testObject = [NSConnection new]; + test_NSObject(@"NSConnection",[NSArray arrayWithObject:testObject]); + testObject = [NSConnection defaultConnection]; + PASS(testObject != nil && [testObject isKindOfClass:[NSConnection class]], + "NSConnection +defaultConnection works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSConnection/connection.m b/Tests/base/NSConnection/connection.m new file mode 100644 index 000000000..110aade6a --- /dev/null +++ b/Tests/base/NSConnection/connection.m @@ -0,0 +1,36 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSBundle *bundle; + NSString *bundlePath = [[NSFileManager defaultManager] currentDirectoryPath]; + bundlePath = [bundlePath stringByAppendingPathComponent: @"Resources"]; + bundlePath = [NSBundle pathForResource: @"TestConnection" + ofType: @"bundle" + inDirectory: bundlePath]; + bundle = [NSBundle bundleWithPath: bundlePath]; + PASS([bundle load],"We can load the test bundle"); + { + /* this should probably be rewritten to uh return a bool */ + NS_DURING + NSDate *date; + NSRunLoop *run = [NSRunLoop currentRunLoop]; + [NSClassFromString(@"Tester") performSelector: @selector(startup)]; + + date = [NSDate dateWithTimeIntervalSinceNow: 3.0]; + [run runUntilDate: date]; + PASS(1, "NSConnection can do a simple connection"); + NS_HANDLER + PASS(0, "NSConnection can do a simple connection"); + NS_ENDHANDLER + } + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSCountedSet/TestInfo b/Tests/base/NSCountedSet/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSCountedSet/basic.m b/Tests/base/NSCountedSet/basic.m new file mode 100644 index 000000000..483f4e7a9 --- /dev/null +++ b/Tests/base/NSCountedSet/basic.m @@ -0,0 +1,22 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObject = [NSCountedSet new]; + test_alloc(@"NSCountedSet"); + test_NSObject(@"NSCountedSet",[NSArray arrayWithObject:testObject]); + test_NSCoding([NSArray arrayWithObject:testObject]); + test_NSCopying(@"NSCountedSet", + @"NSCountedSet", + [NSArray arrayWithObject:testObject], NO, YES); + test_NSMutableCopying(@"NSCountedSet", + @"NSCountedSet", + [NSArray arrayWithObject:testObject]); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSData/TestInfo b/Tests/base/NSData/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSData/basic.m b/Tests/base/NSData/basic.m new file mode 100644 index 000000000..99fe51fa1 --- /dev/null +++ b/Tests/base/NSData/basic.m @@ -0,0 +1,22 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObject = [NSData new]; + test_alloc(@"NSData"); + test_NSObject(@"NSData",[NSArray arrayWithObject:testObject]); + test_NSCoding([NSArray arrayWithObject:testObject]); + test_NSCopying(@"NSData", + @"NSMutableData", + [NSArray arrayWithObject:testObject], NO, NO); + test_NSMutableCopying(@"NSData", + @"NSMutableData", + [NSArray arrayWithObject:testObject]); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSData/general.m b/Tests/base/NSData/general.m new file mode 100644 index 000000000..fdd89df79 --- /dev/null +++ b/Tests/base/NSData/general.m @@ -0,0 +1,78 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + char *str1,*str2; + NSData *data1, *data2; + NSMutableData *mutable; + unsigned char *hold; + + str1 = "Test string for data classes"; + str2 = (char *) malloc(sizeof("Test string for data classes not copied")); + strcpy(str2,"Test string for data classes not copied"); + + mutable = [NSMutableData dataWithLength:100]; + hold = [mutable mutableBytes]; + + /* hmpf is this correct */ + data1 = [NSData dataWithBytes:str1 length:(strlen(str1) * sizeof(void*))]; + PASS(data1 != nil && + [data1 isKindOfClass:[NSData class]] && + [data1 length] == (strlen(str1) * sizeof(void*)) && + [data1 bytes] != str1 && + strcmp(str1,[data1 bytes]) == 0, + "+dataWithBytes:length: works"); + + data2 = [NSData dataWithBytesNoCopy:str2 length:(strlen(str2) * sizeof(void*))]; + PASS(data2 != nil && [data2 isKindOfClass:[NSData class]] && + [data2 length] == (strlen(str2) * sizeof(void*)) && + [data2 bytes] == str2, + "+dataWithBytesNoCopy:length: works"); + + data1 = [NSData dataWithBytes:nil length:0]; + PASS(data1 != nil && [data1 isKindOfClass:[NSData class]] && + [data1 length] == 0, + "+dataWithBytes:length works with 0 length"); + + [data2 getBytes:hold range:NSMakeRange(2,6)]; + PASS(strcmp(hold,"st str") == 0, "-getBytes:range works"); + + PASS_EXCEPTION([data2 getBytes:hold + range:NSMakeRange(strlen(str2)*sizeof(void*),1)];, + NSRangeException, + "getBytes:range: with bad location"); + + PASS_EXCEPTION([data2 getBytes:hold + range:NSMakeRange(1,(strlen(str2)*sizeof(void*)))];, + NSRangeException, + "getBytes:range: with bad length"); + + PASS_EXCEPTION([data2 subdataWithRange:NSMakeRange((strlen(str2)*sizeof(void*)),1)];, + NSRangeException, + "-subdataWithRange: with bad location"); + + PASS_EXCEPTION([data2 subdataWithRange:NSMakeRange(1,(strlen(str2)*sizeof(void*)))];, + NSRangeException, + "-subdataWithRange: with bad length"); + + data2 = [NSData dataWithBytesNoCopy:str1 + length:(strlen(str1) * sizeof(void*)) + freeWhenDone:NO]; + PASS(data2 != nil && [data2 isKindOfClass:[NSData class]] && + [data2 length] == (strlen(str1) * sizeof(void*)) && + [data2 bytes] == str1, + "+dataWithBytesNoCopy:length:freeWhenDone: works"); + + [arp release]; arp = nil; + + { + BOOL didNotSegfault = YES; + PASS(didNotSegfault, "+dataWithBytesNoCopy:length:freeWhenDone:NO doesn't free memory"); + } + return 0; +} diff --git a/Tests/base/NSDate/TestInfo b/Tests/base/NSDate/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSDate/basic.m b/Tests/base/NSDate/basic.m new file mode 100644 index 000000000..b79371085 --- /dev/null +++ b/Tests/base/NSDate/basic.m @@ -0,0 +1,16 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObj = [NSDate new]; + + test_NSObject(@"NSDate",[NSArray arrayWithObject:[NSDate new]]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSDate",@"NSDate",[NSArray arrayWithObject:testObj],NO,NO); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSDate/create.m b/Tests/base/NSDate/create.m new file mode 100644 index 000000000..aca50b77f --- /dev/null +++ b/Tests/base/NSDate/create.m @@ -0,0 +1,53 @@ +#import "Testing.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val; + NSDate *date1,*date2; + + val = @"2000-10-19 00:00:00 +0000"; + date1 = [NSDate date]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+date works"); + date1 = [NSDate dateWithString:val]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+dateWithString works"); + + date2 = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: + [date1 timeIntervalSinceReferenceDate]]; + PASS(date2 != nil && [date2 isKindOfClass:[NSDate class]], + "+dateWithTimeIntervalSinceReferenceDate: works"); + // Make sure we get day in correct zone. + [date2 setTimeZone: [NSTimeZone timeZoneForSecondsFromGMT: 0]]; + PASS([date2 dayOfMonth] == 19, "+dateWithString makes correct day"); + PASS([date2 monthOfYear] == 10, "+dateWithString makes correct month"); + PASS([date2 yearOfCommonEra] == 2000, "+dateWithString makes correct year"); + + date1 = [NSDate dateWithTimeIntervalSinceNow:0]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+dateWithTimeIntervalSinceNow: works"); + + date1 = [NSDate dateWithTimeIntervalSince1970:0]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+dateWithTimeIntervalSince1970: works"); + + date1 = [NSDate dateWithTimeIntervalSinceReferenceDate:0]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+dateWithTimeIntervalSinceReferenceDate: works"); + + date1 = [NSDate distantFuture]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+distantFuture works"); + + date1 = [NSDate distantPast]; + PASS(date1 != nil && [date1 isKindOfClass:[NSDate class]], + "+distantPast works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSDate/general.m b/Tests/base/NSDate/general.m new file mode 100644 index 000000000..121011702 --- /dev/null +++ b/Tests/base/NSDate/general.m @@ -0,0 +1,33 @@ +#import "Testing.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSDate *cdate, *date1, *date2; + NSComparisonResult comp; + + cdate = [NSDate date]; + + comp = [cdate compare: [NSDate distantFuture]]; + PASS(comp == NSOrderedAscending, "+distantFuture is in the future"); + + comp = [cdate compare: [NSDate distantPast]]; + PASS(comp == NSOrderedDescending, "+distantPast is in the past"); + + date1 = [NSDate dateWithTimeIntervalSinceNow:-600]; + date2 = [cdate earlierDate: date1]; + PASS(date1 == date2, "-earlierDate works"); + + date2 = [cdate laterDate: date1]; + PASS(cdate == date2, "-laterDate works"); + + date2 = [date1 addTimeInterval:0]; + PASS ([date1 isEqualToDate:date2], "-isEqualToDate works"); + + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSDateFormatter/TestInfo b/Tests/base/NSDateFormatter/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSDateFormatter/general.m b/Tests/base/NSDateFormatter/general.m new file mode 100644 index 000000000..7adccd9d0 --- /dev/null +++ b/Tests/base/NSDateFormatter/general.m @@ -0,0 +1,82 @@ +#import +#import +#import +#import +#import +#import "Testing.h" + +#if defined(GS_USE_ICU) +#define NSLOCALE_SUPPORTED GS_USE_ICU +#else +#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main(void) +{ + NSDateFormatter *inFmt; + NSDateFormatter *outFmt; + NSDate *date; + NSString *str; + NSLocale *locale; + NSCalendar *cal; + unsigned int components; + NSInteger year; + + START_SET("NSDateFormatter") + if (!NSLOCALE_SUPPORTED) + SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built") + + [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; + + inFmt = [[NSDateFormatter alloc] init]; + [inFmt setDateFormat: @"yyyy-MM-dd 'at' HH:mm"]; + date = [inFmt dateFromString: @"2011-01-27 at 17:36"]; + outFmt = [[NSDateFormatter alloc] init]; + [outFmt setLocale: [[NSLocale alloc] initWithLocaleIdentifier: @"pt_BR"]]; + [outFmt setDateFormat: @"HH:mm 'on' EEEE MMMM d"]; + str = [outFmt stringFromDate: date]; + PASS_EQUAL(str, @"17:36 on quinta-feira janeiro 27", + "Output has the same format as Cocoa.") + RELEASE(outFmt); + RELEASE(inFmt); + + locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"]; + inFmt = [NSDateFormatter new]; + [inFmt setDateStyle: NSDateFormatterShortStyle]; + [inFmt setTimeStyle: NSDateFormatterNoStyle]; + [inFmt setLocale: locale]; + [inFmt setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; + date = [inFmt dateFromString: @"15/06/1982"]; + PASS_EQUAL([date description], @"1982-06-15 00:00:00 +0000", + "GMT time zone is correctly accounted for."); + [inFmt setTimeZone: [NSTimeZone timeZoneWithName: @"EST"]]; + date = [inFmt dateFromString: @"15/06/1982"]; + PASS_EQUAL([date description], @"1982-06-15 05:00:00 +0000", + "EST time zone is correctly accounted for."); + RELEASE(inFmt); + + cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]; + [cal setTimeZone: [NSTimeZone timeZoneWithName: @"CST"]]; + [cal setLocale: locale]; + components = NSYearCalendarUnit; + year = [[cal components: components fromDate: date] year]; + inFmt = [NSDateFormatter new]; + [inFmt setLocale: locale]; + [inFmt setDateStyle: NSDateFormatterLongStyle]; + [inFmt setTimeStyle: NSDateFormatterNoStyle]; + str = [inFmt stringFromDate: date]; + PASS (year == 1982, "Year is 1982"); + PASS_EQUAL(str, @"15 June 1982", "Date is formatted correctly."); + RELEASE(cal); + RELEASE(inFmt); + + str = [NSDateFormatter dateFormatFromTemplate: @"MMMdd" + options: 0 locale: locale]; + PASS_EQUAL(str, @"dd MMM", "Convert date format as Cocoa."); + RELEASE(locale); + + END_SET("NSDateFormatter") + + return 0; +} + diff --git a/Tests/base/NSDictionary/TestInfo b/Tests/base/NSDictionary/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSDictionary/basic.m b/Tests/base/NSDictionary/basic.m new file mode 100644 index 000000000..0da4d8af2 --- /dev/null +++ b/Tests/base/NSDictionary/basic.m @@ -0,0 +1,33 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableArray *testObjs = [NSMutableArray new]; + NSDictionary *obj; + test_alloc(@"NSDictionary"); + obj = [NSDictionary new]; + [testObjs addObject:obj]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 0, + "can create an empty dictionary"); + obj = [NSDictionary dictionaryWithObject:@"Hello" forKey:@"Key"]; + [testObjs addObject:obj]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 1, + "can create a dictionary with one element"); + + test_NSObject(@"NSDictionary", testObjs); + test_NSCoding(testObjs); + test_NSCopying(@"NSDictionary", @"NSMutableDictionary", testObjs, YES, NO); + test_NSMutableCopying(@"NSDictionary", @"NSMutableDictionary", testObjs); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSDictionary/create.m b/Tests/base/NSDictionary/create.m new file mode 100644 index 000000000..c9bee6aa5 --- /dev/null +++ b/Tests/base/NSDictionary/create.m @@ -0,0 +1,79 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *key1, *key2, *key3, *val1, *val2, *val3; + NSArray *keys1, *keys2, *keys3, *vals1, *vals2, *vals3; + NSDictionary *obj,*old; + old = nil; + key1 = @"Key1"; + key2 = @"Key2"; + key3 = @"Key3"; + keys1 = [NSArray arrayWithObjects:key1, key2, nil]; + keys2 = [NSArray arrayWithObjects:key1, key2, key3, nil]; + /* duplicate keys */ + keys3 = [NSArray arrayWithObjects:key1, key2, key2, nil]; + val1 = @"Kidnapped"; + val2 = @"tied up"; + val3 = @"taken away and helf for ransom"; + vals1 = [NSArray arrayWithObjects:val1, val2, nil]; + /* duplicate values */ + vals2 = [NSArray arrayWithObjects:val1, val2, val2, nil]; + vals3 = [NSArray arrayWithObjects:val1, val2, val3, nil]; + obj = [NSDictionary new]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 0, + "+new creates an empty dictionary"); + + obj = [NSDictionary dictionary]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 0, + "+dictionary creates an empty dictionary"); + + PASS_EXCEPTION([NSDictionary dictionaryWithObject:val1 forKey:nil];, + NSInvalidArgumentException, + "+dictionaryWithObject:forKey: with nil key"); + + PASS_EXCEPTION([NSDictionary dictionaryWithObject:nil forKey:key1];, + NSInvalidArgumentException, + "+dictionaryWithObject:forKey: with nil value"); + + obj = [NSDictionary dictionaryWithObject:val1 forKey:key1]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 1, + "+dictionaryWithObject:forKey: builds minimal dictionary"); + + obj = [NSDictionary dictionaryWithObjects:vals1 forKeys:keys1]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 2, + "+dictionaryWithObjects:forKeys: builds a dictionary"); + + PASS_EXCEPTION([NSDictionary dictionaryWithObjects:vals1 forKeys:keys2];, + NSInvalidArgumentException, + "+dictionaryWithObjects:forKeys: with arrays of different sizes"); + obj = [NSDictionary dictionaryWithObjects:vals2 forKeys:keys2]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 3, + "we can have multiple identical objects in a dictionary"); + + obj = [NSDictionary dictionaryWithObjects:vals3 forKeys:keys3]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 2, + "we can't have multiple identical keys in a dictionary"); + old = obj; + obj = [NSDictionary dictionaryWithDictionary:old]; + PASS(obj != nil && + [obj isEqual: old], "+dictionaryWithDictionary: copies dictionary"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSDictionary/general.m b/Tests/base/NSDictionary/general.m new file mode 100644 index 000000000..aff8ef368 --- /dev/null +++ b/Tests/base/NSDictionary/general.m @@ -0,0 +1,238 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import +#import +#import + +#if defined(GNUSTEP_BASE_LIBRARY) +#import +#endif + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *key1, *key2, *key3, *val1, *val2, *val3; + NSArray *keys1, *keys2, *keys3, *keys4, *vals1, *vals2, *vals3, *vals4; + id obj; + NSDictionary *dict; + + key1 = @"Key1"; + key2 = @"Key2"; + key3 = @"Key3"; + val1 = @"Hello"; + val2 = @"Goodbye"; + val3 = @"Testing"; + keys1 = [NSArray arrayWithObjects:key1,key2,nil]; + keys2 = [NSArray arrayWithObjects:key1,key2,key3,nil]; + keys3 = [NSArray arrayWithObjects:key1,key2,key2,nil]; /* duplicate keys */ + keys4 = [NSArray arrayWithObjects:key1,key2,nil]; + vals1 = [NSArray arrayWithObjects:val1,val2,nil]; + vals2 = [NSArray arrayWithObjects:val1,val2,val2,nil]; /* duplicate vals */ + vals3 = [NSArray arrayWithObjects:val1,val2,val3,nil]; + vals4 = [NSArray arrayWithObjects:val1, val2, val3, [NSDate date], + [NSNumber numberWithInt:2], + [NSData data], nil]; + keys4 = [NSArray arrayWithObjects:key1, key2, key2, @"date", @"number", + @"data",nil]; + + + dict = [NSDictionary new]; + PASS(dict != nil && + [dict isKindOfClass:[NSDictionary class]] + && [dict count] == 0, + "-count returns zero for an empty dictionary"); + + PASS([dict hash] == 0, "-hash returns zero for an empty dictionary"); + obj = [dict allKeys]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 0, + "-allKeys gives an empty array for an empty dictionary"); + + obj = [dict allKeysForObject:nil]; + PASS(obj == nil, "-allKeysForObject: gives nil for an empty dictionary"); + + obj = [dict allValues]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 0, + "-allValues gives an empty array for an empty dictionary"); + { + id o1; + id o2; + + o1 = [dict objectForKey:nil]; + o2 = [dict objectForKey:key1]; + PASS(o1 == nil && o2 == nil, + "-objectForKey: gives nil for an empty dictionary"); + } + + { + NSEnumerator *e = [dict keyEnumerator]; + id k1,k2; + + k1 = [e nextObject]; + k2 = [e nextObject]; + PASS(e != nil && k1 == nil && k2 == nil, + "-keyEnumerator: is ok for empty dictionary"); + } + + { + NSEnumerator *e = [dict objectEnumerator]; + id v1,v2; + + v1 = [e nextObject]; + v2 = [e nextObject]; + PASS(e != nil && v1 == nil && v2 == nil, + "-objectEnumerator: is ok for empty dictionary"); + } + + { + NSString *notFound = @"notFound"; + NSArray *a = [dict objectsForKeys:keys1 notFoundMarker:notFound]; + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && + [a count] == 2 && + [a objectAtIndex:0] == notFound && + [a objectAtIndex:1] == notFound, + "-objectsForKeys:notFoundMarker: is ok for empty dictionary"); + } + + obj = [dict description]; + obj = [obj propertyList]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 0, + "-description gives us a text property-list"); + + dict = [[NSDictionary dictionaryWithObjects:vals1 forKeys:keys1] retain]; + PASS(dict != nil && + [dict isKindOfClass:[NSDictionary class]] && + [dict count] == 2, + "-count returns two for an dictionary with two keys"); + + PASS([dict hash] == 2, "-hash returns two for a dictionary with two keys"); + + obj = [dict allKeys]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 2 && + [obj containsObject:key1] && + [obj containsObject:key1], + "-allKeys gives the keys we put in the dictionary"); + + { + NSArray *o1,*o2; + o1 = [dict allKeysForObject:val1]; + o2 = [dict allKeysForObject:val2]; + PASS(o1 != nil && + [o1 isKindOfClass:[NSArray class]] && + [o1 count] == 1 && + [o1 containsObject:key1] && + o2 != nil && + [o2 isKindOfClass:[NSArray class]] && + [o2 count] == 1 && + [o2 containsObject:key2], + "-allKeysForObject: gives the key we expect"); + } + obj = [dict allValues]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 2 && + [obj containsObject:val1] && + [obj containsObject:val2], + "-allValues gives the values we put in the dictionary"); + + PASS([dict objectForKey:nil] == nil,"-objectForKey: gives nil for a nil key"); + PASS([dict objectForKey:key3] == nil, + "-objectForKey: gives nil for a key not in the dictionary"); + + { + id o1 = [dict objectForKey: key1]; + id o2 = [dict objectForKey: key2]; + PASS(o1 == val1 && o2 == val2, + "-objectForKey: gives the objects we added for the keys"); + } + + { + NSEnumerator *e = [dict keyEnumerator]; + id k1,k2,k3; + k1 = [e nextObject]; + k2 = [e nextObject]; + k3 = [e nextObject]; + PASS(k1 != nil && + k2 != nil && + k3 == nil && + k1 != k2 && + [keys1 containsObject:k1] && + [keys1 containsObject:k2], + "-keyEnumerator: enumerates the dictionary"); + } + + { + NSEnumerator *e = [dict objectEnumerator]; + id v1,v2,v3; + v1 = [e nextObject]; + v2 = [e nextObject]; + v3 = [e nextObject]; + + PASS(v1 != nil && + v2 != nil && + v3 == nil && + v1 != v2 && + [vals1 containsObject:v1] && + [vals1 containsObject:v2], + "-objectEnumerator: enumerates the dictionary"); + } + + { + NSString *notFound = @"notFound"; + NSArray *a = [dict objectsForKeys:keys2 notFoundMarker:notFound]; + + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && + [a count] == 3 && + [a objectAtIndex:0] == val1 && + [a objectAtIndex:1] == val2 && + [a objectAtIndex:2] == notFound, + "-objectsForKeys:notFoundMarker: is ok for dictionary"); + } + + { + NSArray *a = [dict keysSortedByValueUsingSelector:@selector(compare:)]; + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && + [a count] == 2 && + [a objectAtIndex:0] == key2 && + [a objectAtIndex:1] == key1, + "-keysSortedByValueUsingSelector: seems ok"); + } + + obj = [dict description]; + obj = [obj propertyList]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj isEqual:dict], + "-description gives us a text property-list"); + + + ASSIGN(dict,[NSDictionary dictionaryWithObjects:vals4 forKeys:keys4]); + PASS(dict != nil, "we can create a dictionary with several keys"); + +#if defined(GNUSTEP_BASE_LIBRARY) + obj = [NSSerializer serializePropertyList:dict]; + obj = [NSDeserializer deserializePropertyListFromData:obj + mutableContainers:YES]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj isEqual:dict], + "data/number/data are ok in serialized property-list"); +#endif + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSException/TestInfo b/Tests/base/NSException/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSException/basic.m b/Tests/base/NSException/basic.m new file mode 100644 index 000000000..651d243d3 --- /dev/null +++ b/Tests/base/NSException/basic.m @@ -0,0 +1,69 @@ +#import +#import +#import "ObjectTesting.h" + +static void +handler(NSException *e) +{ + PASS (YES == [[e reason] isEqual: @"Terminate"], + "uncaught exceptionhandler called as expected"); + abort(); +} + +@interface MyClass : NSObject ++ (void) testAbc; +@end +@implementation MyClass ++ (void) testAbc +{ + [NSException raise: NSGenericException format: @"In MyClass"]; +} +@end + +int main() +{ + NSException *obj; + NSMutableArray *testObjs = [[NSMutableArray alloc] init]; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + test_alloc_only(@"NSException"); + obj = [NSException exceptionWithName: NSGenericException + reason: nil + userInfo: nil]; + PASS((obj != nil), "can create an exception"); + PASS(([[obj name] isEqualToString: NSGenericException]), "name works"); + obj = [NSException exceptionWithName: NSGenericException + reason: nil + userInfo: nil]; + [testObjs addObject: obj]; + test_NSObject(@"NSException", testObjs); + + NS_DURING + [MyClass testAbc]; + NS_HANDLER + { + NSArray *a = [localException callStackSymbols]; + NSEnumerator *e = [a objectEnumerator]; + NSString *s = nil; + + while ((s = [e nextObject]) != nil) + if ([s rangeOfString: @"testAbc"].length > 0) + break; + testHopeful = YES; + PASS(s != nil, "working callStackSymbols ... if this has failed it is probably due to a lack of support for objective-c method names (local symbols) in the backtrace_symbols() function of your libc. If so, you might lobby your operating system provider for a fix."); + testHopeful = NO; + } + NS_ENDHANDLER + + PASS(NSGetUncaughtExceptionHandler() == 0, "default handler is null"); + NSSetUncaughtExceptionHandler(handler); + PASS(NSGetUncaughtExceptionHandler() == handler, "setting handler works"); + + fprintf(stderr, "We expect a single FAIL without any explanation as\n" + "the test is terminated by an uncaught exception ...\n"); + [NSException raise: NSGenericException format: @"Terminate"]; + PASS(NO, "shouldn't get here ... exception should have terminated process"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSException/basic.m.abort b/Tests/base/NSException/basic.m.abort new file mode 100644 index 000000000..70834a0d4 --- /dev/null +++ b/Tests/base/NSException/basic.m.abort @@ -0,0 +1 @@ +# this file is a marker to say that the test is expected to abort. diff --git a/Tests/base/NSException/mixedException.mm b/Tests/base/NSException/mixedException.mm new file mode 100644 index 000000000..bcf6699e3 --- /dev/null +++ b/Tests/base/NSException/mixedException.mm @@ -0,0 +1,75 @@ +#import "Testing.h" +#import + +#if defined(TESTDEV) + +#if !__has_feature(objc_nonfragile_abi) +int main(void) +{ + START_SET("String throwing") + SKIP("Unified exception model not supported") + END_SET("String throwing"); + return 0; +} + +#else + +/** + * Tests throwing an exception with the C++ exception throwing mechanism and + * catching it with the Objective-C exception handling mechanism. This + * behaviour is required for compatibility with Apple's new exception model. + * The converse should also work - throwing an object with @throw and catching + * it with catch(). + */ +int main(void) +{ + NSString *foo = @"foo"; + id caught = nil; + int final = 0; + int wrongCatch = 0; + + @try + { + throw foo; + } + @catch(NSString *f) + { + caught = f; + } + @finally + { + final = 1; + } + PASS(caught == foo, "Unified exception model works correctly"); + PASS(1==final, "@finally works in ObjC++"); + final = 0; + caught = nil; + try + { + @throw foo; + } + catch (NSArray *a) + { + wrongCatch = 1; + } + catch (NSString *f) + { + caught = f; + } + catch(...) + { + final = 1; + } + PASS(0==final, "catchall not used to catch object"); + PASS(0==wrongCatch, "Incorrect object catch not used to catch object"); + PASS(caught == foo, "Unified exception model works correctly"); + return 0; +} +#endif + +#else +int main(void) +{ + return 0; +} +#endif diff --git a/Tests/base/NSException/sillySemantics.mm b/Tests/base/NSException/sillySemantics.mm new file mode 100644 index 000000000..5a9973b12 --- /dev/null +++ b/Tests/base/NSException/sillySemantics.mm @@ -0,0 +1,76 @@ +#import "Testing.h" +#import + +#if defined(TESTDEV) + +#if !__has_feature(objc_nonfragile_abi) +int main(void) +{ + START_SET("String throwing") + SKIP("Unified exception model not supported") + END_SET("String throwing"); + return 0; +} + +#else +#if __has_include() +#include +#endif + +NSObject *foo = @"foo"; +id caughtObj = nil; +id caughtStr = nil; +int final = 0; + +void testThrow(void) +{ + caughtObj = nil; + caughtStr = nil; + final = 0; + try + { + throw foo; + } + catch (NSString *f) + { + caughtStr = f; + } + catch (NSObject *o) + { + caughtObj = o; + } + catch(...) + { + final = 1; + } +} +/** + * Tests whether C++ exception catching uses Objective-C semantics. + * + * This is a completely stupid thing to do, because it means that a C++ + * language feature now doesn't behave like a C++ language feature, but Apple + * did it so we have to do stupid things in the name of compatibility... + */ +int main(void) +{ + testThrow(); + PASS(0==final, "catchall not used to catch object"); + PASS(caughtObj == nil, "Thrown string cast to NSObject matched NSObject (Apple mode)"); + PASS(caughtStr == foo, "Thrown string cast to NSObject matched NSString (Apple mode)"); +#ifdef OBJC_UNIFIED_EXCEPTION_MODEL + // Turn off Apple compatibility mode and try again + objc_set_apple_compatible_objcxx_exceptions(0); + testThrow(); + PASS(0==final, "catchall not used to catch object"); + PASS(caughtObj == foo, "Thrown string cast to NSObject matched NSObject (sane mode)"); + PASS(caughtStr == nil, "Thrown string cast to NSObject matched NSString (sane mode)"); +#endif + return 0; +} +#endif +#else +int main(void) +{ + return 0; +} +#endif diff --git a/Tests/base/NSException/skipCatchall.mm b/Tests/base/NSException/skipCatchall.mm new file mode 100644 index 000000000..4bd4b39bf --- /dev/null +++ b/Tests/base/NSException/skipCatchall.mm @@ -0,0 +1,61 @@ +#import "Testing.h" +#import + +#if defined(TESTDEV) + +#if !__has_feature(objc_nonfragile_abi) +int main(void) +{ + START_SET("Unified exception model") + SKIP("Unified exception model not supported") + END_SET("Unified exception model") + return 0; +} + +#else + +/** + * Tests whether void* catches Objective-C objects thrown as exceptions. + * According to John McCall at Apple, the correct behaviour is not to catch + * them in void* (which makes sense - void* is effectively a restricted + * catchall, and we don't want to be catching foreign exceptions there because + * we don't know what to do with them). In fact, the current behaviour on OS X + * (with g++, not tested with clang++) is not simply to not catch them, it is + * also to crash with a segfault. Current behaviour with clang + libobjc2 is + * to do the Right Thingâ„¢. + */ +int main(void) +{ + NSString *foo = @"foo"; + id caught = nil; + int final = 0; + int wrongCatch = 0; + try + { + @throw foo; + } + catch (void *foo) + { + wrongCatch = 1; + } + catch (NSString *f) + { + caught = f; + } + catch(...) + { + final = 1; + } + PASS(0==final, "catchall not used to catch object"); + PASS(0==wrongCatch, "Incorrect object catch not used to catch object"); + PASS(caught == foo, "Unified exception model works correctly"); + return 0; +} +#endif + +#else +int main(void) +{ + return 0; +} +#endif diff --git a/Tests/base/NSException/throwstr.m b/Tests/base/NSException/throwstr.m new file mode 100644 index 000000000..b1d8f9006 --- /dev/null +++ b/Tests/base/NSException/throwstr.m @@ -0,0 +1,24 @@ +#import "Testing.h" +#import + +int main(void) +{ + START_SET("String throwing") +#if defined(BASE_NATIVE_OBJC_EXCEPTIONS) && BASE_NATIVE_OBJC_EXCEPTIONS == 1 + id caught = nil; + id thrown = @"thrown"; + @try + { + @throw thrown; + } + @catch (id str) + { + caught = str; + } + PASS((caught == thrown), "Throwing an NSConstantString instance before the class is initialised"); +#else + SKIP("Native exceptions not supported") +#endif + END_SET("String throwing") + return 0; +} diff --git a/Tests/base/NSFileHandle/TestInfo b/Tests/base/NSFileHandle/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSFileHandle/basic.m b/Tests/base/NSFileHandle/basic.m new file mode 100644 index 000000000..04c4921a8 --- /dev/null +++ b/Tests/base/NSFileHandle/basic.m @@ -0,0 +1,35 @@ +/* + Copyright (C) 2005 Free Software Foundation, Inc. + + Written by: David Ayers + Date: February 2005 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + +*/ + +#import "ObjectTesting.h" +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_NSObject(@"NSFileHandle", + [NSArray arrayWithObject:[NSFileHandle fileHandleWithStandardInput]]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSFileHandle/general.m b/Tests/base/NSFileHandle/general.m new file mode 100644 index 000000000..f3beb325d --- /dev/null +++ b/Tests/base/NSFileHandle/general.m @@ -0,0 +1,87 @@ +/* + Copyright (C) 2005 Free Software Foundation, Inc. + + Written by: David Ayers + Date: February 2005 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + +*/ + +#import "Testing.h" +#import "ObjectTesting.h" +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + /* We invert the order so that we really test the FD values when they + are not opened in order. */ + NSFileHandle *stdErrFH = [NSFileHandle fileHandleWithStandardError]; + NSFileHandle *stdOutFH = [NSFileHandle fileHandleWithStandardOutput]; + NSFileHandle *stdInFH = [NSFileHandle fileHandleWithStandardInput]; + NSFileHandle *stdNullFH = [NSFileHandle fileHandleWithNullDevice]; + NSFileHandle *t1FH, *t2FH; + NSString *tPath = [NSString stringWithFormat:@"%@/%@",NSTemporaryDirectory(),[[NSProcessInfo processInfo]globallyUniqueString]]; + NSData *t1Data = [tPath dataUsingEncoding:NSUTF8StringEncoding]; + NSData *t2Data; + + PASS([stdInFH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleWithStandardInput"); + PASS([stdInFH fileDescriptor]==0, + "NSFileHandle +fileHandleWithStandardInput has 0 as fileDescriptor"); + + PASS([stdOutFH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleWithStandardOutput"); + PASS([stdOutFH fileDescriptor]==1, + "NSFileHandle +fileHandleWithStandardOutput has 1 as fileDescriptor"); + + PASS([stdErrFH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleWithStandardError"); + PASS([stdErrFH fileDescriptor]==2, + "NSFileHandle +fileHandleWithStandardError has 2 as fileDescriptor"); + + PASS([stdNullFH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleWithNullDevice"); + + t1FH = [[NSFileHandle alloc] initWithFileDescriptor: 0]; + PASS([t1FH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands -initWithFileDescriptor:"); + + t1FH = [NSFileHandle fileHandleForWritingAtPath: tPath]; + PASS(t1FH == nil, + "NSFileHandle +fileHandleForWritingAtPath: with non-existing file return nil"); + + [@"" writeToFile: tPath atomically: YES]; + t1FH = [NSFileHandle fileHandleForWritingAtPath: tPath]; + PASS([t1FH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleForWritingAtPath:"); + + t2FH = [NSFileHandle fileHandleForReadingAtPath: tPath]; + PASS([t2FH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleForReadingAtPath:"); + + [t1FH writeData: t1Data]; + t2Data = [t2FH availableData]; + PASS([t1Data isEqual: t2Data], + "NSFileHandle -writeData:/-availableData match"); + + [[NSFileManager defaultManager] removeFileAtPath: tPath handler: nil]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSFileHandle/socket.m b/Tests/base/NSFileHandle/socket.m new file mode 100644 index 000000000..cc6d110a5 --- /dev/null +++ b/Tests/base/NSFileHandle/socket.m @@ -0,0 +1,100 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +/* + Copyright (C) 2005 Free Software Foundation, Inc. + + Written by: David Ayers + Date: November 2005 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + +*/ +#import "Testing.h" +#import "ObjectTesting.h" +#import + +#define GST_PORT @"32329" + +NSFileHandle *rFH = nil; + +@interface Handler : NSObject +@end +@implementation Handler +- (id)init +{ + if ((self = [super init])) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver: self + selector: @selector(connect:) + name: NSFileHandleConnectionAcceptedNotification + object: nil]; + } + return self; +} +- (void)connect:(NSNotification *)notif +{ + NSDictionary *d = [notif userInfo]; +NSLog(@"%@", notif); + rFH = [[d objectForKey: NSFileHandleNotificationFileHandleItem] retain]; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + Handler *h; + NSFileHandle *sFH, *cFH; + NSData *wData = [@"Socket Test" dataUsingEncoding:NSASCIIStringEncoding]; + NSData *rData; + /* Note that the above data should be short enough to fit into the + socket send buffer otherwise we risk being blocked in this single + threaded process. */ + + h = [[Handler new] autorelease]; + + sFH = [NSFileHandle fileHandleAsServerAtAddress: @"127.0.0.1" + service: GST_PORT + protocol: @"tcp"]; + PASS([sFH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleAsServerAtAddress:"); + + [sFH acceptConnectionInBackgroundAndNotify]; + + + cFH = [NSFileHandle fileHandleAsClientAtAddress: @"127.0.0.1" + service: GST_PORT + protocol: @"tcp"]; + PASS([cFH isKindOfClass:[NSFileHandle class]], + "NSFileHandle understands +fileHandleAsClientAtAddress:"); + + [cFH writeData: wData]; + [[NSRunLoop currentRunLoop] run]; + PASS(rFH != nil, "NSFileHandle connection was made"); + + rData = [rFH availableData]; + PASS([wData isEqual: rData], + "NSFileHandle -writeData:/-availableData match with socket"); + + [arp release]; arp = nil; + return 0; +} +#else +int main() +{ + return 0; +} +#endif diff --git a/Tests/base/NSFileManager/TestInfo b/Tests/base/NSFileManager/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSFileManager/basic.m b/Tests/base/NSFileManager/basic.m new file mode 100644 index 000000000..49f21990a --- /dev/null +++ b/Tests/base/NSFileManager/basic.m @@ -0,0 +1,12 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_NSObject(@"NSFileManager", + [NSArray arrayWithObject:[NSFileManager defaultManager]]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSFileManager/general.m b/Tests/base/NSFileManager/general.m new file mode 100644 index 000000000..22507cc85 --- /dev/null +++ b/Tests/base/NSFileManager/general.m @@ -0,0 +1,182 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSFileManager *mgr = [NSFileManager defaultManager]; + NSString *dir = @"NSFileManagerTestDir"; + NSString *dirInDir = [@"TestDirectory" stringByAppendingPathComponent: @"WithinDirectory"]; + NSString *str1,*str2; + PASS(mgr != nil && [mgr isKindOfClass: [NSFileManager class]], + "NSFileManager understands +defaultManager"); + +/* remove test directory if it exists */ + { + BOOL exists,isDir; + exists = [mgr fileExistsAtPath: dir isDirectory: &isDir]; + if (exists) + { + [mgr removeFileAtPath: dir handler: nil]; + } + } + PASS([mgr fileAttributesAtPath: dir traverseLink: NO] == nil, + "NSFileManager returns nil for attributes of non-existent file"); + + + { + NSDictionary *attr; + BOOL isDir; + PASS([mgr createDirectoryAtPath: dir attributes: nil], + "NSFileManager can create a directory"); + PASS([mgr fileExistsAtPath: dir isDirectory: &isDir] && + isDir == YES, + "exists and is a directory"); + PASS([mgr fileAttributesAtPath: dir traverseLink: NO] != nil, + "NSFileManager returns non-nil for attributes of existing file"); + attr = [mgr fileAttributesAtPath: dir traverseLink: NO]; + PASS(attr != nil, + "NSFileManager returns non-nil for attributes of existing file"); + PASS([NSUserName() isEqual: [attr fileOwnerAccountName]], + "newly created file is owned by current user"); +NSLog(@"'%@', '%@'", NSUserName(), [attr fileOwnerAccountName]); + } + + PASS([mgr changeCurrentDirectoryPath: dir], + "NSFileManager can change directories"); + + + { + NSString *dir1 = [mgr currentDirectoryPath]; + PASS(dir1 != nil && [[dir1 lastPathComponent] isEqualToString: dir], + "NSFileManager can get current dir"); + } + + str1 = @"A string"; + PASS([mgr createFileAtPath: @"NSFMFile" + contents: [str1 dataUsingEncoding: 1] + attributes: nil], + "NSFileManager creates a file"); + PASS([mgr fileExistsAtPath: @"NSFMFile"],"-fileExistsAtPath: agrees"); + + { + NSData *dat1 = [mgr contentsAtPath: @"NSFMFile"]; + str2 = [[NSString alloc] initWithData: dat1 encoding: 1]; + PASS([str1 isEqualToString: str2], "NSFileManager file contents match"); + } + + PASS([mgr copyPath: @"NSFMFile" + toPath: @"NSFMCopy" + handler: nil], + "NSFileManager copies a file"); + PASS([mgr fileExistsAtPath: @"NSFMCopy"],"-fileExistsAtPath: agrees"); + { + NSData *dat1 = [mgr contentsAtPath: @"NSFMCopy"]; + str2 = [[NSString alloc] initWithData: dat1 encoding: 1]; + PASS([str1 isEqual: str2],"NSFileManager copied file contents match"); + } + + PASS([mgr movePath: @"NSFMFile" + toPath: @"NSFMMove" + handler: nil], + "NSFileManager moves a file"); + PASS([mgr fileExistsAtPath: @"NSFMMove"], + "NSFileManager move destination exists"); + PASS(![mgr fileExistsAtPath: @"NSFMFile"], + "NSFileManager move source doesn't exist"); + { + NSData *dat1 = [mgr contentsAtPath: @"NSFMMove"]; + str2 = [[NSString alloc] initWithData: dat1 encoding: 1]; + PASS([str1 isEqualToString: str2],"NSFileManager moved file contents match"); + } + + if ([[NSProcessInfo processInfo] operatingSystem] + != NSWindowsNTOperatingSystem) + { + PASS([mgr createSymbolicLinkAtPath: @"NSFMLink" pathContent: @"NSFMMove"], + "NSFileManager creates a symbolic link"); + + PASS([mgr fileExistsAtPath: @"NSFMLink"], "link exists"); + + PASS([mgr removeFileAtPath: @"NSFMLink" handler: nil], + "NSFileManager removes a symbolic link"); + + PASS(![mgr fileExistsAtPath: @"NSFMLink"], + "NSFileManager removed link doesn't exist"); + + PASS([mgr fileExistsAtPath: @"NSFMMove"], + "NSFileManager removed link's target still exists"); + } + + PASS([mgr removeFileAtPath: @"NSFMMove" handler: nil], + "NSFileManager removes a file"); + + PASS(![mgr fileExistsAtPath: @"NSFMMove"], + "NSFileManager removed file doesn't exist"); + + PASS([mgr isReadableFileAtPath: @"NSFMCopy"], + "NSFileManager isReadableFileAtPath: works"); + PASS([mgr isWritableFileAtPath: @"NSFMCopy"], + "NSFileManager isWritableFileAtPath: works"); + PASS([mgr isDeletableFileAtPath: @"NSFMCopy"], + "NSFileManager isDeletableFileAtPath: works"); + PASS(![mgr isExecutableFileAtPath: @"NSFMCopy"], + "NSFileManager isExecutableFileAtPath: works"); + + PASS_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];, + NSInvalidArgumentException, + "NSFileManager -removeFileAtPath: @\".\" throws exception"); + + PASS([mgr createDirectoryAtPath: @"subdir" attributes: nil], + "NSFileManager can create a subdirectory"); + + PASS([mgr changeCurrentDirectoryPath: @"subdir"], + "NSFileManager can move into subdir"); + + { + BOOL isDir; + PASS([mgr createDirectoryAtPath: dirInDir + withIntermediateDirectories: NO + attributes: nil + error: NULL] == NO, + "NSFileManager refuses to create non-existent intermediate directories withIntermediateDirectories == NO"); + + PASS([mgr createDirectoryAtPath: dirInDir + withIntermediateDirectories: YES + attributes: nil + error: NULL], + "NSFileManager can create intermediate directories withIntermediateDirectories == YES"); + PASS([mgr fileExistsAtPath: dirInDir isDirectory: &isDir] && isDir == YES, + "NSFileManager create directory and intermediate directory that actually exist"); + + } + + PASS_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];, + NSInvalidArgumentException, + "NSFileManager -removeFileAtPath: @\".\" throws exception"); + + PASS_EXCEPTION([mgr removeFileAtPath: @".." handler: nil];, + NSInvalidArgumentException, + "NSFileManager -removeFileAtPath: @\"..\" throws exception"); +/* clean up */ + { + BOOL exists,isDir; + [mgr changeCurrentDirectoryPath: [[[mgr currentDirectoryPath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]]; + exists = [mgr fileExistsAtPath: dir isDirectory: &isDir]; + if (exists || isDir) + { + PASS([mgr removeFileAtPath: dir handler: nil], + "NSFileManager removes a directory"); + PASS(![mgr fileExistsAtPath: dir],"directory no longer exists"); + } + + isDir = NO; + } + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSFileManager/unrepresentable_filenames.m b/Tests/base/NSFileManager/unrepresentable_filenames.m new file mode 100644 index 000000000..e8ab12929 --- /dev/null +++ b/Tests/base/NSFileManager/unrepresentable_filenames.m @@ -0,0 +1,40 @@ +/* +copyright 2004 Alexander Malmberg +*/ + +#import "Testing.h" +#import +#import +#import +#import + +int main(int argc, char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSFileManager *fm=[NSFileManager defaultManager]; + NSArray *files; + int i; + BOOL e,d; + + files=[fm directoryContentsAtPath: @"."]; + printf("%i files\n",[files count]); + for (i=0;i<[files count];i++) + { + int j; + NSString *f=[files objectAtIndex: i]; + e=[fm fileExistsAtPath: f + isDirectory: &d]; + printf("%5i: %i %i %s\n",i,e,d, [f lossyCString]); + for (j=0;j<[f length];j++) + printf(" %3i: %04x\n",j,[f characterAtIndex: j]); + } + +/* const char *test="hallå.txt"; + NSString *s=[NSString stringWithCString: test]; + printf("s=%s\n", [s lossyCString]);*/ + + [arp release]; arp = nil; + + return 0; +} + diff --git a/Tests/base/NSHTTPCookie/TestInfo b/Tests/base/NSHTTPCookie/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSHTTPCookie/basic.m b/Tests/base/NSHTTPCookie/basic.m new file mode 100644 index 000000000..51e5297e5 --- /dev/null +++ b/Tests/base/NSHTTPCookie/basic.m @@ -0,0 +1,49 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSDictionary *dict; + NSArray *cookies; + NSURL *url; + NSHTTPCookie *cookie; + + TEST_FOR_CLASS(@"NSHTTPCookie", [NSHTTPCookie alloc], + "NSHTTPCookie +alloc returns an NSHTTPCookie"); + + dict = [NSDictionary dictionaryWithObjectsAndKeys: @"myname", @"Name", + @"myvalue", @"Value", @"/", @"Path", @".test.com", @"Domain", nil]; + cookie = [NSHTTPCookie cookieWithProperties: dict]; + TEST_FOR_CLASS(@"NSHTTPCookie", cookie, + "NSHTTPCookie +cookieWithProperties: returns an NSHTTPCookie"); + + dict = [NSDictionary dictionaryWithObjectsAndKeys: @"myname", @"Name", + @"myvalue", @"Value", @".test.com", @"Domain", nil]; + cookie = [NSHTTPCookie cookieWithProperties: dict]; + PASS(cookie == nil, "cookie without path returns nil"); + + dict = [NSDictionary dictionaryWithObject: + @"S=calendar=R7tjDKqNB5L8YTZSvf29Bg;Expires=Wed, 09-Mar-2011 23:00:35 GMT" + forKey: @"Set-Cookie"]; + + url = [NSURL URLWithString: @"http://www.google.com/calendar/feeds/default/"]; + cookies= [NSHTTPCookie cookiesWithResponseHeaderFields: dict forURL: url]; + TEST_FOR_CLASS(@"NSArray", cookies, + "NSHTTPCookie +cookiesWithResponseHeaderFields: returns an NSArray"); + PASS([cookies count ] == 1, "cookies array contains a cookie"); + cookie = [cookies objectAtIndex: 0]; + PASS([[cookie name] isEqual: @"S"], "NSHTTPCookie returns proper name"); + PASS([[cookie value] isEqual: @"calendar=R7tjDKqNB5L8YTZSvf29Bg"], + "NSHTTPCookie returns proper value"); + PASS([[cookie domain] isEqual: [url host]], + "NSHTTPCookie returns proper domain"); + + dict = [NSHTTPCookie requestHeaderFieldsWithCookies: cookies]; + PASS([[dict objectForKey: @"Cookie"] isEqual: @"S=calendar=R7tjDKqNB5L8YTZSvf29Bg"], + "NSHTTPCookie can generate proper cookie"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSHashTable/TestInfo b/Tests/base/NSHashTable/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSHashTable/basic.m b/Tests/base/NSHashTable/basic.m new file mode 100644 index 000000000..433186e26 --- /dev/null +++ b/Tests/base/NSHashTable/basic.m @@ -0,0 +1,20 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSHashTable *testObj; + + testObj = [[NSHashTable new] autorelease]; + [testObj addObject: @"hello"]; + test_alloc(@"NSHashTable"); + test_NSObject(@"NSHashTable", [NSArray arrayWithObject: testObj]); + test_NSCopying(@"NSHashTable",@"NSHashTable", + [NSArray arrayWithObject: testObj], NO, YES); + // test_NSCoding([NSArray arrayWithObject: testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSHashTable/create.m b/Tests/base/NSHashTable/create.m new file mode 100644 index 000000000..7f2975601 --- /dev/null +++ b/Tests/base/NSHashTable/create.m @@ -0,0 +1,34 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val1, *val2, *val3; + NSHashTable *obj, *old; + id vals[3]; + + val1 = @"Hello"; + val2 = @"Goodbye"; + val3 = @"Testing"; + + vals[0] = val1; + vals[1] = val2; + vals[2] = val3; + + obj = [[NSHashTable new] autorelease]; + PASS(obj != nil + && [obj isKindOfClass:[NSHashTable class]] + && [obj count] == 0, + "+new creates an empty hash table"); + + [obj addObject: (void*)@"hello"]; + PASS([obj count] == 1, "-addObject: increments count"); + PASS_EXCEPTION([obj addObject: nil];, + NSInvalidArgumentException, "-addObject: raises with nil"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSHashTable/general.m b/Tests/base/NSHashTable/general.m new file mode 100644 index 000000000..a599a2e20 --- /dev/null +++ b/Tests/base/NSHashTable/general.m @@ -0,0 +1,10 @@ +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSHost/TestInfo b/Tests/base/NSHost/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSHost/basic.m b/Tests/base/NSHost/basic.m new file mode 100644 index 000000000..12d49e6dd --- /dev/null +++ b/Tests/base/NSHost/basic.m @@ -0,0 +1,13 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_NSObject(@"NSHost",[NSArray arrayWithObject:[NSHost currentHost]]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSHost/create.m b/Tests/base/NSHost/create.m new file mode 100644 index 000000000..962c57d7c --- /dev/null +++ b/Tests/base/NSHost/create.m @@ -0,0 +1,37 @@ +#import "ObjectTesting.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSHost *current; + NSHost *localh; + NSHost *tmp; + + current = [NSHost currentHost]; + PASS(current != nil && [current isKindOfClass:[NSHost class]], + "NSHost understands +currentHost"); + +#if defined(GNUSTEP_BASE_LIBRARY) + localh = [NSHost localHost]; + PASS(localh != nil && [localh isKindOfClass:[NSHost class]], + "NSHost understands +localHost"); +#else + localh = current; +#endif + + tmp = [NSHost hostWithName:[current name]]; + PASS([tmp isEqualToHost:current], "NSHost understands +hostWithName:"); + + tmp = [NSHost hostWithAddress:[current address]]; + PASS([tmp isEqualToHost:current], "NSHost understands +hostWithAddress:"); + + tmp = [NSHost hostWithName:@"127.0.0.1"]; + PASS(tmp != nil && [tmp isEqualToHost:localh], + "NSHost understands [+hostWithName: 127.0.0.1]"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSIndexPath/TestInfo b/Tests/base/NSIndexPath/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSIndexPath/general.m b/Tests/base/NSIndexPath/general.m new file mode 100644 index 000000000..1d1befb53 --- /dev/null +++ b/Tests/base/NSIndexPath/general.m @@ -0,0 +1,79 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSIndexPath *index1; + NSIndexPath *index2; + NSUInteger i0[2]; + NSUInteger i1[2]; + + i0[0] = i1[1] = 0; + i0[1] = i1[0] = 1; + + index1 = [NSIndexPath indexPathWithIndex: 1]; + PASS(index1 != nil && + [index1 isKindOfClass:[NSIndexPath class]] && + [index1 length] == 1 && + [index1 indexAtPosition: 0] == 1, + "+indexPathWithIndex: works"); + + index2 = [NSIndexPath indexPathWithIndex: 1]; + PASS(index1 == index2, + "index path gives a shared instance"); + + PASS([index1 indexAtPosition: 1] == NSNotFound, + "indexAtPosition: with bad location gives NSNotFound"); + + index1 = [index1 indexPathByAddingIndex: 9]; + PASS([index1 length] == 2 + && [index1 indexAtPosition: 0] == 1 + && [index1 indexAtPosition: 1] == 9, + "indexPathByAddingIndex: works"); + + index1 = [index1 indexPathByRemovingLastIndex]; + PASS([index1 length] == 1 + && [index1 indexAtPosition: 0] == 1, + "indexPathByRemovingLastIndex works"); + + index1 = [NSIndexPath indexPathWithIndexes: i0 length: 2]; + PASS([index1 length] == 2 + && [index1 indexAtPosition: 0] == i0[0] + && [index1 indexAtPosition: 1] == i0[1], + "indexPathWithindexes:length: works"); + + index2 = [NSIndexPath indexPathWithIndexes: i1 length: 2]; + PASS([index1 length] == 2 + && [index1 indexAtPosition: 0] == i0[0] + && [index1 indexAtPosition: 1] == i0[1], + "indexPathWithindexes:length: works for another path"); + + PASS([index1 isEqual: index2] == NO, + "different index paths are not equal"); + + PASS([index1 compare: index2] == NSOrderedAscending, + "comparison one way works"); + PASS([index2 compare: index1] == NSOrderedDescending, + "comparison the other way works"); + index1 = [index1 indexPathByAddingIndex: 1]; + PASS([index1 compare: index2] == NSOrderedAscending, + "longer index1 comparison one way works"); + PASS([index2 compare: index1] == NSOrderedDescending, + "longer index1 comparison the other way works"); + index1 = [index1 indexPathByRemovingLastIndex]; + index2 = [index2 indexPathByAddingIndex: 1]; + PASS([index1 compare: index2] == NSOrderedAscending, + "longer index2 comparison one way works"); + PASS([index2 compare: index1] == NSOrderedDescending, + "longer index2 comparison the other way works"); + + [arp release]; arp = nil; + { + BOOL didNotSegfault = YES; + PASS(didNotSegfault, "+indexPathWithIndex: doesn't mess up memory"); + } + return 0; +} diff --git a/Tests/base/NSInvocation/GNUmakefile.preamble b/Tests/base/NSInvocation/GNUmakefile.preamble new file mode 100644 index 000000000..382fa2a2f --- /dev/null +++ b/Tests/base/NSInvocation/GNUmakefile.preamble @@ -0,0 +1,9 @@ + +ADDITIONAL_OBJCFLAGS += -I../GenericTests/ -I../../.. -Wall + +$(GNUSTEP_INSTANCE)_SUBPROJECTS = ../GenericTests + +SUBPROJECTS= ../GenericTests Resources + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSInvocation/InvokeProxyProtocol.h b/Tests/base/NSInvocation/InvokeProxyProtocol.h new file mode 100644 index 000000000..98ba5edf0 --- /dev/null +++ b/Tests/base/NSInvocation/InvokeProxyProtocol.h @@ -0,0 +1,50 @@ +/* InvokeProxyProtocol.h - protocol for simple target and proxy classes + + Written By: Adam Fedor +*/ +#import +#import + +typedef struct { + char c; + int i; +} smallStruct; + +typedef struct { + int i; + char *s; + float f; +} largeStruct; + +@protocol InvokeTarget +- (char) loopChar: (char)v; +- (double) loopDouble: (double)v; +- (float) loopFloat: (float)v; +- (int) loopInt: (int)v; +- (largeStruct) loopLarge: (largeStruct)v; +- (long) loopLong: (long)v; +- (largeStruct) loopLargePtr: (largeStruct*)v; +- (id) loopObject: (id)v; +- (NSRect) loopRect: (NSRect)v; +- (short) loopShort: (short)v; +- (smallStruct) loopSmall: (smallStruct)v; +- (smallStruct) loopSmallPtr: (smallStruct*)v; +- (char*) loopString: (char*)v; + +- (char) retChar; +- (double) retDouble; +- (float) retFloat; +- (int) retInt; +- (largeStruct) retLarge; +- (long) retLong; +- (id) retObject; +- (short) retShort; +- (smallStruct) retSmall; +- (char*) retString; +@end + +@protocol InvokeProxy +- (id) initWithTarget: (id)target; +@end + + diff --git a/Tests/base/NSInvocation/Resources/GNUmakefile b/Tests/base/NSInvocation/Resources/GNUmakefile new file mode 100644 index 000000000..849670e78 --- /dev/null +++ b/Tests/base/NSInvocation/Resources/GNUmakefile @@ -0,0 +1,8 @@ +include $(GNUSTEP_MAKEFILES)/common.make +BUNDLE_NAME=InvokeProxy +InvokeProxy_OBJC_FILES=InvokeProxy.m +InvokeProxy_NEEDS_GUI = NO +include $(GNUSTEP_MAKEFILES)/bundle.make +include $(GNUSTEP_MAKEFILES)/test-tool.make + +check:: all diff --git a/Tests/base/NSInvocation/Resources/InvokeProxy.h b/Tests/base/NSInvocation/Resources/InvokeProxy.h new file mode 100644 index 000000000..3f6587ccf --- /dev/null +++ b/Tests/base/NSInvocation/Resources/InvokeProxy.h @@ -0,0 +1,55 @@ +/* InvokeProxy.h - Definitions for simple target and proxy classes + + Written By: Adam Fedor +*/ +#include +#include + +typedef struct { + char c; + int i; +} smallStruct; + +typedef struct { + int i; + char *s; + float f; +} largeStruct; + +@interface InvokeTarget: NSObject +- (char) loopChar: (char)v; +- (double) loopDouble: (double)v; +- (float) loopFloat: (float)v; +- (int) loopInt: (int)v; +- (largeStruct) loopLarge: (largeStruct)v; +- (long) loopLong: (long)v; +- (largeStruct) loopLargePtr: (largeStruct*)v; +- (id) loopObject: (id)v; +- (short) loopShort: (short)v; +- (NSRect) loopRect: (NSRect)v; +- (smallStruct) loopSmall: (smallStruct)v; +- (smallStruct) loopSmallPtr: (smallStruct*)v; +- (char*) loopString: (char*)v; + +- (char) retChar; +- (double) retDouble; +- (float) retFloat; +- (int) retInt; +- (largeStruct) retLarge; +- (long) retLong; +- (id) retObject; +- (short) retShort; +- (smallStruct) retSmall; +- (char*) retString; +@end + +@interface InvokeProxy : NSObject +{ + id obj; +} + +- (id) initWithTarget: (id)target; + +@end + + diff --git a/Tests/base/NSInvocation/Resources/InvokeProxy.m b/Tests/base/NSInvocation/Resources/InvokeProxy.m new file mode 100644 index 000000000..f19a1de35 --- /dev/null +++ b/Tests/base/NSInvocation/Resources/InvokeProxy.m @@ -0,0 +1,165 @@ +/* InvokeProxy.h - Implementation of simple target and proxy classes + + Written By: Adam Fedor +*/ +#include "InvokeProxy.h" +#include +#include +#include +#include +//#include "GNUstepGuile/gstep_guile.h" + +@implementation InvokeTarget + +- (char) loopChar: (char)v +{ + return v+1; +} +- (double) loopDouble: (double)v +{ + return v+1.0; +} +- (float) loopFloat: (float)v +{ + return v+1.0; +} +- (int) loopInt: (int)v +{ + return v+1; +} +- (largeStruct) loopLarge: (largeStruct)v +{ + v.i += 1; + return v; +} +- (long) loopLong: (long)v +{ + return v+1; +} +- (largeStruct) loopLargePtr: (largeStruct*)v +{ + return *v; +} +- (id) loopObject: (id)v +{ + return v; +} +- (short) loopShort: (short)v +{ + return v+1; +} +- (smallStruct) loopSmall: (smallStruct)v +{ + v.i += 1; + return v; +} +- (NSRect) loopRect: (NSRect)v +{ + return v; +} +- (smallStruct) loopSmallPtr: (smallStruct*)v +{ + return *v; +} +- (char*) loopString: (char*)v +{ + v[0] += 1; + return v; +} + +- (char) retChar +{ + return (char)99; +} +- (double) retDouble +{ + return 123.456; +} +- (float) retFloat +{ + return 123.456; +} +- (int) retInt +{ + return 123456; +} +- (largeStruct) retLarge +{ + static largeStruct l = { + 99, "largeStruct", 99.99 + }; + return l; +} +- (long) retLong +{ + return 123456; +} +- (id) retObject +{ + return self; +} +- (short) retShort +{ + return 12345; +} +- (smallStruct) retSmall +{ + static smallStruct s = { + 11, 22 + }; + return s; +} +- (char*) retString +{ + return "string"; +} + +- (id) returnIdButThrowException +{ + [NSException raise: @"AnException" format: @"Deliberately thrown"]; + return @"This string should not be returned"; +} + +@end + +@implementation InvokeProxy +#if 0 ++ (void) load +{ + /* Make sure these classes are defined within gstep-guile, so tests + can find them */ +#define CCLS(X) gh_define(#X, gstep_id2scm([X class], NO)) + CCLS(InvokeTarget); + CCLS(InvokeProxy); +} +#endif +- (id) initWithTarget: (id)target +{ + obj = target; + return self; +} + +- (void) forwardInvocation: (NSInvocation*)inv +{ +#if 1 + [inv invokeWithTarget: obj]; +#else + NSData *d = [NSArchiver archivedDataWithRootObject: inv]; + NSInvocation *i = [NSUnarchiver unarchiveObjectWithData: d]; + unsigned l; + void *b; + + [i invokeWithTarget: obj]; + d = [NSArchiver archivedDataWithRootObject: i]; + i = [NSUnarchiver unarchiveObjectWithData: d]; + l = [[i methodSignature] methodReturnLength]; + b = (void *)malloc(l); + [i getReturnValue: b]; + [inv setReturnValue: b]; + free(b); +#endif +} + +@end + + diff --git a/Tests/base/NSInvocation/TestInfo b/Tests/base/NSInvocation/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSInvocation/basic.m b/Tests/base/NSInvocation/basic.m new file mode 100644 index 000000000..e1694257d --- /dev/null +++ b/Tests/base/NSInvocation/basic.m @@ -0,0 +1,14 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMethodSignature *testSig = [NSMethodSignature signatureWithObjCTypes:"@@::"]; + NSInvocation *testObj = [NSInvocation invocationWithMethodSignature:testSig]; + test_alloc(@"NSInvocation"); + test_NSObject(@"NSInvocation", [NSArray arrayWithObject:testObj]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSInvocation/general.m b/Tests/base/NSInvocation/general.m new file mode 100644 index 000000000..77f38b782 --- /dev/null +++ b/Tests/base/NSInvocation/general.m @@ -0,0 +1,212 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import "InvokeProxyProtocol.h" + +/* these macros should only be used in the scope of main */ +#define TEST_INVOKE(selx) \ + { \ + NS_DURING \ + NSMethodSignature *sig = nil; \ + sig = [tar methodSignatureForSelector:selx]; \ + inv = [NSInvocation invocationWithMethodSignature:sig]; \ + [inv setSelector:selx]; \ + [inv invokeWithTarget:tar]; \ + PASS(1,"Invoke %s",[NSStringFromSelector(selx) cString]); \ + NS_HANDLER \ + PASS(0,"Invoke %s",[NSStringFromSelector(selx) cString]); \ + [localException raise]; \ + NS_ENDHANDLER \ + } + +#define TEST_INVOKE_ARG(selx,argp) \ + { \ + NS_DURING \ + NSMethodSignature *sig = nil; \ + sig = [tar methodSignatureForSelector:selx]; \ + inv = [NSInvocation invocationWithMethodSignature:sig]; \ + [inv setSelector:selx]; \ + [inv setArgument:argp atIndex:2]; \ + [inv invokeWithTarget:tar]; \ + PASS(1,"Invoke %s",[NSStringFromSelector(selx) cString]); \ + NS_HANDLER \ + PASS(0,"Invoke %s",[NSStringFromSelector(selx) cString]); \ + [localException raise]; \ + NS_ENDHANDLER \ + } + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSInvocation *inv = nil; + NSObject *tar; + NSObject *pxy; + char cret,carg; + short sret,sarg; + int iret,iarg; + long lret,larg; + float fret,farg; + double dret,darg; + NSRect rret, rarg, rprx; + id oret,oarg; + char *cpret,*cparg,*cparg2; + smallStruct ssret,ssarg; + largeStruct lsret,lsarg; + Class tClass = Nil; + Class pClass = Nil; + NSString *bundlePath; + NSBundle *bundle; + + bundlePath = [[[NSFileManager defaultManager] + currentDirectoryPath] + stringByAppendingPathComponent:@"Resources"]; + bundlePath = [[NSBundle bundleWithPath:bundlePath] + pathForResource:@"InvokeProxy" + ofType:@"bundle"]; + bundle = [NSBundle bundleWithPath:bundlePath]; + PASS([bundle load], + "loading resources from bundle"); + tClass = NSClassFromString(@"InvokeTarget"); + pClass = NSClassFromString(@"InvokeProxy"); + + + tar = [tClass new]; + pxy = [[pClass alloc] initWithTarget:tar]; + TEST_INVOKE(@selector(retChar)); + [inv getReturnValue:&cret]; + PASS(cret == 99 && + [pxy retChar] == 99, + "Can return chars"); + + TEST_INVOKE(@selector(retShort)); + [inv getReturnValue:&sret]; + PASS(sret == 12345 && + [pxy retShort] == 12345, + "Can return short"); + + TEST_INVOKE(@selector(retInt)); + [inv getReturnValue:&iret]; + PASS(iret == 123456 && + [pxy retInt] == 123456, + "Can return int"); + + TEST_INVOKE(@selector(retLong)); + [inv getReturnValue:&lret]; + PASS(lret == 123456 && + [pxy retLong] == 123456, + "Can return long"); + + TEST_INVOKE(@selector(retFloat)); + [inv getReturnValue:&fret]; + PASS(fabs(123.456 - fret) <= 0.001 && + fabs(123.456 - [pxy retFloat]) <= 0.001, + "Can return float"); + + TEST_INVOKE(@selector(retDouble)); + [inv getReturnValue:&dret]; + PASS(fabs(123.456 - dret) <= 0.001 && + fabs(123.456 - [pxy retDouble]) <= 0.001, + "Can return double"); + + TEST_INVOKE(@selector(retObject)); + [inv getReturnValue:&oret]; + PASS(oret == tar && + tar == [pxy retObject], + "Can return object"); + + carg = 1; + TEST_INVOKE_ARG(@selector(loopChar:),&carg); + [inv getReturnValue:&cret]; + PASS(cret == 2 && + 2 == [pxy loopChar:carg], + "Can send/return chars"); + + sarg = 1; + TEST_INVOKE_ARG(@selector(loopShort:),&sarg); + [inv getReturnValue:&sret]; + PASS(sret == 2 && + [pxy loopShort:sarg] == 2, + "Can send/return shorts"); + + iarg = 1; + TEST_INVOKE_ARG(@selector(loopInt:),&iarg); + [inv getReturnValue:&iret]; + PASS(iret == 2 && + [pxy loopInt:iarg] == 2, + "Can send/return ints"); + + larg = 1; + TEST_INVOKE_ARG(@selector(loopLong:),&larg); + [inv getReturnValue:&lret]; + PASS(lret == 2 && + [pxy loopLong:larg] == 2, + "Can send/return longs"); + + farg = 1; + TEST_INVOKE_ARG(@selector(loopFloat:),&farg); + [inv getReturnValue:&fret]; + PASS(fabs(2 - fret) <= 0.001 && + fabs(2 - [pxy loopFloat:farg]) <= 0.001, + "Can send/return floats"); + + darg = 1; + TEST_INVOKE_ARG(@selector(loopDouble:),&darg); + [inv getReturnValue:&dret]; + PASS(fabs(2 - dret) <= 0.001 && + fabs(2 - [pxy loopFloat:darg]) <= 0.001, + "Can send/return double"); + + oarg = pxy; + TEST_INVOKE_ARG(@selector(loopObject:),&oarg); + [inv getReturnValue:&oret]; + PASS(oret == pxy && + [pxy loopObject:oarg] == pxy, + "Can send/return objects"); + + /* unlinke the rest of these loopString: modifies its arg */ + cparg = malloc(sizeof("Hello There")); + strcpy(cparg,"Hello There"); + cparg2 = malloc(sizeof("Hello There")); + strcpy(cparg2,"Hello There"); + + TEST_INVOKE_ARG(@selector(loopString:),&cparg); + [inv getReturnValue:&cpret]; + PASS(strcmp(cpret,"Iello There") == 0 && + strcmp([pxy loopString:cparg2],"Iello There") == 0, + "Can send/return char *"); + + ssarg.c = 7; + ssarg.i = 9; + TEST_INVOKE_ARG(@selector(loopSmall:),&ssarg); + [inv getReturnValue:&ssret]; + PASS(ssret.c == 7 && ssret.i == 10, + "Can send/return small structs"); + + lsarg.i = 8; + lsarg.s = "Hello"; + lsarg.f = 11.0; + TEST_INVOKE_ARG(@selector(loopLarge:),&lsarg); + [inv getReturnValue:&lsret]; + PASS(lsret.i == 9 && + lsret.s == "Hello" && + lsret.f == 11.0, + "Can send/return large structs"); + + rarg = NSMakeRect(1,2,3,4); + TEST_INVOKE_ARG(@selector(loopRect:),&rarg); + [inv getReturnValue:&rret]; + rprx = [pxy loopRect:rarg]; + PASS(NSEqualRects(rret, rarg) && NSEqualRects(rprx, rarg), + "Can send/return NSRect"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSInvocation/test01.m b/Tests/base/NSInvocation/test01.m new file mode 100644 index 000000000..efda9f3f8 --- /dev/null +++ b/Tests/base/NSInvocation/test01.m @@ -0,0 +1,104 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import "InvokeProxyProtocol.h" +#import +#import +#import +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSInvocation *inv = nil; + NSObject *tar; + NSMethodSignature *sig; + id ret; + Class tClass = Nil; + NSString *bundlePath; + NSBundle *bundle; + int retc; + bundlePath = [[[NSFileManager defaultManager] + currentDirectoryPath] + stringByAppendingPathComponent:@"Resources"]; + bundlePath = [[NSBundle bundleWithPath:bundlePath] + pathForResource:@"InvokeProxy" + ofType:@"bundle"]; + bundle = [NSBundle bundleWithPath:bundlePath]; + PASS([bundle load], + "loading resources from bundle"); + tClass = NSClassFromString(@"InvokeTarget"); + + + tar = [tClass new]; + + /* + Test if the return value is retained. It is in the Apple OpenStep edition + for Windows (YellowBox) + matt: this doesn't seem like a valid test as PASS/fail will vary on + platforms + */ + sig = [tar methodSignatureForSelector:@selector(retObject)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + retc = [[tar retObject] retainCount]; + [inv setSelector:@selector(retObject)]; + [inv invokeWithTarget:tar]; + if (nil == [NSGarbageCollector defaultCollector]) + { + PASS(retc + 1 == [[tar retObject] retainCount], + "Retain return value") + } + + sig = [tar methodSignatureForSelector:@selector(loopObject:)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + retc = [tar retainCount]; + [inv setSelector:@selector(loopObject:)]; + [inv invokeWithTarget:tar]; + [inv retainArguments]; + [inv setArgument:&tar atIndex:2]; + if (nil == [NSGarbageCollector defaultCollector]) + { + PASS(retc + 1 == [tar retainCount], + "Will Retain arguments after -retainArguments") + } + + sig = [tar methodSignatureForSelector:@selector(loopObject:)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + retc = [tar retainCount]; + [inv setSelector:@selector(loopObject:)]; + [inv invokeWithTarget:tar]; + [inv setArgument:&tar atIndex:2]; + PASS(retc == [tar retainCount], + "default will not retain arguments"); + + sig = [tar methodSignatureForSelector:@selector(retObject)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + [inv setSelector:@selector(retObject)]; + [inv invokeWithTarget:nil]; + [inv getReturnValue:&ret]; + PASS(ret == nil,"Check if nil target works"); + + sig = [tar methodSignatureForSelector:@selector(returnIdButThrowException)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + [inv setSelector:@selector(returnIdButThrowException)]; + PASS_EXCEPTION([inv invokeWithTarget:tar];,@"AnException","Exception in invocation #1"); + PASS_EXCEPTION([inv getReturnValue:&ret];,NSGenericException,"Exception getting return value #1"); + + /* same as above but with a successful call first */ + sig = [tar methodSignatureForSelector:@selector(returnIdButThrowException)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + [inv setSelector:@selector(retObject)]; + + [inv invokeWithTarget:tar]; /* these two lines */ + [inv getReturnValue:&ret]; + + [inv setSelector:@selector(returnIdButThrowException)]; + PASS_EXCEPTION([inv invokeWithTarget:tar];,@"AnException","Exception in invocation #2"); + PASS_EXCEPTION([inv getReturnValue:&ret];,NSGenericException,"Exception getting return value #2"); + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSKeyedArchiver/TestInfo b/Tests/base/NSKeyedArchiver/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSKeyedArchiver/basic.m b/Tests/base/NSKeyedArchiver/basic.m new file mode 100644 index 000000000..d5272c66f --- /dev/null +++ b/Tests/base/NSKeyedArchiver/basic.m @@ -0,0 +1,13 @@ +#import +#import "ObjectTesting.h" +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_alloc_only(@"NSKeyedArchiver"); + test_NSObject(@"NSKeyedArchiver",[NSArray arrayWithObject:[[NSKeyedArchiver alloc] initForWritingWithMutableData: [NSMutableData data]]]); + test_alloc_only(@"NSKeyedUnarchiver"); + test_NSObject(@"NSKeyedUnarchiver",[NSArray arrayWithObject:[[NSKeyedUnarchiver alloc] initForReadingWithData: [NSKeyedArchiver archivedDataWithRootObject: [NSData data]]]]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSKeyedArchiver/create.m b/Tests/base/NSKeyedArchiver/create.m new file mode 100644 index 000000000..25f57fda9 --- /dev/null +++ b/Tests/base/NSKeyedArchiver/create.m @@ -0,0 +1,25 @@ +#import +#import +#import +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id obj; + NSMutableData *data1; + + obj = [NSKeyedArchiver alloc]; + data1 = [NSMutableData dataWithLength: 0]; + obj = [obj initForWritingWithMutableData: data1]; + PASS((obj != nil && [obj isKindOfClass:[NSKeyedArchiver class]]), "-initForWritingWithMutableData seems ok"); + + PASS_EXCEPTION([[NSUnarchiver alloc] initForReadingWithData:nil];, + @"NSInvalidArgumentException", + "Creating an NSUnarchiver with nil data throws an exception"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSKeyedArchiver/general.m b/Tests/base/NSKeyedArchiver/general.m new file mode 100644 index 000000000..c734df56f --- /dev/null +++ b/Tests/base/NSKeyedArchiver/general.m @@ -0,0 +1,89 @@ +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val1, *val2, *val3, *s; + NSNumber *val4; + NSArray *vals1, *vals2; + NSData *data1; + NSMutableData *data2; + NSArray *a; + NSURL *u; + NSMutableSet *ms; + NSKeyedArchiver *archiver = nil; + NSKeyedUnarchiver *unarchiver = nil; + + u = [NSURL URLWithString: @"http://www.w3.org/"]; + ms = [NSMutableSet set]; + [ms addObject: u]; + data2 = [NSMutableData new]; + archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData: data2]; + [archiver setOutputFormat: NSPropertyListXMLFormat_v1_0]; + [archiver encodeObject: ms forKey: @"root"]; + [archiver finishEncoding]; + NSLog(@"%*.*s", [data2 length], [data2 length], [data2 bytes]); + ms = [NSKeyedUnarchiver unarchiveObjectWithData: data2]; + PASS([[[ms anyObject] absoluteString] isEqual: @"http://www.w3.org/"], + "Can archive and restore a URL"); + + [archiver release]; + [data2 release]; + + + PASS_RUNS(val1 = [NSString stringWithCString:"Archiver.dat"]; + val2 = [NSString stringWithCString:"A Goodbye"]; + val3 = [NSString stringWithCString:"Testing all strings"]; + val4 = [NSNumber numberWithUnsignedInt: 100]; + vals1 = [[[NSArray arrayWithObject:val1] + arrayByAddingObject:val2] + arrayByAddingObject: val4]; + vals2 = [vals1 arrayByAddingObject: val2];, + "We can build basic strings and arrays for tests"); + + PASS([NSKeyedArchiver archiveRootObject:vals2 toFile:val1], + "archiveRootObject:toFile: seems ok"); + + data1 = [NSKeyedArchiver archivedDataWithRootObject:vals2]; + PASS((data1 != nil && [data1 length] != 0), + "archivedDataWithRootObject: seems ok"); + + a = [NSKeyedUnarchiver unarchiveObjectWithData:data1]; + NSLog(@"From data: original array %@, decoded array %@",vals2, a); + PASS((a != nil && [a isKindOfClass:[NSArray class]] && [a isEqual:vals2]), + "unarchiveObjectWithData: seems ok"); + + a = [NSKeyedUnarchiver unarchiveObjectWithFile:val1]; + NSLog(@"From file: original array %@, decoded array %@",vals2, a); + PASS((a != nil && [a isKindOfClass:[NSArray class]] && [a isEqual:vals2]), + "unarchiveObjectWithFile: seems ok"); + + // encode + data2 = [[NSMutableData alloc] initWithCapacity: 10240]; + archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData: data2]; + [archiver encodeObject: val3 forKey: @"string"]; + [archiver finishEncoding]; + + // decode... + unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData: data2]; + s = [[unarchiver decodeObjectForKey: @"string"] retain]; + PASS((s != nil && [s isKindOfClass:[NSString class]] && [s isEqual: val3]), + "encodeObject:forKey: seems okay"); + [data2 release]; + + NSLog(@"Original string: %@, unarchived string: %@",val3, s); + + [[NSFileManager defaultManager] removeFileAtPath: val1 handler: nil]; + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSLocale/TestInfo b/Tests/base/NSLocale/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSLocale/basic.m b/Tests/base/NSLocale/basic.m new file mode 100644 index 000000000..e95849134 --- /dev/null +++ b/Tests/base/NSLocale/basic.m @@ -0,0 +1,27 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import + +#if defined(GS_USE_ICU) +#define NSLOCALE_SUPPORTED GS_USE_ICU +#else +#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main() +{ + START_SET("NSLocale") + id testObj; + + if (!NSLOCALE_SUPPORTED) + SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built") + + testObj = [NSLocale currentLocale]; + test_NSObject(@"NSLocale", [NSArray arrayWithObject: testObj]); + test_keyed_NSCoding([NSArray arrayWithObject: testObj]); + test_NSCopying(@"NSLocale", @"NSLocale", + [NSArray arrayWithObject: testObj], NO, NO); + + END_SET("NSLocale") + return 0; +} diff --git a/Tests/base/NSLocale/create.m b/Tests/base/NSLocale/create.m new file mode 100644 index 000000000..4181fd703 --- /dev/null +++ b/Tests/base/NSLocale/create.m @@ -0,0 +1,29 @@ +#import +#import +#import "ObjectTesting.h" + +#if defined(GS_USE_ICU) +#define NSLOCALE_SUPPORTED GS_USE_ICU +#else +#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main(void) +{ + START_SET("NSLocale") + NSLocale *locale; + + if (!NSLOCALE_SUPPORTED) + SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built") + locale = [NSLocale systemLocale]; + PASS (locale != nil, "+systemLocale returns non-nil"); + TEST_FOR_CLASS(@"NSLocale", locale, "+systemLocale return a NSLocale"); + + locale = [NSLocale currentLocale]; + PASS (locale != nil, "+currentLocale return non-nil"); + TEST_FOR_CLASS(@"NSLocale", locale, "+currentLocale return a NSLocale"); + + END_SET("NSLocale") + + return 0; +} diff --git a/Tests/base/NSLocale/general.m b/Tests/base/NSLocale/general.m new file mode 100644 index 000000000..3b0865b70 --- /dev/null +++ b/Tests/base/NSLocale/general.m @@ -0,0 +1,133 @@ +#import +#import +#import +#import "ObjectTesting.h" + +#if defined(GS_USE_ICU) +#define NSLOCALE_SUPPORTED GS_USE_ICU +#else +#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main(void) +{ + START_SET("NSLocale") + + NSLocale *locale; + id o; + unichar u; + + if (!NSLOCALE_SUPPORTED) + SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built") + + // These tests don't really work all that well. I need to come up with + // something better. Most of the ones that fail are because nil is returned. + locale = [[NSLocale alloc] initWithLocaleIdentifier: @"es_ES_PREEURO"]; + PASS_EQUAL([locale objectForKey: NSLocaleIdentifier], + @"es_ES@currency=ESP", + "NSLocaleIdentifier key returns 'es_ES@currency=ESP'"); + PASS_EQUAL([locale objectForKey: NSLocaleLanguageCode], + @"es", + "NSLocaleLanguageCode key returns 'es'"); + PASS_EQUAL([locale objectForKey: NSLocaleCountryCode], + @"ES", + "NSLocaleCountryCode key returns 'ES'"); + + PASS_EQUAL([locale objectForKey: NSLocaleScriptCode], nil, + "NSLocaleScriptCode key returns nil"); + PASS_EQUAL([locale objectForKey: NSLocaleVariantCode], nil, + "NSLocaleVariantCode key returns nil"); + PASS_EQUAL([locale objectForKey: NSLocaleCollationIdentifier], nil, + "NSLocaleCollationIdentifier key returns nil"); + TEST_FOR_CLASS(@"NSCharacterSet", + [locale objectForKey: NSLocaleExemplarCharacterSet], + "NSLocaleExemplarCharacterSet key returns a NSCharacterSet"); + TEST_FOR_CLASS(@"NSCalendar", [locale objectForKey: NSLocaleCalendar], + "NSLocaleCalendar key returns a NSCalendar"); + o = [locale objectForKey: NSLocaleUsesMetricSystem]; + TEST_FOR_CLASS(@"NSNumber", o, + "NSLocaleUsesMetricSystem key returns a NSNumber"); + PASS_EQUAL(o, [NSNumber numberWithBool: YES], + "NSLocaleUsesMetricSystem key returns YES"); + PASS_EQUAL([locale objectForKey: NSLocaleMeasurementSystem], + @"Metric", + "NSLocaleMeasurementSystem key returns 'Metric'"); + PASS_EQUAL([locale objectForKey: NSLocaleDecimalSeparator], + @",", + "NSLocaleDecimalSeparator key returns ','"); + PASS_EQUAL([locale objectForKey: NSLocaleGroupingSeparator], + @".", + "NSLocaleGroupingSeparator key returns '.'"); + u = 8359; + PASS_EQUAL([locale objectForKey: NSLocaleCurrencySymbol], + [NSString stringWithCharacters: &u length: 1], + "NSLocaleCurrencySymbol key returns 'xx3'"); + PASS_EQUAL([locale objectForKey: NSLocaleCurrencyCode], + @"ESP", + "NSLocaleCurrencyCode key returns 'ESP'"); + PASS_EQUAL([locale objectForKey: NSLocaleCollatorIdentifier], + @"es_ES@currency=ESP", "NSLocaleCollatorIdentifier for Spain"); + u = 8216; + PASS_EQUAL([locale objectForKey: NSLocaleQuotationBeginDelimiterKey], + [NSString stringWithCharacters: &u length: 1], + "NSLocaleQuotationBeginDelimiterKey key works"); + u = 8217; + PASS_EQUAL([locale objectForKey: NSLocaleQuotationEndDelimiterKey], + [NSString stringWithCharacters: &u length: 1], + "NSLocaleQuotationEndDelimiterKey key returns 'xx6'"); + u = 8220; + PASS_EQUAL([locale objectForKey: NSLocaleAlternateQuotationBeginDelimiterKey], + [NSString stringWithCharacters: &u length: 1], + "NSLocaleAlternateQuotationBeginDelimiterKey key returns 'xx7'"); + u = 8221; + PASS_EQUAL([locale objectForKey: NSLocaleAlternateQuotationEndDelimiterKey], + [NSString stringWithCharacters: &u length: 1], + "NSLocaleAlternateQuotationEndDelimiterKey key returns 'xx8'"); + RELEASE(locale); + + locale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_US"]; + PASS_EQUAL([locale localeIdentifier], @"en_US", + "'en_US' is stored as 'en_US'."); + PASS_EQUAL([locale objectForKey: NSLocaleScriptCode], nil, + "en_US does not have script code"); + PASS_EQUAL([locale objectForKey: NSLocaleVariantCode], nil, + "en_US does not have variant code"); + PASS_EQUAL([locale objectForKey: NSLocaleCollationIdentifier], nil, + "en_US does not have a collation identifier"); + PASS ([[locale objectForKey: NSLocaleUsesMetricSystem] boolValue] == NO, + "en_US does not use the metric system"); + RELEASE(locale); + + locale = [[NSLocale alloc] initWithLocaleIdentifier: @"zh-Hant_TW"]; + PASS_EQUAL([locale objectForKey: NSLocaleCountryCode], @"TW", + "zh-Hant_TW country code is zh"); + PASS_EQUAL([locale objectForKey: NSLocaleLanguageCode], @"zh", + "zh-Hant_TW language code is zh"); + PASS_EQUAL([locale localeIdentifier], @"zh_TW", + "'zh-Hant_TW' is stored as 'zh_TW'"); + PASS_EQUAL([locale objectForKey: NSLocaleScriptCode], nil, + "zh-Hant_TW has no script code"); + RELEASE(locale); + + PASS_EQUAL([NSLocale canonicalLocaleIdentifierFromString: nil], nil, + "Canonical identifier for nil is nil"); + PASS_EQUAL([NSLocale canonicalLocaleIdentifierFromString: @""], @"", + "Canonical identifier for an empty string is an empty string"); + PASS_EQUAL([NSLocale canonicalLocaleIdentifierFromString: @"some rubbish"], + @"some rubbish", + "Canonical identifier for 'some rubbish is 'some rubbish'"); + + /* Let's just hope the next two PASS. + */ + testHopeful = YES; + PASS_EQUAL([NSLocale canonicalLocaleIdentifierFromString: @"AmericanEnglish"], + @"americanenglish", + "Canonical identifier for 'AmericanEnglish is americanenglish"); + PASS_EQUAL([NSLocale canonicalLanguageIdentifierFromString: @"AmericanEnglish"], + @"americanenglish", + "Canonical language identifier for 'AmericanEnglish is americanenglish"); + + END_SET("NSLocale") + + return 0; +} diff --git a/Tests/base/NSLock/GNUmakefile.preamble b/Tests/base/NSLock/GNUmakefile.preamble new file mode 100644 index 000000000..cc5508093 --- /dev/null +++ b/Tests/base/NSLock/GNUmakefile.preamble @@ -0,0 +1,5 @@ + +SUBPROJECTS = Helpers + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSLock/Helpers/GNUmakefile b/Tests/base/NSLock/Helpers/GNUmakefile new file mode 100644 index 000000000..02faa30e2 --- /dev/null +++ b/Tests/base/NSLock/Helpers/GNUmakefile @@ -0,0 +1,15 @@ + +include $(GNUSTEP_MAKEFILES)/common.make + +TOOL_NAME = doubleNSLock doubleNSConditionLock + +doubleNSLock_OBJC_FILES = doubleNSLock.m +doubleNSLock_NEEDS_GUI = NO + +doubleNSConditionLock_OBJC_FILES = doubleNSConditionLock.m +doubleNSConditionLock_NEEDS_GUI = NO + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/tool.make +-include GNUmakefile.postamble + diff --git a/Tests/base/NSLock/Helpers/doubleNSConditionLock.m b/Tests/base/NSLock/Helpers/doubleNSConditionLock.m new file mode 100644 index 000000000..8eeeb70b5 --- /dev/null +++ b/Tests/base/NSLock/Helpers/doubleNSConditionLock.m @@ -0,0 +1,41 @@ + +#import +#import +#import +#import +#import + +@interface MyClass : NSObject ++ (void) run; +@end + +@implementation MyClass ++ (void) run +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSConditionLock *lock = [NSConditionLock new]; + + [lock lock]; + [lock lock]; + [arp release]; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + /* We need the user defaults system set up to allow NSLog to query it + * when logging the deadlock message, but if the main thread is + * sleeping then it can't get set up. So we set it up before we + * start the test. + */ + [NSUserDefaults standardUserDefaults]; + [NSThread detachNewThreadSelector: @selector(run) + toTarget: [MyClass class] + withObject: nil]; + [NSThread sleepForTimeInterval: 1.0]; + NSLog(@"Done."); + [arp release]; + return 0; +} diff --git a/Tests/base/NSLock/Helpers/doubleNSLock.m b/Tests/base/NSLock/Helpers/doubleNSLock.m new file mode 100644 index 000000000..59d244c21 --- /dev/null +++ b/Tests/base/NSLock/Helpers/doubleNSLock.m @@ -0,0 +1,41 @@ + +#import +#import +#import +#import +#import + +@interface MyClass : NSObject ++ (void) run; +@end + +@implementation MyClass ++ (void) run +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSLock *lock = [NSLock new]; + + [lock lock]; + [lock lock]; + [arp release]; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + /* We need the user defaults system set up to allow NSLog to query it + * when logging the deadlock message, but if the main thread is + * sleeping then it can't get set up. So we set it up before we + * start the test. + */ + [NSUserDefaults standardUserDefaults]; + [NSThread detachNewThreadSelector: @selector(run) + toTarget: [MyClass class] + withObject: nil]; + [NSThread sleepForTimeInterval: 1.0]; + NSLog(@"Done."); + [arp release]; + return 0; +} diff --git a/Tests/base/NSLock/RecursiveLock.m b/Tests/base/NSLock/RecursiveLock.m new file mode 100644 index 000000000..330d6117b --- /dev/null +++ b/Tests/base/NSLock/RecursiveLock.m @@ -0,0 +1,30 @@ +#import +#import "Testing.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + BOOL ret; + NSLock *lock = [NSRecursiveLock new]; + ret = [lock tryLock]; + if (ret) + [lock unlock]; + PASS(ret, "NSRecursiveLock with tryLock, then unlocking"); + + ASSIGN(lock,[NSRecursiveLock new]); + ret = [lock lockBeforeDate:[NSDate dateWithTimeIntervalSinceNow:1]]; + if (ret) + [lock unlock]; + PASS(ret, "NSRecursiveLock lockBeforeDate: works"); + + ASSIGN(lock,[NSRecursiveLock new]); + [lock tryLock]; + ret = [lock lockBeforeDate:[NSDate dateWithTimeIntervalSinceNow:1]]; + if (ret) + [lock unlock]; + PASS(ret, "NSRecursiveLock lockBeforeDate: with NSRecursiveLock returns YES"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSLock/TestInfo b/Tests/base/NSLock/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSLock/condlock.m b/Tests/base/NSLock/condlock.m new file mode 100644 index 000000000..e429535fd --- /dev/null +++ b/Tests/base/NSLock/condlock.m @@ -0,0 +1,95 @@ +#import +#import "Testing.h" + +@interface Queue : NSObject +{ + NSMutableArray *queue; + NSConditionLock *lock; +} +- (void) enqueue: (id)object; +- (id) dequeue; +@end + + +@implementation Queue + +- (id) init +{ + if (nil == (self = [super init])) { return nil; } + queue = [[NSMutableArray alloc] init]; + lock = [[NSConditionLock alloc] initWithCondition: 0]; + return self; +} + +- (void) enqueue: (id)object +{ + [lock lock]; + [queue addObject: object]; + [lock unlockWithCondition: 1]; +} + +- (id) dequeue +{ + id element; + NSUInteger count; + + [lock lockWhenCondition: 1]; + element = [[[queue objectAtIndex: 0] retain] autorelease]; + [queue removeObjectAtIndex: 0]; + count = [queue count]; + if (count > 0) + { + [lock unlockWithCondition: 1]; + } + else + { + [lock unlockWithCondition: 0]; + } + return element; +} +@end +NSMutableArray *received; +@interface Consumer : NSObject @end +@implementation Consumer +- (void) consumeFromQueue: (Queue*)q +{ + while (1) + { + id p = [NSAutoreleasePool new]; + + [received addObject: [q dequeue]]; + [p release]; + } +} +@end + +int main(void) +{ + [NSAutoreleasePool new]; + { + Queue *q = [Queue new]; + NSMutableArray *sent = [NSMutableArray new]; + received = [NSMutableArray new]; + unsigned int i; + [NSThread detachNewThreadSelector: @selector(consumeFromQueue:) + toTarget: [Consumer new] + withObject: q]; + for (i = 0; i < 10000; i++) + { + id obj = [NSNumber numberWithUnsignedInt: i]; + [sent addObject: obj]; + if (i % 10 == 0) + { + [NSThread sleepForTimeInterval: 0.0]; + } + if (i % 1000 == 0) + { + [NSThread sleepForTimeInterval: 1.0]; + } + [q enqueue: obj]; + } + [NSThread sleepForTimeInterval: 2.0]; + PASS([sent isEqual: received], "Condition lock"); + } + return 0; +} diff --git a/Tests/base/NSLock/doubleLocking.m b/Tests/base/NSLock/doubleLocking.m new file mode 100644 index 000000000..6f100915e --- /dev/null +++ b/Tests/base/NSLock/doubleLocking.m @@ -0,0 +1,95 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSFileManager *mgr; + NSString *helpers; + NSString *command; + NSTask *task; + NSPipe *ePipe; + NSFileHandle *hdl; + NSData *data; + NSString *string; + NSLock *lock = nil; + unsigned count; + + mgr = [NSFileManager defaultManager]; + helpers = [mgr currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + + command = [helpers stringByAppendingPathComponent: @"doubleNSLock"]; + task = [[NSTask alloc] init]; + ePipe = [[NSPipe pipe] retain]; + [task setLaunchPath: command]; + [task setStandardError: ePipe]; + hdl = [ePipe fileHandleForReading]; + [task launch]; + for (count = 0; count < 10 && [task isRunning]; count++) + { + [NSThread sleepForTimeInterval: 1.0]; + } + data = [hdl availableData]; + NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]); + string = [NSString alloc]; + string = [string initWithData: data encoding: NSISOLatin1StringEncoding]; + PASS([string rangeOfString: @"deadlock"].length > 0, + "NSLock reported deadlock as expected"); + if (NO == testPassed) + { + PASS(count == 10, "NSLock seems to have deadlocked as expected") + [task terminate]; + } + [task waitUntilExit]; + + command = [helpers stringByAppendingPathComponent: @"doubleNSConditionLock"]; + task = [[NSTask alloc] init]; + ePipe = [[NSPipe pipe] retain]; + [task setLaunchPath: command]; + [task setStandardError: ePipe]; + hdl = [ePipe fileHandleForReading]; + [task launch]; + for (count = 0; count < 10 && [task isRunning]; count++) + { + [NSThread sleepForTimeInterval: 1.0]; + } + data = [hdl availableData]; + NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]); + string = [NSString alloc]; + string = [string initWithData: data encoding: NSISOLatin1StringEncoding]; + PASS([string rangeOfString: @"deadlock"].length > 0, + "NSConditionLock reported deadlock as expected"); + if (NO == testPassed) + { + PASS(count == 10, "NSConditionLock seems to have deadlocked as expected") + [task terminate]; + } + [task waitUntilExit]; + + ASSIGN(lock,[NSRecursiveLock new]); + [lock lock]; + [lock lock]; + [lock unlock]; + [lock unlock]; + + ASSIGN(lock,[NSLock new]); + PASS([lock tryLock] == YES, "NSLock can tryLock"); + PASS([lock tryLock] == NO, "NSLock says NO for recursive tryLock"); + [lock unlock]; + + ASSIGN(lock,[NSConditionLock new]); + PASS([lock tryLock] == YES, "NSConditionLock can tryLock"); + PASS([lock tryLock] == NO, "NSConditionLock says NO for recursive tryLock"); + [lock unlock]; + + ASSIGN(lock,[NSRecursiveLock new]); + PASS([lock tryLock] == YES, "NSRecursiveLock can tryLock"); + PASS([lock tryLock] == YES, "NSRecursiveLock says YES for recursive tryLock"); + [lock unlock]; + + [arp release]; + return 0; +} diff --git a/Tests/base/NSLock/tryLock.m b/Tests/base/NSLock/tryLock.m new file mode 100644 index 000000000..b2edbedf4 --- /dev/null +++ b/Tests/base/NSLock/tryLock.m @@ -0,0 +1,78 @@ +#import +#import "Testing.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + BOOL ret; + id lock; + + lock = [NSLock new]; + ret = [lock tryLock]; + if (ret) + [lock unlock]; + PASS(ret, "NSLock with tryLock, then unlocking"); + + ASSIGN(lock,[NSLock new]); + [lock tryLock]; + ret = [lock tryLock]; + if (ret) + [lock unlock]; + PASS(ret == NO, "Recursive try lock with NSLock should return NO"); + + ASSIGN(lock,[NSConditionLock new]); + [lock lock]; + ret = [lock tryLock]; + if (ret) + [lock unlock]; + PASS(ret == NO, "Recursive try lock with NSConditionLock should return NO"); + + ret = [lock tryLockWhenCondition: 42]; + if (ret) + [lock unlock]; + PASS(ret == NO, "Recursive tryLockWhenCondition: with NSConditionLock (1) should return NO"); + [lock unlockWithCondition: 42]; + [lock lock]; + ret = [lock tryLockWhenCondition: 42]; + if (ret) + [lock unlock]; + PASS(ret == NO, "Recursive tryLockWhenCondition: with NSConditionLock (2) should return NO"); + + ASSIGN(lock,[NSRecursiveLock new]); + [lock tryLock]; + ret = [lock tryLock]; + if (ret) + [lock unlock]; + PASS(ret == YES, "Recursive try lock with NSRecursiveLock should return YES"); + + ASSIGN(lock,[NSLock new]); + ret = [lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 1]]; + if (ret) + [lock unlock]; + PASS(ret, "NSLock lockBeforeDate: works"); + + ASSIGN(lock,[NSLock new]); + [lock tryLock]; + ret = [lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 1]]; + if (ret) + [lock unlock]; + PASS(ret == NO, "Recursive lockBeforeDate: with NSLock returns NO"); + + ASSIGN(lock,[NSConditionLock new]); + [lock tryLock]; + ret = [lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 1]]; + if (ret) + [lock unlock]; + PASS(ret == NO, "Recursive lockBeforeDate: with NSConditionLock returns NO"); + + ASSIGN(lock,[NSRecursiveLock new]); + [lock tryLock]; + ret = [lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 1]]; + if (ret) + [lock unlock]; + PASS(ret == YES, "Recursive lockBeforeDate: with NSRecursiveLock returns YES"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMapTable/TestInfo b/Tests/base/NSMapTable/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMapTable/basic.m b/Tests/base/NSMapTable/basic.m new file mode 100644 index 000000000..a1b7baf85 --- /dev/null +++ b/Tests/base/NSMapTable/basic.m @@ -0,0 +1,20 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMapTable *testObj; + + testObj = [[NSMapTable new] autorelease]; + [testObj setObject: @"hello" forKey: @"there"]; + test_alloc(@"NSMapTable"); + test_NSObject(@"NSMapTable", [NSArray arrayWithObject: testObj]); + test_NSCopying(@"NSMapTable",@"NSMapTable", + [NSArray arrayWithObject: testObj], NO, YES); + // test_NSCoding([NSArray arrayWithObject: testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMapTable/create.m b/Tests/base/NSMapTable/create.m new file mode 100644 index 000000000..5cb70919c --- /dev/null +++ b/Tests/base/NSMapTable/create.m @@ -0,0 +1,36 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val1, *val2, *val3; + NSMapTable *obj, *old; + id vals[3]; + + val1 = @"Hello"; + val2 = @"Goodbye"; + val3 = @"Testing"; + + vals[0] = val1; + vals[1] = val2; + vals[2] = val3; + + obj = [[NSMapTable new] autorelease]; + PASS(obj != nil + && [obj isKindOfClass:[NSMapTable class]] + && [obj count] == 0, + "+new creates an empty hash table"); + + [obj setObject: val1 forKey: @"Key1"]; + PASS([obj count] == 1, "-setObject:forKey increments count"); + [obj setObject: nil forKey: @"Key2"]; + PASS([obj count] == 2, "-setObject:forKey: works with nil value"); + PASS_EXCEPTION([obj setObject: val1 forKey: nil];, + NSInvalidArgumentException, "-setObject:forKey: raises with nil key"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMapTable/general.m b/Tests/base/NSMapTable/general.m new file mode 100644 index 000000000..a599a2e20 --- /dev/null +++ b/Tests/base/NSMapTable/general.m @@ -0,0 +1,10 @@ +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMethodSignature/TestInfo b/Tests/base/NSMethodSignature/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMethodSignature/general.m b/Tests/base/NSMethodSignature/general.m new file mode 100644 index 000000000..226be9ede --- /dev/null +++ b/Tests/base/NSMethodSignature/general.m @@ -0,0 +1,384 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +#if GNUSTEP +#import + + +#define SRV_NAME @"nsmethodsignaturetest" + +struct _MyLargeStruct +{ + double first; + double second; +}; +typedef struct _MyLargeStruct MyLargeStruct; + +struct _MySmallStruct +{ + char first; +}; +typedef struct _MySmallStruct MySmallStruct; + +/*------------------------------------*/ +@interface MyClass : NSObject +-(void)void_void; +-(id)id_void; + +-(char)char_void; +-(unsigned char)uchar_void; +-(signed char)schar_void; + +-(short)short_void; +-(unsigned short)ushort_void; +-(signed short)sshort_void; + +-(int)int_void; +-(unsigned int)uint_void; +-(signed int)sint_void; + +-(long)long_void; +-(unsigned long)ulong_void; +-(signed long)slong_void; + +-(float)float_void; +-(double)double_void; + +-(MyLargeStruct)largeStruct_void; +-(MySmallStruct)smallStruct_void; + + + +-(void)void_id:(id)_id; + +-(void)void_char:(char)_char; +-(void)void_uchar:(unsigned char)_char; +-(void)void_schar:(signed char)_char; + +-(void)void_short:(short)_short; +-(void)void_ushort:(unsigned short)_short; +-(void)void_sshort:(signed short)_short; + +-(void)void_int:(int)_int; +-(void)void_uint:(unsigned int)_int; +-(void)void_sint:(signed int)_int; + +-(void)void_long:(long)_long; +-(void)void_ulong:(unsigned long)_long; +-(void)void_slong:(signed long)_long; + +-(void)void_float:(float)_float; +-(void)void_double:(double)_double; + +-(void)void_largeStruct:(MyLargeStruct)_str; +-(void)void_smallStruct:(MySmallStruct)_str; + +-(void)void_float:(float)_float double:(double)_double; +-(void)void_double:(double)_double float:(float)_float; + +-(MyLargeStruct)largeStruct_id:(id)_id + char:(char)_char + short:(short)_short + int:(int)_int + long:(long)_long + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr; +-(MySmallStruct)smallStruct_id:(id)_id + uchar:(unsigned char)_uchar + ushort:(unsigned short)_ushort + uint:(unsigned int)_uint + ulong:(unsigned long)_ulong + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr; + +-(const char *)runtimeSignatureForSelector:(SEL)selector; +@end + +@implementation MyClass +-(void)void_void {} +-(id)id_void { return 0; } + +-(char)char_void { return 0; } +-(unsigned char)uchar_void { return 0; } +-(signed char)schar_void { return 0; } + +-(short)short_void { return 0; } +-(unsigned short)ushort_void { return 0; } +-(signed short)sshort_void { return 0; } + +-(int)int_void { return 0; } +-(unsigned int)uint_void { return 0; } +-(signed int)sint_void { return 0; } + +-(long)long_void { return 0; } +-(unsigned long)ulong_void { return 0; } +-(signed long)slong_void { return 0; } + +-(float)float_void { return 0; } +-(double)double_void { return 0; } + +-(MyLargeStruct)largeStruct_void { MyLargeStruct str; return str; } +-(MySmallStruct)smallStruct_void { MySmallStruct str; return str; } + + + +-(void)void_id:(id)_id {} + +-(void)void_char:(char)_char {} +-(void)void_uchar:(unsigned char)_char {} +-(void)void_schar:(signed char)_char {} + +-(void)void_short:(short)_short {} +-(void)void_ushort:(unsigned short)_short {} +-(void)void_sshort:(signed short)_short {} + +-(void)void_int:(int)_int {} +-(void)void_uint:(unsigned int)_int {} +-(void)void_sint:(signed int)_int {} + +-(void)void_long:(long)_long {} +-(void)void_ulong:(unsigned long)_long {} +-(void)void_slong:(signed long)_long {} + +-(void)void_float:(float)_float {} +-(void)void_double:(double)_double {} + +-(void)void_largeStruct:(MyLargeStruct)_str {} +-(void)void_smallStruct:(MySmallStruct)_str {} + +-(void)void_float:(float)_float double:(double)_double {} +-(void)void_double:(double)_double float:(float)_float {} + + +-(MyLargeStruct)largeStruct_id:(id)_id + char:(char)_char + short:(short)_short + int:(int)_int + long:(long)_long + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr { return _lstr; } + +-(MySmallStruct)smallStruct_id:(id)_id + uchar:(unsigned char)_uchar + ushort:(unsigned short)_ushort + uint:(unsigned int)_uint + ulong:(unsigned long)_ulong + float:(float)_float + double:(double)_double + largeStruct:(MyLargeStruct)_lstr + smallStruct:(MySmallStruct)_sstr { return _sstr; } + +-(const char *)runtimeSignatureForSelector:(SEL)selector +{ + GSMethod meth = GSGetMethod(isa, selector, YES, YES); + return method_getTypeEncoding (meth); +} + +@end + +/*------------------------------------*/ + + +/* + This test is useful if the nsmethodsignatureserver is running which + was compiled with either a different GNUstep-base version or a different + version of gcc. It the server isn't found the test is skipped. +*/ +void +test_compare_server_signature(void) +{ + id objct = [MyClass new]; + id proxy = [NSConnection rootProxyForConnectionWithRegisteredName: SRV_NAME + host: nil]; + if (proxy) + { + const char *rmtSig; + const char *lclSig; + const char *msg; + +#define TEST_SEL(SELNAME) { \ + BOOL ok; \ + lclSig = [objct runtimeSignatureForSelector: @selector(SELNAME)]; \ + rmtSig = [proxy runtimeSignatureForSelector: @selector(SELNAME)]; \ + msg = [[NSString stringWithFormat: @"runtime: sel:%s\nlcl:%s\nrmt:%s", \ + GSNameFromSelector(@selector(SELNAME)), lclSig, rmtSig] UTF8String]; \ + ok = GSSelectorTypesMatch(lclSig, rmtSig); \ + PASS(ok, "%s", msg) \ + } + + TEST_SEL(void_void); + TEST_SEL(id_void); + TEST_SEL(char_void); + TEST_SEL(uchar_void); + TEST_SEL(schar_void); + TEST_SEL(short_void); + TEST_SEL(ushort_void); + TEST_SEL(sshort_void); + TEST_SEL(int_void); + TEST_SEL(uint_void); + TEST_SEL(sint_void); + TEST_SEL(long_void); + TEST_SEL(ulong_void); + TEST_SEL(slong_void); + TEST_SEL(float_void); + TEST_SEL(double_void); + TEST_SEL(largeStruct_void); + TEST_SEL(smallStruct_void); + + TEST_SEL(void_id:); + TEST_SEL(void_char:); + TEST_SEL(void_uchar:); + TEST_SEL(void_schar:); + TEST_SEL(void_short:); + TEST_SEL(void_ushort:); + TEST_SEL(void_sshort:); + TEST_SEL(void_int:); + TEST_SEL(void_uint:); + TEST_SEL(void_sint:); + TEST_SEL(void_long:); + TEST_SEL(void_ulong:); + TEST_SEL(void_slong:); + TEST_SEL(void_float:); + TEST_SEL(void_double:); + TEST_SEL(void_largeStruct:); + TEST_SEL(void_smallStruct:); + TEST_SEL(void_float:double:); + TEST_SEL(void_double:float:); + TEST_SEL(largeStruct_id:char:short:int:long:float:double:largeStruct:smallStruct:); + TEST_SEL(smallStruct_id:uchar:ushort:uint:ulong:float:double:largeStruct:smallStruct:); + + } + else + { + NSLog(@"Skipping test_compare_server_signature: proxy not found."); + } +} + +void +test_GSSelectorTypesMatch(void) +{ + const char *pairs[][2] = { {"@@::", "@12@0:4:8"}, + {"@@::", "@12@+0:+4:+8"}, + {"@@::", "@12@-0:-4:-8"}, + {"@12@0:4:8", "@@::"}, + {"@12@+0:+4:+8", "@@::"}, + {"@12@-0:-4:-8", "@@::"}, + + {"@12@0:4:8", "@12@+0:+4:+8"}, + {"@12@0:4:8", "@12@-0:-4:-8"}, + {"@12@+0:+4:+8", "@12@0:4:8"}, + {"@12@-0:-4:-8", "@12@0:4:8"}, + + {"@12@0:4:8", "@16@+4:+8:+12"}, + {"@12@0:4:8", "@16@-4:-8:-12"}, + {"@12@+0:+4:+8", "@16@4:8:12"}, + {"@12@-0:-4:-8", "@16@4:8:12"}, + +/* NB Use of a backslash in a ? ? = sequence below is to prevent the sequence + * from being interpreted as a trigraph by the compiler/preprocessor. + */ + {"{_MyLargeStruct2={_MyLargeStruct=dd}dd}@:", + "{?\?={?\?=dd}dd}16@0:4"}, + + {"{_MyLargeStruct=dd}56@+8:+12@+16c+23s+26i+28l24f28d32{_MyLargeStruct=dd}40{_MySmallStruct=c}44", + "{_MyLargeStruct=dd}46@+8:+12@+16c+17s+16i+20l+24f+28d24{_MyLargeStruct=dd}32{_MySmallStruct=c}45"}, + {"{_MyLargeStruct=dd}56@+8:+12@+16c+23s+26i+28l24f28d32{_MyLargeStruct=dd}40{_MySmallStruct=c}44", + "{?\?=dd}46@+8:+12@+16c+17s+16i+20l+24f+28d24{?\?=dd}32{?\?=c}45"}, + {0, 0} }; + unsigned int i = 0; + + while (pairs[i][0]) + { + const char *s; + BOOL ok; + + s = [[NSString stringWithFormat: @"pair %d matches:\n%s\n%s", + i, pairs[i][0], pairs[i][1]] UTF8String]; + ok = GSSelectorTypesMatch(pairs[i][0], pairs[i][1]); + PASS(ok, "%s", s) + i++; + } +} + +void +run_server(void) +{ + id obj = [MyClass new]; + NSConnection *conn = [NSConnection defaultConnection]; + + [conn setRootObject: obj]; + if ([conn registerName: SRV_NAME] == NO) + { + NSLog(@"Failed to register name: " SRV_NAME ); + abort(); + } + [[NSRunLoop currentRunLoop] run]; +} +#endif + +@interface SimpleClass : NSObject +- (const char *) sel1; +@end + +@implementation SimpleClass +- (const char *) sel1 +{ + return ""; +} +@end + +int +main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool; + pool = [[NSAutoreleasePool alloc] init]; + const char *e; + id o; + id s; + + o = [SimpleClass new]; + s = [o methodSignatureForSelector: @selector(sel1)]; + e = @encode(const char*); + PASS(strcmp(e, "r*") == 0, "@encode(const char*) makes 'r*' type encoding") + PASS(strcmp([s methodReturnType], "r*") == 0, + "sel1 return type is 'r*'") + +#if GNUSTEP + if ([[[[NSProcessInfo processInfo] arguments] lastObject] isEqual: @"srv"]) + { + run_server(); + abort(); + } + + NS_DURING + { + test_compare_server_signature(); + test_GSSelectorTypesMatch(); + } + NS_HANDLER + { + NSLog(@"MethodSignature Test Failed:"); + NSLog(@"%@ %@ %@", + [localException name], + [localException reason], + [localException userInfo]); + } + NS_ENDHANDLER +#endif + + [pool release]; + + exit(0); +} + diff --git a/Tests/base/NSMutableArray/TestInfo b/Tests/base/NSMutableArray/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableArray/basic.m b/Tests/base/NSMutableArray/basic.m new file mode 100644 index 000000000..868d49b00 --- /dev/null +++ b/Tests/base/NSMutableArray/basic.m @@ -0,0 +1,18 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *testObj = [NSMutableArray arrayWithCapacity:1]; + test_alloc(@"NSMutableArray"); + test_NSObject(@"NSMutableArray", [NSArray arrayWithObject:testObj]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSArray",@"NSMutableArray", + [NSArray arrayWithObject:testObj], NO, NO); + test_NSMutableCopying(@"NSArray",@"NSMutableArray", + [NSArray arrayWithObject:testObj]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableArray/create.m b/Tests/base/NSMutableArray/create.m new file mode 100644 index 000000000..8b7236172 --- /dev/null +++ b/Tests/base/NSMutableArray/create.m @@ -0,0 +1,63 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *val1, *val2, *val3; + NSMutableArray *obj, *old; + id vals[3]; + + val1 = @"Hello"; + val2 = @"Goodbye"; + val3 = @"Testing"; + + vals[0] = val1; + vals[1] = val2; + vals[2] = val3; + + obj = [NSMutableArray arrayWithCapacity:10]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && + [obj count] == 0, + "+arrayWithCapacity creates an empty mutable array"); + + obj = [NSMutableArray array]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && + [obj count] == 0, + "+array creates an empty mutable array"); + + PASS_EXCEPTION([NSMutableArray arrayWithObject:nil];, + NSInvalidArgumentException, + "+arrayWithObject: with nil object raises an exception"); + + obj = [NSMutableArray arrayWithObject:val1]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && + [obj count] == 1, + "+arrayWithObject: builds minimal array"); + + obj = [NSMutableArray arrayWithObjects:vals count:3]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && + [obj count] == 3, + "+arrayWithObjects:count: builds an array"); + + obj = [NSMutableArray arrayWithObjects:val1,val2,val3,nil]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && + [obj count] == 3, + "+arrayWithObjects: builds an array"); + + old = obj; + obj = [NSMutableArray arrayWithArray:old]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && + [obj isEqual:old], + "+arrayWithArray: copies array"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableArray/general.m b/Tests/base/NSMutableArray/general.m new file mode 100644 index 000000000..c9349b683 --- /dev/null +++ b/Tests/base/NSMutableArray/general.m @@ -0,0 +1,102 @@ +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id val1,val2,val3,obj; + NSMutableArray *arr,*vals1,*vals2,*vals3; + + val1 = @"Hello"; + val2 = @"A Goodbye"; + val3 = @"Testing all strings"; + + vals1 = [[NSMutableArray arrayWithObject:val1] retain]; + [vals1 addObject:val2]; + vals2 = [[vals1 arrayByAddingObject:val2] retain]; + vals3 = [[vals1 arrayByAddingObject:val3] retain]; + + obj = [NSMutableArray new]; + arr = obj; + PASS(obj != nil && [obj isKindOfClass:[NSMutableArray class]] && [obj count] == 0, + "-count returns zero for an empty array"); + PASS([arr hash] == 0, "-hash returns zero for an empty array"); + PASS(vals3 != nil && [vals3 containsObject:val2], "-containsObject works"); + PASS(vals3 != nil && [vals3 indexOfObject:@"A Goodbye"] == 1, + "-indexOfObject: finds object"); + PASS(vals3 != nil && [vals3 indexOfObjectIdenticalTo:val2], + "-indexOfObjectIdenticalTo: finds identical object"); + { + NSEnumerator *e; + id v1, v2, v3; + e = [arr objectEnumerator]; + v1 = [e nextObject]; + v2 = [e nextObject]; + PASS(e != nil && v1 == nil && v2 == nil, + "-objectEnumerator: is ok for empty array"); + e = [vals1 objectEnumerator]; + v1 = [e nextObject]; + v2 = [e nextObject]; + v3 = [e nextObject]; + PASS(v1 != nil && v2 != nil && v3 == nil && [vals1 containsObject:v1] && + [vals1 containsObject:v2] && [v1 isEqual:val1] && [v2 isEqual: val2], + "-objectEnumerator: enumerates the array"); + } + + { + obj = [arr description]; + obj = [obj propertyList]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && [obj count] == 0, + "-description gives us a text property-list (empty array)"); + obj = [arr description]; + obj = [obj propertyList]; + PASS(obj != nil && + [obj isKindOfClass:[NSMutableArray class]] && [obj isEqual:arr], + "-description gives us a text property-list"); + } + PASS(vals1 != nil && + [vals1 isKindOfClass: [NSMutableArray class]] && + [vals1 count] == 2, "-count returns two for an array with two objects"); + + PASS([vals1 hash] == 2, "-hash returns two for an array with two objects"); + + PASS([vals1 indexOfObject:nil] == NSNotFound, + "-indexOfObject: gives NSNotFound for a nil object"); + PASS([vals1 indexOfObject:val3] == NSNotFound, + "-indexOfObject: gives NSNotFound for a object not in the array"); + PASS([vals1 isEqualToArray:vals1], + "Array is equal to itself using -isEqualToArray:"); + PASS(![vals1 isEqualToArray:vals2],"Similar arrays are not equal using -isEqualToArray:"); + + { + NSArray *a; + NSRange r = NSMakeRange(0,2); + a = [vals2 subarrayWithRange:r]; + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && [a count] == 2 && + [a objectAtIndex:0] == val1 && [a objectAtIndex:1] == val2, + "-subarrayWithRange: seems ok"); + r = NSMakeRange(1,2); + + PASS_EXCEPTION([arr subarrayWithRange:r];,@"NSRangeException","-subarrayWithRange with invalid range"); + } + + { + NSString *c = @"/"; + NSString *s = @"Hello/A Goodbye"; + NSString *a = [vals1 componentsJoinedByString: c]; + PASS(a != nil && [a isKindOfClass:[NSString class]] && [a isEqual:s], + "-componentsJoinedByString: seems ok"); + } + { + NSArray *a = [vals1 sortedArrayUsingSelector:@selector(compare:)]; + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && [a count] == 2 && + [a objectAtIndex:0] == val2 && [a objectAtIndex:1] == val1, + "-sortedArrayUsingSelector: seems ok"); + + } + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableAttributedString/TestInfo b/Tests/base/NSMutableAttributedString/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableAttributedString/basic.m b/Tests/base/NSMutableAttributedString/basic.m new file mode 100644 index 000000000..ae62110fe --- /dev/null +++ b/Tests/base/NSMutableAttributedString/basic.m @@ -0,0 +1,18 @@ +#import +#import +#import "ObjectTesting.h" +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *arr = [NSArray arrayWithObject:[NSMutableAttributedString new]]; + + test_alloc(@"NSMutableAttributedString"); + test_NSObject(@"NSMutableAttributedString", arr); + test_NSCoding(arr); + test_NSCopying(@"NSAttributedString",@"NSMutableAttributedString",arr,NO, NO); + test_NSMutableCopying(@"NSAttributedString",@"NSMutableAttributedString",arr); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMutableAttributedString/test00.m b/Tests/base/NSMutableAttributedString/test00.m new file mode 100644 index 000000000..d0c3bfe12 --- /dev/null +++ b/Tests/base/NSMutableAttributedString/test00.m @@ -0,0 +1,251 @@ +#import "Testing.h" +#import +#import + +@interface NSMutableAttributedString (TestingAdditions) +-(BOOL)checkAttributes:(NSDictionary *)attr location:(int)location; +-(BOOL)checkAttributes:(NSDictionary *)attr range:(NSRange)range; +@end +@implementation NSMutableAttributedString (TestingAdditions) +-(BOOL)checkAttributes:(NSDictionary *)attr location:(int)loc +{ + return [[self attributesAtIndex:loc + effectiveRange:NULL] isEqual:attr]; +} + +-(BOOL)checkAttributes:(NSDictionary *)attr range:(NSRange)range +{ + NSRange aRange = range; + + while (aRange.length > 0) + { + BOOL attrEqual; + attrEqual= [[self attributesAtIndex:aRange.location + (aRange.length - 1) + effectiveRange:NULL] isEqual:attr]; + if (attrEqual == NO) + return NO; + + aRange.length -= 1; + } + return YES; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableAttributedString *attrStr; + NSString *baseString = @"0123456789"; + NSDictionary *red, *gray, *blue; + + red = [NSDictionary dictionaryWithObject:@"Red" forKey:@"Color"]; + gray = [NSDictionary dictionaryWithObject:@"Gray" forKey:@"Color"]; + blue = [NSDictionary dictionaryWithObject:@"Blue" forKey:@"Color"]; + + attrStr = [[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]; + PASS([[attrStr string] isEqual:baseString] && + [attrStr checkAttributes:red range:NSMakeRange(0,10)], + "-initWithString:attributes: works"); + + [attrStr setAttributes:blue range:NSMakeRange(0,10)]; + PASS([attrStr checkAttributes:blue range:NSMakeRange(0,10)], + "-setAttributes:range: works for the whole string"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(0,5)]; + PASS([attrStr checkAttributes:blue range:NSMakeRange(0,5)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works for the first half of the string"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(3,5)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,3)] && + [attrStr checkAttributes:blue range:NSMakeRange(3,5)] && + [attrStr checkAttributes:red range:NSMakeRange(8,2)], + "-setAttributes:range: works for the middle of the string"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(5,5)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,5)] && + [attrStr checkAttributes:blue range:NSMakeRange(5,5)], + "-setAttributes:range: works for the last half of the string"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(0,3)]; + [attrStr setAttributes:red range:NSMakeRange(3,4)]; + [attrStr setAttributes:gray range:NSMakeRange(7,3)]; + PASS([attrStr checkAttributes:blue range:NSMakeRange(0,3)] && + [attrStr checkAttributes:red range:NSMakeRange(3,4)] && + [attrStr checkAttributes:gray range:NSMakeRange(7,3)], + "-setAttributes:range: works in three parts of the string"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(0,5)]; + [attrStr setAttributes:red range:NSMakeRange(3,5)]; + [attrStr setAttributes:gray range:NSMakeRange(4,5)]; + PASS([attrStr checkAttributes:blue range:NSMakeRange(0,3)] && + [attrStr checkAttributes:red range:NSMakeRange(3,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(4,5)] && + [attrStr checkAttributes:red range:NSMakeRange(9,1)], + "-setAttributes:range: works with overlapping"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(1,2)]; + [attrStr setAttributes:blue range:NSMakeRange(4,2)]; + [attrStr setAttributes:blue range:NSMakeRange(7,2)]; + [attrStr setAttributes:gray range:NSMakeRange(2,6)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:blue range:NSMakeRange(1,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(2,6)] && + [attrStr checkAttributes:blue range:NSMakeRange(8,1)] && + [attrStr checkAttributes:red range:NSMakeRange(9,1)], + "-setAttributes:range: works with overlapping (2)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(2,5)]; + [attrStr setAttributes:gray range:NSMakeRange(2,5)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,2)] && + [attrStr checkAttributes:gray range:NSMakeRange(2,5)] && + [attrStr checkAttributes:red range:NSMakeRange(7,3)], + "-setAttributes:range: works with replacing"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(1,8)]; + [attrStr setAttributes:red range:NSMakeRange(2,6)]; + [attrStr setAttributes:gray range:NSMakeRange(3,4)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:blue range:NSMakeRange(1,1)] && + [attrStr checkAttributes:red range:NSMakeRange(2,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(3,4)] && + [attrStr checkAttributes:red range:NSMakeRange(7,1)] && + [attrStr checkAttributes:blue range:NSMakeRange(8,1)] && + [attrStr checkAttributes:red range:NSMakeRange(9,1)], + "-setAttributes:range: works with chinese boxes"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(1,3)]; + [attrStr setAttributes:gray range:NSMakeRange(1,4)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(1,4)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works with extending at the end (diff color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:gray range:NSMakeRange(1,3)]; + [attrStr setAttributes:gray range:NSMakeRange(1,4)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(1,4)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works with extending at the end (diff color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(2,3)]; + [attrStr setAttributes:gray range:NSMakeRange(1,4)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(1,4)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works with extending at the beginning (diff color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:gray range:NSMakeRange(2,3)]; + [attrStr setAttributes:gray range:NSMakeRange(1,4)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(1,4)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works with extending at the beginning (same color)"); + + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(1,3)]; + [attrStr setAttributes:gray range:NSMakeRange(2,2)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:blue range:NSMakeRange(1,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(2,2)] && + [attrStr checkAttributes:red range:NSMakeRange(4,6)], + "-setAttributes:range: works with subset at the end (diff color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:gray range:NSMakeRange(1,3)]; + [attrStr setAttributes:gray range:NSMakeRange(2,2)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:gray range:NSMakeRange(1,3)] && + [attrStr checkAttributes:red range:NSMakeRange(4,6)], + "-setAttributes:range: works with subset at the end (same color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(2,3)]; + [attrStr setAttributes:gray range:NSMakeRange(2,2)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,2)] && + [attrStr checkAttributes:gray range:NSMakeRange(2,2)] && + [attrStr checkAttributes:blue range:NSMakeRange(4,1)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works with subset at the beginning (diff color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:gray range:NSMakeRange(2,3)]; + [attrStr setAttributes:gray range:NSMakeRange(2,2)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,2)] && + [attrStr checkAttributes:gray range:NSMakeRange(2,3)] && + [attrStr checkAttributes:red range:NSMakeRange(5,5)], + "-setAttributes:range: works with subset at the beginning (same color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:gray range:NSMakeRange(2,1)]; + [attrStr setAttributes:gray range:NSMakeRange(4,1)]; + [attrStr setAttributes:blue range:NSMakeRange(1,5)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:blue range:NSMakeRange(1,5)] && + [attrStr checkAttributes:red range:NSMakeRange(6,4)], + "-setAttributes:range: works with subsets (diff color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(2,1)]; + [attrStr setAttributes:blue range:NSMakeRange(4,1)]; + [attrStr setAttributes:blue range:NSMakeRange(1,5)]; + PASS([attrStr checkAttributes:red range:NSMakeRange(0,1)] && + [attrStr checkAttributes:blue range:NSMakeRange(1,5)] && + [attrStr checkAttributes:red range:NSMakeRange(6,4)], + "-setAttributes:range: works with subsets (same color)"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(2,1)]; + [attrStr setAttributes:blue range:NSMakeRange(4,1)]; + [attrStr setAttributes:blue range:NSMakeRange(7,2)]; + [attrStr setAttributes:red range:NSMakeRange(3,2)]; + [attrStr setAttributes:gray range:NSMakeRange(0,10)]; + PASS([attrStr checkAttributes:gray range:NSMakeRange(0,10)], + "-setAttributes:range: works with setting attributes for the whole string"); + + ASSIGN(attrStr,[[NSMutableAttributedString alloc] initWithString:baseString + attributes:red]); + [attrStr setAttributes:blue range:NSMakeRange(0,1)]; + [attrStr setAttributes:blue range:NSMakeRange(1,1)]; + [attrStr setAttributes:blue range:NSMakeRange(2,1)]; + PASS([attrStr checkAttributes:blue range:NSMakeRange(0,3)] && + [attrStr checkAttributes:red range:NSMakeRange(3,7)], + "-setAttributes:range: works with nearby attributes"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMutableAttributedString/test01.m b/Tests/base/NSMutableAttributedString/test01.m new file mode 100644 index 000000000..57547b503 --- /dev/null +++ b/Tests/base/NSMutableAttributedString/test01.m @@ -0,0 +1,162 @@ +#import "Testing.h" +#import +#import + +/* get rid of compiler warnings */ +@interface NSMutableAttributedString(evil) +-(void) _sanity; +@end +#if defined(GNUSTEP_BASE_LIBRARY) +@implementation NSMutableAttributedString(evil) +-(void) _sanity +{ +} +@end +#endif + +@interface NSMutableAttributedString (TestingAdditions) +-(BOOL)checkAttributes:(NSDictionary *)attr location:(int)location; +-(BOOL)checkAttributes:(NSDictionary *)attr range:(NSRange)range; +@end + +@implementation NSMutableAttributedString (TestingAdditions) +-(BOOL)checkAttributes:(NSDictionary *)attr location:(int)loc +{ + return [[self attributesAtIndex:loc + effectiveRange:NULL] isEqual:attr]; +} + +-(BOOL)checkAttributes:(NSDictionary *)attr range:(NSRange)range +{ + NSRange aRange = range; + + while (aRange.length > 0) + { + BOOL attrEqual; + attrEqual= [[self attributesAtIndex:aRange.location + (aRange.length - 1) + effectiveRange:NULL] isEqual:attr]; + if (attrEqual == NO) + return NO; + + aRange.length -= 1; + } + return YES; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableAttributedString *as; + NSString *base1 = @"base-1"; + NSString *base2 = @"base-2"; + NSDictionary *attrE, *attr1, *attr2; + int start,length,index; + + [[[NSMutableAttributedString new] autorelease] _sanity]; + + as = [[NSMutableAttributedString alloc] initWithString:base1 attributes:nil]; + [as replaceCharactersInRange:NSMakeRange(2,2) withString:@""]; + [as _sanity]; + PASS([[as string] isEqual:@"ba-1"], + "-replaceCharactersInRange: withString: works with zero length string"); + + as = [[NSMutableAttributedString alloc] initWithString:base1 attributes:nil]; + [as replaceCharactersInRange:NSMakeRange(2,2) withString:base2]; + [as _sanity]; + PASS([[as string] isEqual:@"babase-2-1"], + "-replaceCharactersInRange:withString: works in middle of string"); + + as = [[NSMutableAttributedString alloc] initWithString:base1 attributes:nil]; + [as replaceCharactersInRange:NSMakeRange(6,0) withString:base2]; + [as _sanity]; + PASS([[as string] isEqual:@"base-1base-2"], + "-replaceCharactersInRange:withString: works at end of string works"); + + as = [[NSMutableAttributedString alloc] initWithString:base1 attributes:nil]; + [as replaceCharactersInRange:NSMakeRange(0,0) withString:base2]; + [as _sanity]; + PASS([[as string] isEqual:@"base-2base-1"], + "-replaceCharactersInRange:withString: works at start of string works"); + + attrE = [NSDictionary dictionary]; + attr1 = [NSDictionary dictionaryWithObject:@"a" forKey:@"1"]; + attr2 = [NSDictionary dictionaryWithObject:@"b" forKey:@"2"]; + as = [[NSMutableAttributedString alloc] initWithString:base1 + attributes:attr1]; + [as setAttributes:attr2 range:NSMakeRange(2,4)]; + [as replaceCharactersInRange:NSMakeRange(0,6) withString:@""]; + [as replaceCharactersInRange:NSMakeRange(0,0) withString:@"aa"]; + [as replaceCharactersInRange:NSMakeRange(2,0) withString:@"bb"]; + [as _sanity]; + PASS([as checkAttributes:attrE range:NSMakeRange(0,4)], + "-replaceCharactersInRange:withString: keeps attributes if entire string is replaced"); + + as = [[NSMutableAttributedString alloc] initWithString:base1 + attributes:attr1]; + [as replaceCharactersInRange:NSMakeRange(0,6) withString:base2]; + [as _sanity]; + PASS([[as string] isEqual:base2] && + [as checkAttributes:attr1 range:NSMakeRange(0,6)], + "-replaceCharactersInRange:withString: keeps attributes if entire string is replaced"); + + for (start=0;start != 9; start++) + { + for (length = 0; (length + start) != 9; length++) + { + + BOOL removeAll,replaceAll; + NSDictionary *aBegin,*aEnd; + as = [[NSMutableAttributedString alloc] initWithString:@"aabbccdd" + attributes:attr2]; + removeAll = (start == 0 && length == 8); + [as setAttributes:attr1 range:NSMakeRange(2,2)]; + [as setAttributes:attrE range:NSMakeRange(4,2)]; + + if (removeAll) + { + aBegin = attrE; + aEnd = attrE; + } + else + { + aBegin = [as attributesAtIndex: (start == 0) ? length : 0 + effectiveRange:NULL]; + aEnd = [as attributesAtIndex: ((start + length) == 8) ? (start - 1) : 8 + effectiveRange:NULL]; + + [as replaceCharactersInRange:NSMakeRange(start, length) + withString:@""]; + [as _sanity]; + PASS([[as string] length] == (8 - length) && + [as checkAttributes:aBegin location:0] && + [as checkAttributes:aEnd location: (8 - length)], + "attribute/(replaceCharacters... with zero length string) interaction _sanity checks %i %i",start, length); + + } + as = [[NSMutableAttributedString alloc] initWithString:@"aabbccdd" + attributes:attr2]; + replaceAll = (start == 0 && length == 8); + [as setAttributes:attr1 range:NSMakeRange(2,2)]; + [as setAttributes:attrE range:NSMakeRange(4,2)]; + if (length == 0 && start == 0) + index = 0; + else if (length == 0) + index = (start - 1); + else + index = start; + + aBegin = [as attributesAtIndex:index effectiveRange:NULL]; + [as replaceCharactersInRange:NSMakeRange(start,length) + withString:@"foo"]; + [as _sanity]; + PASS([[as string] length] == (11 - length) && + [as checkAttributes:aBegin range:NSMakeRange(start,3)], + "attribute/replaceCharacters... interaction _sanity checks %i %i",start,length); + + } + } + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableCharacterSet/TestInfo b/Tests/base/NSMutableCharacterSet/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableCharacterSet/basic.m b/Tests/base/NSMutableCharacterSet/basic.m new file mode 100644 index 000000000..7de9b397d --- /dev/null +++ b/Tests/base/NSMutableCharacterSet/basic.m @@ -0,0 +1,19 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObj = [NSMutableCharacterSet new]; + test_alloc(@"NSMutableCharacterSet"); + test_NSObject(@"NSMutableCharacterSet",[NSArray arrayWithObject:testObj]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSCharacterSet", @"NSMutableCharacterSet", + [NSArray arrayWithObject:testObj], NO, NO); + test_NSMutableCopying(@"NSCharacterSet", @"NSMutableCharacterSet", + [NSArray arrayWithObject:testObj]); + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMutableCharacterSet/test00.m b/Tests/base/NSMutableCharacterSet/test00.m new file mode 100644 index 000000000..748fe2f07 --- /dev/null +++ b/Tests/base/NSMutableCharacterSet/test00.m @@ -0,0 +1,27 @@ +#import "Testing.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableCharacterSet *testMutableNamedSet, *testMutableNamedSet1, *testMutableNamedSet2; + NSCharacterSet *testNamedSet; + testMutableNamedSet = [NSMutableCharacterSet letterCharacterSet]; + testNamedSet = [NSCharacterSet letterCharacterSet]; + [testMutableNamedSet invert]; + PASS([testMutableNamedSet characterIsMember:[@"." characterAtIndex:0]] && + ![testNamedSet characterIsMember:[@"." characterAtIndex:0]], + "Insure defaults set accessors return the correct class"); + + testMutableNamedSet1 = [NSMutableCharacterSet letterCharacterSet]; + testMutableNamedSet2 = [NSMutableCharacterSet letterCharacterSet]; + [testMutableNamedSet1 invert]; + PASS([testMutableNamedSet1 characterIsMember:[@"." characterAtIndex:0]] && + ![testMutableNamedSet2 characterIsMember:[@"." characterAtIndex:0]], + "Test whether we always get a clean mutable set"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMutableData/TestInfo b/Tests/base/NSMutableData/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableData/basic.m b/Tests/base/NSMutableData/basic.m new file mode 100644 index 000000000..c5fd17e9b --- /dev/null +++ b/Tests/base/NSMutableData/basic.m @@ -0,0 +1,22 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObject = [NSMutableData new]; + test_alloc(@"NSMutableData"); + test_NSObject(@"NSData",[NSArray arrayWithObject:testObject]); + test_NSCoding([NSArray arrayWithObject:testObject]); + test_NSCopying(@"NSData", + @"NSMutableData", + [NSArray arrayWithObject:testObject], NO, NO); + test_NSMutableCopying(@"NSData", + @"NSMutableData", + [NSArray arrayWithObject:testObject]); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSMutableData/general.m b/Tests/base/NSMutableData/general.m new file mode 100644 index 000000000..6ba148108 --- /dev/null +++ b/Tests/base/NSMutableData/general.m @@ -0,0 +1,57 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + char *str1,*str2,*tmp; + NSData *data1, *data2; + NSMutableData *mutable; + unsigned char *hold; + + str1 = "Test string for data classes"; + str2 = (char *) malloc(sizeof("insert")); + strcpy(str2,"insert"); + + mutable = [NSMutableData dataWithLength:100]; + hold = [mutable mutableBytes]; + + /* hmpf is this correct */ + data1 = [NSData dataWithBytes:str1 length:(strlen(str1) * sizeof(void*))]; + PASS(data1 != nil && + [data1 isKindOfClass:[NSData class]] && + [data1 length] == (strlen(str1) * sizeof(void*)) && + [data1 bytes] != str1 && + strcmp(str1,[data1 bytes]) == 0, + "+dataWithBytes:length: works"); + + mutable = [NSMutableData data]; + PASS(mutable != nil && + [mutable isKindOfClass:[NSMutableData class]] && + [mutable length] == 0, + "+data creates empty mutable data"); + + [mutable setData:data1]; + PASS(mutable != nil && + [mutable length] == (strlen(str1) * sizeof(void*)), + "-setData: works"); + + [mutable replaceBytesInRange:NSMakeRange(22,6) withBytes:str2]; + tmp = (char *)malloc([mutable length]); + [mutable getBytes:tmp range:NSMakeRange(22,6)]; + tmp[6] = '\0'; + PASS(mutable != nil && + strcmp(tmp,str2) == 0, + "-replaceBytesInRange:withBytes suceeds"); + free(tmp); + PASS_EXCEPTION([mutable replaceBytesInRange:NSMakeRange([mutable length]+1,6) + withBytes:str2];, + NSRangeException,"-replaceBytesInRange:withBytes out of range raises exception"); + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableDictionary/TestInfo b/Tests/base/NSMutableDictionary/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableDictionary/basic.m b/Tests/base/NSMutableDictionary/basic.m new file mode 100644 index 000000000..b863ce453 --- /dev/null +++ b/Tests/base/NSMutableDictionary/basic.m @@ -0,0 +1,23 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableDictionary *testObj; + + testObj = [NSMutableDictionary new]; + + test_NSObject(@"NSMutableDictionary", [NSArray arrayWithObject:testObj]); + + test_NSCoding([NSArray arrayWithObject:testObj]); + + test_NSCopying(@"NSDictionary",@"NSMutableDictionary", + [NSArray arrayWithObject:testObj], NO, NO); + + test_NSMutableCopying(@"NSDictionary",@"NSMutableDictionary", + [NSArray arrayWithObject:testObj]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableDictionary/general.m b/Tests/base/NSMutableDictionary/general.m new file mode 100644 index 000000000..80ccf10b5 --- /dev/null +++ b/Tests/base/NSMutableDictionary/general.m @@ -0,0 +1,223 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *key1, *key2, *key3, *val1, *val2, *val3; + NSArray *keys1, *keys2, *keys3, *vals1, *vals2, *vals3; + id obj; + NSMutableDictionary *dict; + + key1 = @"Key1"; + key2 = @"Key2"; + key3 = @"Key3"; + val1 = @"Hello"; + val2 = @"Goodbye"; + val3 = @"Testing"; + keys1 = [NSArray arrayWithObjects:key1,key2,nil]; + keys2 = [NSArray arrayWithObjects:key1,key2,key3,nil]; + keys3 = [NSArray arrayWithObjects:key1,key2,key2,nil]; /* duplicate keys */ + vals1 = [NSArray arrayWithObjects:val1,val2,nil]; + vals2 = [NSArray arrayWithObjects:val1,val2,val2,nil]; /* duplicate vals */ + vals3 = [NSArray arrayWithObjects:val1,val2,val3,nil]; + + + dict = [NSMutableDictionary new]; + PASS(dict != nil && + [dict isKindOfClass:[NSMutableDictionary class]] + && [dict count] == 0, + "-count returns zero for an empty dictionary"); + + PASS([dict hash] == 0, "-hash returns zero for an empty dictionary"); + obj = [dict allKeys]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 0, + "-allKeys gives an empty array for an empty dictionary"); + + obj = [dict allKeysForObject:nil]; + PASS(obj == nil, "-allKeysForObject: gives nil for an empty dictionary"); + + obj = [dict allValues]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 0, + "-allValues gives an empty array for an empty dictionary"); + { + id o1; + id o2; + + o1 = [dict objectForKey:nil]; + o2 = [dict objectForKey:key1]; + PASS(o1 == nil && o2 == nil, + "-objectForKey: gives nil for an empty dictionary"); + } + + { + NSEnumerator *e = [dict keyEnumerator]; + id k1,k2; + + k1 = [e nextObject]; + k2 = [e nextObject]; + PASS(e != nil && k1 == nil && k2 == nil, + "-keyEnumerator: is ok for empty dictionary"); + } + + { + NSEnumerator *e = [dict objectEnumerator]; + id v1,v2; + + v1 = [e nextObject]; + v2 = [e nextObject]; + PASS(e != nil && v1 == nil && v2 == nil, + "-objectEnumerator: is ok for empty dictionary"); + } + + { + NSString *notFound = @"notFound"; + NSArray *a = [dict objectsForKeys:keys1 notFoundMarker:notFound]; + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && + [a count] == 2 && + [a objectAtIndex:0] == notFound && + [a objectAtIndex:1] == notFound, + "-objectsForKeys:notFoundMarker: is ok for empty dictionary"); + } + + obj = [dict description]; + obj = [obj propertyList]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj count] == 0, + "-description gives us a text property-list"); + + dict = [[NSMutableDictionary dictionaryWithObjects:vals1 forKeys:keys1] retain]; + PASS(dict != nil && + [dict isKindOfClass:[NSMutableDictionary class]] && + [dict count] == 2, + "-count returns two for an dictionary with two keys"); + + PASS([dict hash] == 2, "-hash returns two for a dictionary with two keys"); + + obj = [dict allKeys]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 2 && + [obj containsObject:key1] && + [obj containsObject:key1], + "-allKeys gives the keys we put in the dictionary"); + + { + NSArray *o1,*o2; + o1 = [dict allKeysForObject:val1]; + o2 = [dict allKeysForObject:val2]; + PASS(o1 != nil && + [o1 isKindOfClass:[NSArray class]] && + [o1 count] == 1 && + [o1 containsObject:key1] && + o2 != nil && + [o2 isKindOfClass:[NSArray class]] && + [o2 count] == 1 && + [o2 containsObject:key2], + "-allKeysForObject: gives the key we expect"); + } + obj = [dict allValues]; + PASS(obj != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] == 2 && + [obj containsObject:val1] && + [obj containsObject:val2], + "-allValues gives the values we put in the dictionary"); + + PASS([dict objectForKey:nil] == nil,"-objectForKey: gives nil for a nil key"); + PASS([dict objectForKey:key3] == nil, + "-objectForKey: gives nil for a key not in the dictionary"); + + { + id o1 = [dict objectForKey: key1]; + id o2 = [dict objectForKey: key2]; + PASS(o1 == val1 && o2 == val2, + "-objectForKey: gives the objects we added for the keys"); + } + + { + NSEnumerator *e = [dict keyEnumerator]; + id k1,k2,k3; + k1 = [e nextObject]; + k2 = [e nextObject]; + k3 = [e nextObject]; + PASS(k1 != nil && + k2 != nil && + k3 == nil && + k1 != k2 && + [keys1 containsObject:k1] && + [keys1 containsObject:k2], + "-keyEnumerator: enumerates the dictionary"); + } + + { + NSEnumerator *e = [dict objectEnumerator]; + id v1,v2,v3; + v1 = [e nextObject]; + v2 = [e nextObject]; + v3 = [e nextObject]; + + PASS(v1 != nil && + v2 != nil && + v3 == nil && + v1 != v2 && + [vals1 containsObject:v1] && + [vals1 containsObject:v2], + "-objectEnumerator: enumerates the dictionary"); + } + + { + NSString *notFound = @"notFound"; + NSArray *a = [dict objectsForKeys:keys2 notFoundMarker:notFound]; + + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && + [a count] == 3 && + [a objectAtIndex:0] == val1 && + [a objectAtIndex:1] == val2 && + [a objectAtIndex:2] == notFound, + "-objectsForKeys:notFoundMarker: is ok for dictionary"); + } + + { + NSArray *a = [dict keysSortedByValueUsingSelector:@selector(compare:)]; + PASS(a != nil && + [a isKindOfClass:[NSArray class]] && + [a count] == 2 && + [a objectAtIndex:0] == key2 && + [a objectAtIndex:1] == key1, + "-keysSortedByValueUsingSelector: seems ok"); + } + + obj = [dict description]; + obj = [obj propertyList]; + PASS(obj != nil && + [obj isKindOfClass:[NSDictionary class]] && + [obj isEqual:dict], + "-description gives us a text property-list"); + + dict = [NSMutableDictionary new]; + [dict setObject:@"hello" forKey:@"world"]; + PASS(dict != nil && + [dict isKindOfClass:[NSMutableDictionary class]] && + [[dict objectForKey:@"world"] isEqual:@"hello"], + "-setObject:forKey: is ok"); + + [dict setValue:@"hello" forKey:@"Lücke"]; + PASS([[dict valueForKey:@"Lücke"] isEqualToString:@"hello"], + "unicode keys work with setValue:forKey:"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableIndexSet/TestInfo b/Tests/base/NSMutableIndexSet/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableIndexSet/test0.m b/Tests/base/NSMutableIndexSet/test0.m new file mode 100644 index 000000000..f71fd9fd8 --- /dev/null +++ b/Tests/base/NSMutableIndexSet/test0.m @@ -0,0 +1,27 @@ +#include +#include +#include +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSMutableIndexSet *set = [[NSMutableIndexSet alloc] init]; + + [set addIndex:1]; + [set addIndex:2]; + [set addIndex:1]; + PASS([set containsIndex:2], "contains index 2"); + PASS([set containsIndex:1], "contains index 1"); + [set removeIndex:1]; + PASS(![set containsIndex:1], "removed index 1"); + [set removeIndex:2]; + PASS(![set containsIndex:2], "removed index 2"); + + [set addIndex:0]; + [set addIndex:2]; + [set shiftIndexesStartingAtIndex:2 by:-1]; + + PASS([set containsIndexesInRange:NSMakeRange(0,2)], "contains range"); + + [pool release]; + return 0; +} diff --git a/Tests/base/NSMutableIndexSet/test1.m b/Tests/base/NSMutableIndexSet/test1.m new file mode 100644 index 000000000..58766cf53 --- /dev/null +++ b/Tests/base/NSMutableIndexSet/test1.m @@ -0,0 +1,43 @@ +#import +#import +#import +#include +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSMutableData *m = [NSMutableData dataWithCapacity: 1024]; + NSPropertyListFormat aFormat; + NSString *aString; + id pl; + NSKeyedArchiver *a; + NSKeyedUnarchiver *u; + NSMutableIndexSet *original; + NSIndexSet *decoded; + + a = [[NSKeyedArchiver alloc] initForWritingWithMutableData: m]; + [a setOutputFormat: NSPropertyListXMLFormat_v1_0]; + + original = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(2,3)]; + [original addIndex: 7]; + [original addIndex: 557]; + [original addIndex: 947]; + [a encodeObject: original forKey: @"outer1"]; + [a finishEncoding]; + + pl = [NSPropertyListSerialization propertyListFromData: m + mutabilityOption: 0 + format: &aFormat + errorDescription: &aString]; + pl = [(NSDictionary*)[[(NSDictionary*)pl objectForKey: @"$objects"] + objectAtIndex: 2] objectForKey: @"NS.data"]; + // FIXME ... maybe check encoded data format + + [a release]; + + u = [[NSKeyedUnarchiver alloc] initForReadingWithData: m]; + decoded = [u decodeObjectForKey: @"outer1"]; + PASS([decoded isEqual: original], "decoded value equals encoded"); + [u release]; + [pool release]; + return 0; +} diff --git a/Tests/base/NSMutableSet/TestInfo b/Tests/base/NSMutableSet/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableSet/basic.m b/Tests/base/NSMutableSet/basic.m new file mode 100644 index 000000000..0ed08479c --- /dev/null +++ b/Tests/base/NSMutableSet/basic.m @@ -0,0 +1,18 @@ +#import "ObjectTesting.h" +#import +#import + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableSet *testObj = [NSMutableSet new]; + test_NSObject(@"NSMutableSet", [NSArray arrayWithObject:testObj]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSSet",@"NSMutableSet", + [NSArray arrayWithObject:testObj],NO,NO); + test_NSMutableCopying(@"NSSet",@"NSMutableSet", + [NSArray arrayWithObject:testObj]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSMutableString/GNUmakefile.preamble b/Tests/base/NSMutableString/GNUmakefile.preamble new file mode 100644 index 000000000..bc09b917a --- /dev/null +++ b/Tests/base/NSMutableString/GNUmakefile.preamble @@ -0,0 +1,2 @@ +ADDITIONAL_INCLUDE_DIRS += -I../NSString + diff --git a/Tests/base/NSMutableString/NSMutableString_string.m b/Tests/base/NSMutableString/NSMutableString_string.m new file mode 100644 index 000000000..a4a7d0643 --- /dev/null +++ b/Tests/base/NSMutableString/NSMutableString_string.m @@ -0,0 +1,16 @@ +/* +copyright 2004 Alexander Malmberg + +Test that -base's cluster of NSMutableString classes are valid NSString +classes. +*/ + +#import "../NSString/NSString_tests.h" + +#import + +int main(int argc,char **argv) +{ + TestNSStringClass([NSMutableString class]); + return 0; +} diff --git a/Tests/base/NSMutableString/TestInfo b/Tests/base/NSMutableString/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSMutableString/basic.m b/Tests/base/NSMutableString/basic.m new file mode 100644 index 000000000..fed5bde9f --- /dev/null +++ b/Tests/base/NSMutableString/basic.m @@ -0,0 +1,123 @@ +#import "ObjectTesting.h" +#import +#import + +@interface CustomString : NSString +{ + unichar *characters; + NSUInteger length; +} +@end + +@implementation CustomString + +- (id) initWithBytesNoCopy: (void *)c + length: (NSUInteger)l + encoding: (NSStringEncoding)encoding + freeWhenDone: (BOOL)freeWhenDone +{ + if (l > 0) + { + if (encoding == NSUnicodeStringEncoding) + { + characters = malloc(l); + memcpy(characters, c, l); + } + else + { + NSString *s; + + s = [[NSString alloc] initWithBytesNoCopy: c + length: l + encoding: encoding + freeWhenDone: freeWhenDone]; + if (s == nil) return nil; + l = [s length] * sizeof(unichar); + characters = malloc(l); + [s getCharacters: characters]; + [s release]; + } + } + length = l / sizeof(unichar); + return self; +} + +- (void) dealloc +{ + if (characters) + { + free(characters); + characters = NULL; + } + [super dealloc]; +} + +- (NSUInteger) length +{ + return length; +} + +- (unichar) characterAtIndex: (NSUInteger)index +{ + return characters[index]; +} +@end + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + unichar u0 = 'a'; + unichar u1 = 0xfe66; + NSMutableString *testObj,*base,*ext,*want; + + test_alloc(@"NSMutableString"); + testObj = [[NSMutableString alloc] initWithCString:"Hello\n"]; + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSString",@"NSMutableString", + [NSArray arrayWithObject:testObj],NO,NO); + test_NSMutableCopying(@"NSString",@"NSMutableString", + [NSArray arrayWithObject:testObj]); + + base = [[NSMutableString alloc] initWithCString:"hello"]; + ext = [@"\"\\UFE66???\"" propertyList]; + want = [@"\"hello\\UFE66???\"" propertyList]; + [base appendString:ext]; + PASS([base length] == 9 && [ext length] == 4 + && [want length] == 9 && [base isEqual:want], + "We can append a unicode string to a C string"); + + PASS([[[NSMutableString alloc] initWithCharacters: &u0 length: 1] + isKindOfClass: [NSMutableString class]], + "initWithCharacters:length: creates mutable string for ascii"); + + PASS([[[NSMutableString alloc] initWithCharacters: &u1 length: 1] + isKindOfClass: [NSMutableString class]], + "initWithCharacters:length: creates mutable string for unicode"); + + PASS_RUNS([[NSMutableString stringWithString: @"foo"] + appendString: @"bar"];, + "can append to string from NSMutableString +stringWithString:"); + + testObj = [@"hello" mutableCopy]; + [testObj replaceCharactersInRange: NSMakeRange(1,1) withString: @"a"]; + PASS([testObj isEqual: @"hallo"], + "replaceCharactersInRange:withString: works in middle of string"); + [testObj replaceCharactersInRange: NSMakeRange(4,1) withString: @"y"]; + PASS([testObj isEqual: @"hally"], + "replaceCharactersInRange:withString: works at end of string"); + + [testObj setString: @"hello"]; + [testObj replaceCharactersInRange: NSMakeRange(1,1) + withString: [CustomString stringWithCString: "a"]]; + PASS([testObj isEqual: @"hallo"], + "custom string replacement works in middle of string"); + [testObj replaceCharactersInRange: NSMakeRange(4,1) + withString: [CustomString stringWithCString: "y"]]; + PASS([testObj isEqual: @"hally"], + "custom string replacement works at end of string"); + + [testObj release]; + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSNumber/TestInfo b/Tests/base/NSNumber/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSNumber/basic.m b/Tests/base/NSNumber/basic.m new file mode 100644 index 000000000..b0242bbab --- /dev/null +++ b/Tests/base/NSNumber/basic.m @@ -0,0 +1,18 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSNumber *testObj; + + test_alloc_only(@"NSNumber"); + testObj = [NSNumber numberWithInt: 5]; + test_NSObject(@"NSNumber", [NSArray arrayWithObject:testObj]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSNumber", @"NSNumber", + [NSArray arrayWithObject:testObj],YES,NO); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSNumber/test00.m b/Tests/base/NSNumber/test00.m new file mode 100644 index 000000000..097e22b64 --- /dev/null +++ b/Tests/base/NSNumber/test00.m @@ -0,0 +1,170 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +#include +#include + +#if !defined(LLONG_MAX) +# if defined(__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX-1) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +# else +# error Neither LLONG_MAX nor __LONG_LONG_MAX__ found +# endif +#endif + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSNumber *val1, *val2, *val3; + NSArray *a; + id o; + double d; + + val1 = [NSNumber numberWithBool:YES]; + PASS(val1 != nil, "We can create a boolean (YES)") + + val2 = [NSNumber numberWithBool:NO]; + PASS(val2 != nil, "We can create a boolean (NO)") + + PASS(![val1 isEqual:val2], "A boolean YES is not a NO") + PASS(![val2 isEqual:val1], "A boolean NO is not a YES") + PASS([val1 isEqual:[NSNumber numberWithBool:YES]], "A boolean YES is a YES") + PASS([val2 isEqual:[NSNumber numberWithBool:NO]], "A boolean NO is a NO") + + val1 = [NSNumber numberWithChar: 99]; + PASS(val1 != nil, "We can create a char number") + val1 = [NSNumber numberWithChar: -1]; + PASS(val1 != nil, "We can create a signed char number") + val2 = [NSNumber numberWithUnsignedChar: 255]; + PASS(val2 != nil, "We can create an unsigned char number") + PASS(![val1 isEqual: val2], "A -1 signed char is not a 255 unsigned char") + PASS([val1 isEqual: [NSNumber numberWithChar: 255]], + "A -1 signed char is a 255 signed char") + + val1 = [NSNumber numberWithChar: -100]; + PASS([val1 isEqual: [NSNumber numberWithShort: -100]], + "A -100 signed char is a -100 signed short") + PASS([val1 isEqual: [NSNumber numberWithInt: -100]], + "A -100 signed char is a -100 signed int") + PASS([val1 isEqual: [NSNumber numberWithLong: -100]], + "A -100 signed char is a -100 signed long") + PASS([val1 isEqual: [NSNumber numberWithLongLong: -100]], + "A -100 signed char is a -100 signed long long") + PASS([val1 isEqual: [NSNumber numberWithFloat: -100.0]], + "A -100 signed char is a -100 signed float") + PASS([val1 isEqual: [NSNumber numberWithDouble: -100.0]], + "A -100 signed char is a -100 signed double") + PASS([val1 isEqual: [NSNumber numberWithInteger: -100]], + "A -100 signed char is a -100 NSInteger") + + PASS([val1 shortValue] == (signed short)-100, + "A -100 signed char is a -100 signed short") + PASS([val1 intValue] == (signed int)-100, + "A -100 signed char is a -100 signed int") + PASS([val1 longValue] == (signed long)-100, + "A -100 signed char is a -100 signed long") + PASS([val1 longLongValue] == (signed long long)-100, + "A -100 signed char is a -100 signed long long") + PASS([val1 floatValue] == (float)-100.0, + "A -100 signed char is a -100 signed float") + PASS([val1 doubleValue] == (double)-100.0, + "A -100 signed char is a -100 signed double") + PASS([val1 integerValue] == (NSInteger)-100, + "A -100 signed char is a -100 NSInteger") + PASS([val1 boolValue] == YES, + "A -100 signed char is a YES BOOL") + + val1 = [NSNumber numberWithInt: 127]; + val2 = [NSNumber numberWithInt: 128]; + PASS([val2 compare: val1] == NSOrderedDescending, + "integer numbers - 127 < 128") + PASS([val1 compare: val2] == NSOrderedAscending, + "integer numbers - 128 > 127") + val1 = [NSNumber numberWithChar: 100]; + val2 = [NSNumber numberWithChar: 200]; + val3 = [NSNumber numberWithInt: 200]; + PASS(![val2 isEqual: val3], "A 200 signed char is not a 200 int") + PASS([val2 compare: val1] == NSOrderedAscending, + "signed char numbers - 200 < 100") + PASS([val1 compare: val2] == NSOrderedDescending, + "signed char numbers - 100 > 200") + + PASS(5 == (NSUInteger)[[NSNumber numberWithUnsignedInteger: 5] pointerValue], + "pointerValue works") + + val1 = [NSDecimalNumber numberWithInt: 200]; + PASS(200 == [val1 intValue], + "NSDecimalNumber numberWithInt: works") + val1 = [NSDecimalNumber decimalNumberWithString: @"200"]; + PASS(200.0 == [val1 floatValue], + "NSDecimalNumber floatValue works") + PASS(200.0 == [val1 doubleValue], + "NSDecimalNumber doubleValue works") + PASS(YES == [val1 boolValue], + "NSDecimalNumber boolValue works") + PASS((signed char)200 == [val1 charValue], + "NSDecimalNumber charValue works") + PASS(200 == [val1 intValue], + "NSDecimalNumber intValue works") + PASS(200 == [val1 integerValue], + "NSDecimalNumber integerValue works") + PASS(200 == [val1 longValue], + "NSDecimalNumber longValue works") + PASS(200 == [val1 longLongValue], + "NSDecimalNumber longLongValue works") + PASS(200 == [val1 shortValue], + "NSDecimalNumber shortValue works") + PASS(200 == [val1 unsignedCharValue], + "NSDecimalNumber unsignedCharValue works") + PASS(200 == [val1 unsignedIntValue], + "NSDecimalNumber unsignedIntValue works") + PASS(200 == [val1 unsignedIntegerValue], + "NSDecimalNumber unsignedIntegerValue works") + PASS(200 == [val1 unsignedLongValue], + "NSDecimalNumber unsignedLongValue works") + PASS(200 == [val1 unsignedLongLongValue], + "NSDecimalNumber unsignedLongLongValue works") + PASS(200 == [val1 unsignedShortValue], + "NSDecimalNumber unsignedShortValue works") + + val1 = [[NSNumber alloc] initWithLongLong: LLONG_MIN]; + val2 = [[NSNumber alloc] initWithUnsignedLongLong: + (unsigned long long)LLONG_MAX + 1]; + PASS([val1 compare: val2] == NSOrderedAscending, + "comparison of min signed with max unsigned works") + + a = [NSArray arrayWithObjects: + [NSNumber numberWithUnsignedLongLong: ULLONG_MAX], + [NSNumber numberWithInt: -2], + [NSNumber numberWithFloat: 300.057], + [NSNumber numberWithInt: 1], + [NSNumber numberWithDouble: 200.0123], + [NSNumber numberWithLongLong: LLONG_MIN], + nil]; + a = [a sortedArrayUsingSelector: @selector(compare:)]; + PASS([[a objectAtIndex: 0] longLongValue] == LLONG_MIN + && [[a objectAtIndex: 1] longLongValue] == -2 + && [[a objectAtIndex: 2] longLongValue] == 1 + && [[a objectAtIndex: 3] longLongValue] == 200 + && [[a objectAtIndex: 4] longLongValue] == 300 + && [[a objectAtIndex: 5] unsignedLongLongValue] == ULLONG_MAX, + "sorted numbers are correctly ordered"); + +#if defined(GNUSTEP_BASE_LIBRARY) + PASS([[NSPropertyListSerialization propertyListFromData: [NSPropertyListSerialization dataFromPropertyList: [NSNumber numberWithInt: -10] format: NSPropertyListGNUstepFormat errorDescription: 0] mutabilityOption: NSPropertyListImmutable format: 0 errorDescription: 0] intValue] == -10, + "store negative integer in property list works") + PASS((d = [[NSPropertyListSerialization propertyListFromData: [NSPropertyListSerialization dataFromPropertyList: [NSNumber numberWithDouble: -1.2] format: NSPropertyListGNUstepFormat errorDescription: 0] mutabilityOption: NSPropertyListImmutable format: 0 errorDescription: 0] doubleValue]) > -1.21 && d < -1.19, + "store negative double in property list works") +#endif + + o = [NSDecimalNumber numberWithDouble: 66.66]; + PASS([o isKindOfClass: [NSDecimalNumber class]], "+numberWith... subclass") + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSNumber/test01.m b/Tests/base/NSNumber/test01.m new file mode 100644 index 000000000..d0c5d4de7 --- /dev/null +++ b/Tests/base/NSNumber/test01.m @@ -0,0 +1,104 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +#include +#include + +#if !defined(LLONG_MAX) +# if defined(__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX-1) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) +# else +# error Neither LLONG_MAX nor __LONG_LONG_MAX__ found +# endif +#endif + +int main() +{ + START_SET("NSNumber") + NSNumber *n; + + START_SET("not-a-number checks") + + NSNumber *nan = [NSDecimalNumber notANumber]; + + PASS(YES == [nan isEqualToNumber: nan], "NaN is equal to NaN"); + + n = [NSNumber numberWithInt: 2]; + PASS(NO == [n isEqualToNumber: nan], "2 is not equal to NaN"); + PASS([n compare: nan] == NSOrderedDescending, "2 is greater than NaN") + PASS([nan compare: n] == NSOrderedAscending, "NaN is less than 2") + + n = [NSNumber numberWithUnsignedLongLong: 2]; + PASS(NO == [n isEqualToNumber: nan], "2LL is not equal to NaN"); + PASS([n compare: nan] == NSOrderedDescending, "2LL is greater than NaN") + PASS([nan compare: n] == NSOrderedAscending, "NaN is less than 2LL") + + n = [NSNumber numberWithFloat: 2.0]; + PASS(NO == [n isEqualToNumber: nan], "2.0 is not equal to NaN"); + PASS([n compare: nan] == NSOrderedDescending, "2.0 is greater than NaN") + PASS([nan compare: n] == NSOrderedAscending, "NaN is less than 2.0") + + n = [NSNumber numberWithDouble: 2.0]; + PASS(NO == [n isEqualToNumber: nan], "2.0dd is not equal to NaN"); + PASS([n compare: nan] == NSOrderedDescending, "2.0dd is greater than NaN") + PASS([nan compare: n] == NSOrderedAscending, "NaN is less than 2.0dd") + + n = [NSNumber numberWithFloat: 0.0]; + PASS(NO == [n isEqualToNumber: nan], "0.0 is not equal to NaN"); + PASS([n compare: nan] == NSOrderedDescending, "0.0 greater than NaN") + PASS([nan compare: n] == NSOrderedAscending, "NaN less than 0.0") + + n = [NSNumber numberWithFloat: -1.01]; + PASS(NO == [n isEqualToNumber: nan], "-1.01 is not equal to NaN"); + PASS([n compare: nan] == NSOrderedAscending, "-1.01 less than NaN") + PASS([nan compare: n] == NSOrderedAscending, "NaN less than -1.01") + + END_SET("not-a-number checks") + + START_SET("zero checks") + + NSNumber *zero = [NSDecimalNumber zero]; + + PASS(YES == [zero isEqualToNumber: zero], "zero is equal to zero"); + + n = [NSNumber numberWithInt: 2]; + PASS(NO == [n isEqualToNumber: zero], "2 is not equal to zero"); + PASS([n compare: zero] == NSOrderedDescending, "2 is greater than zero") + PASS([zero compare: n] == NSOrderedAscending, "zero is less than 2") + + n = [NSNumber numberWithUnsignedLongLong: 2]; + PASS(NO == [n isEqualToNumber: zero], "2LL is not equal to zero"); + PASS([n compare: zero] == NSOrderedDescending, "2LL is greater than zero") + PASS([zero compare: n] == NSOrderedAscending, "zero is less than 2LL") + + n = [NSNumber numberWithFloat: 2.0]; + PASS(NO == [n isEqualToNumber: zero], "2.0 is not equal to zero"); + PASS([n compare: zero] == NSOrderedDescending, "2.0 is greater than zero") + PASS([zero compare: n] == NSOrderedAscending, "zero is less than 2.0") + + n = [NSNumber numberWithDouble: 2.0]; + PASS(NO == [n isEqualToNumber: zero], "2.0dd is not equal to zero"); + PASS([n compare: zero] == NSOrderedDescending, + "2.0dd is greater than zero") + PASS([zero compare: n] == NSOrderedAscending, "zero is less than 2.0dd") + + n = [NSNumber numberWithFloat: 0.0]; + PASS([n isEqualToNumber: zero], "0.0 is equal to zero"); + PASS([n compare: zero] == NSOrderedSame, "0.0 is zero") + PASS([zero compare: n] == NSOrderedSame, "zero is 0.0") + + n = [NSNumber numberWithFloat: -1.01]; + PASS(NO == [n isEqualToNumber: zero], "-1.01 is not equal to zero"); + PASS([n compare: zero] == NSOrderedAscending, "-1.01 less than zero") + PASS([zero compare: n] == NSOrderedDescending, "zero greater than -1.01") + + END_SET("zero checks") + END_SET("NSNumber") + + return 0; +} diff --git a/Tests/base/NSNumberFormatter/TestInfo b/Tests/base/NSNumberFormatter/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSNumberFormatter/basic.m b/Tests/base/NSNumberFormatter/basic.m new file mode 100644 index 000000000..bfaec3be5 --- /dev/null +++ b/Tests/base/NSNumberFormatter/basic.m @@ -0,0 +1,75 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + START_SET("basic") + + NSNumberFormatter *fmt; + NSNumber *num; + NSString *error; + + [NSNumberFormatter + setDefaultFormatterBehavior: NSNumberFormatterBehavior10_0]; + + TEST_FOR_CLASS(@"NSNumberFormatter",[NSNumberFormatter alloc], + "+[NSNumberFormatter alloc] returns a NSNumberFormatter"); + + fmt = [[[NSNumberFormatter alloc] init] autorelease]; + num = [[[NSNumber alloc] initWithFloat: 1234.567] autorelease]; + + PASS_EQUAL([fmt stringForObjectValue: num], @"1,234.57", + "default format same as Cocoa") + + num = [[[NSNumber alloc] initWithFloat: 1.01] autorelease]; + PASS_EQUAL([fmt stringFromNumber: num], @"1.01", + "Handle leading zeroes in fractional part: 1.01") + + num = [[[NSNumber alloc] initWithFloat: 1.1] autorelease]; + PASS_EQUAL([fmt stringFromNumber: num], @"1.1", + "Handle leading zeroes in fractional part: 1.1") + + [fmt setAllowsFloats: NO]; + + num = [[[NSNumber alloc] initWithFloat: 1234.567] autorelease]; + PASS_EQUAL([fmt stringForObjectValue: num], @"1,234.57", + "-setAllowsFloats: does not effect rounding") + + PASS(NO == [fmt getObjectValue: &num forString: @"1234.567" + errorDescription: 0], "float input is disallowed") + + testHopeful = YES; + [fmt getObjectValue: &num forString: @"1234.567" errorDescription: &error]; + PASS_EQUAL(error, @"Floating Point not allowed", "allowsFloat error") + testHopeful = NO; + + [fmt setFormat: @"__000000"]; + num = [[[NSNumber alloc] initWithFloat: 1234.432] autorelease]; + PASS_EQUAL([fmt stringForObjectValue: num], @" 001234", + "numeric and space padding OK") + + [fmt setAllowsFloats: YES]; + + num = [[[NSNumber alloc] initWithFloat: 1234.56] autorelease]; + [fmt setPositiveFormat: @"$####.##c"]; + [fmt setNegativeFormat: @"-$(####.##)"]; + PASS_EQUAL([fmt stringForObjectValue: num], @"$1234.56c", + "prefix and suffix used properly") + + num = [[[NSNumber alloc] initWithFloat: -1234.56] autorelease]; + PASS_EQUAL([fmt stringForObjectValue: num], @"-$(1234.56)", + "negativeFormat used for -ve number") + + PASS_EQUAL([fmt stringForObjectValue: [NSDecimalNumber notANumber]], + @"NaN", "notANumber special case") + + [fmt setFormat: @"0"]; + PASS_EQUAL([fmt stringForObjectValue: num], @"-1235", + "format string of length 1") + + END_SET("basic") + + return 0; +} + diff --git a/Tests/base/NSNumberFormatter/basic10_4.m b/Tests/base/NSNumberFormatter/basic10_4.m new file mode 100644 index 000000000..91220427d --- /dev/null +++ b/Tests/base/NSNumberFormatter/basic10_4.m @@ -0,0 +1,160 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +#if defined(GS_USE_ICU) +#define NSLOCALE_SUPPORTED GS_USE_ICU +#else +#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main() +{ + NSNumberFormatter *fmt; + NSNumber *num; + NSString *str; + + START_SET("NSNumberFormatter") + + PASS(NSNumberFormatterBehavior10_4 + == [NSNumberFormatter defaultFormatterBehavior], + "default behavior is NSNumberFormatterBehavior10_4") + + [NSNumberFormatter + setDefaultFormatterBehavior: NSNumberFormatterBehavior10_0]; + PASS(NSNumberFormatterBehavior10_0 + == [NSNumberFormatter defaultFormatterBehavior], + "default behavior can be changed to NSNumberFormatterBehavior10_0") + + [NSNumberFormatter + setDefaultFormatterBehavior: NSNumberFormatterBehaviorDefault]; + PASS(NSNumberFormatterBehavior10_4 + == [NSNumberFormatter defaultFormatterBehavior], + "NSNumberFormatterBehaviorDefault gives NSNumberFormatterBehavior10_4") + + [NSNumberFormatter + setDefaultFormatterBehavior: NSNumberFormatterBehavior10_0]; + [NSNumberFormatter setDefaultFormatterBehavior: 1234]; + PASS(1234 == [NSNumberFormatter defaultFormatterBehavior], + "unknown behavior is accepted") + + [NSNumberFormatter + setDefaultFormatterBehavior: NSNumberFormatterBehavior10_4]; + PASS(NSNumberFormatterBehavior10_4 + == [NSNumberFormatter defaultFormatterBehavior], + "default behavior can be changed to NSNumberFormatterBehavior10_4") + + fmt = [[[NSNumberFormatter alloc] init] autorelease]; + + PASS(NSNumberFormatterBehavior10_4 == [fmt formatterBehavior], + "a new formatter gets the current default behavior") + [fmt setFormatterBehavior: NSNumberFormatterBehaviorDefault]; + PASS(NSNumberFormatterBehaviorDefault == [fmt formatterBehavior], + "a new formatter can have the default behavior set") + + str = [fmt stringFromNumber: [NSDecimalNumber notANumber]]; + PASS_EQUAL(str, @"NaN", "notANumber special case") + + START_SET("NSLocale") + if (!NSLOCALE_SUPPORTED) + SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built") + + PASS([fmt getObjectValue: &num forString: @"0.00" errorDescription: nil] + && num != nil, "formatting suceeded") + if (testPassed) + { + PASS(NO == [num isEqual: [NSDecimalNumber notANumber]], + "is not equal to NaN") + PASS(YES == [num isEqual: [NSDecimalNumber zero]], + "is equal to zero") + } + + num = [[[NSNumber alloc] initWithFloat: 1234.567] autorelease]; + + str = [fmt stringFromNumber: num]; + PASS_EQUAL(str, @"1235", "default 10.4 format same as Cocoa") + + [fmt setLocale: [[NSLocale alloc] initWithLocaleIdentifier: @"en"]]; + + [fmt setMaximumFractionDigits: 2]; + str = [fmt stringFromNumber: num]; + + PASS_EQUAL(str, @"1234.57", "round up for fractional part >0.5") + + num = [[[NSNumber alloc] initWithFloat: 1234.432] autorelease]; + str = [fmt stringFromNumber: num]; + + PASS_EQUAL(str, @"1234.43", "round down for fractional part <0.5") + + num = [[[NSNumber alloc] initWithFloat: -1234.43] autorelease]; + [fmt setMaximumFractionDigits: 1]; + [fmt setMinusSign: @"_"]; + PASS_EQUAL([fmt stringFromNumber: num], @"_1234.4", + "minus sign assigned correctly"); + + [fmt setPercentSymbol: @"##"]; + + [fmt setNumberStyle: NSNumberFormatterPercentStyle]; + testHopeful = YES; + PASS_EQUAL([fmt stringFromNumber: num], @"_123,443##", + "Negative percentage correct"); + testHopeful = NO; + + + num = [[[NSNumber alloc] initWithFloat: 1234.432] autorelease]; + + [fmt setNumberStyle: NSNumberFormatterNoStyle]; + [fmt setMaximumFractionDigits: 0]; + [fmt setFormatWidth: 6]; + + str = [fmt stringFromNumber: num]; + PASS_EQUAL(str, @"**1234", "format width set correctly"); + + [fmt setPositivePrefix: @"+"]; + str = [fmt stringFromNumber: num]; + PASS_EQUAL(str, @"*+1234", "positive prefix set correctly"); + + [fmt setPaddingCharacter: @"0"]; + str = [fmt stringFromNumber: num]; + PASS_EQUAL(str, @"0+1234", "default padding position is before prefix"); + + [fmt setPaddingPosition: NSNumberFormatterPadAfterPrefix]; + str = [fmt stringFromNumber: num]; + + PASS_EQUAL(str, @"+01234", "numeric and space padding OK") + + num = [[[NSNumber alloc] initWithFloat: 1234.56] autorelease]; + [fmt setNumberStyle: NSNumberFormatterCurrencyStyle]; + [fmt setLocale: [[NSLocale alloc] initWithLocaleIdentifier: @"pt_BR"]]; + + testHopeful = YES; + PASS_EQUAL([fmt stringFromNumber: num], @"+1.235", + "currency style does not include currency string"); + testHopeful = NO; + + [fmt setPositivePrefix: @"+"]; + PASS_EQUAL([fmt stringFromNumber: num], @"+1.235", + "positive prefix is set correctly for currency style"); + + [fmt setPositiveSuffix: @"c"]; + PASS_EQUAL([fmt stringFromNumber: num], @"+1.235c", + "prefix and suffix used properly"); + + num = [[[NSNumber alloc] initWithFloat: -1234.56] autorelease]; + PASS_EQUAL([fmt stringFromNumber: num], @"(R$1.235)", + "negativeFormat used for -ve number"); + + [fmt setNumberStyle: NSNumberFormatterNoStyle]; + + testHopeful = YES; + PASS_EQUAL([fmt stringFromNumber: num], @"_01235", + "format string of length 1") + testHopeful = NO; + + END_SET("NSLocale") + + END_SET("NSNumberFormatter") + + return 0; +} + diff --git a/Tests/base/NSObject/TestInfo b/Tests/base/NSObject/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSObject/basic.m b/Tests/base/NSObject/basic.m new file mode 100644 index 000000000..234a6049b --- /dev/null +++ b/Tests/base/NSObject/basic.m @@ -0,0 +1,13 @@ +#import "ObjectTesting.h" +#import +#import +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + test_alloc(@"NSObject"); + test_NSObject(@"NSObject", [NSArray arrayWithObject:[[NSObject new] autorelease]]); + PASS([[[NSObject new] autorelease] methodSignatureForSelector: 0] == nil, + "a null selector proiduces a nil method signature"); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSObject/objc++.mm b/Tests/base/NSObject/objc++.mm new file mode 100644 index 000000000..eddf22071 --- /dev/null +++ b/Tests/base/NSObject/objc++.mm @@ -0,0 +1,81 @@ +#import "Testing.h" +#import + +#if defined(TESTDEV) +static int A_init; +static int B_init; +static int A_destroyed; +static int B_destroyed; + +class A +{ + int b; + public: + A() : b(12) + { + PASS(0 == A_init, "Constructor only called once"); + PASS(0 == B_init, "a constructor called before b constructor "); + A_init = 1; + }; + ~A() + { + PASS(0 == A_destroyed, "Destructor only called once"); + PASS(1 == B_destroyed, "b destructor called before a destructor"); + A_destroyed = 1; + }; +}; +class A1 +{ + int b; + public: + A1() : b(12) + { + PASS(1 == A_init, "a constructor called before b constructor "); + B_init = 1; + }; + ~A1() + { + PASS(0 == A_destroyed, "b destructor called before a destructor"); + B_destroyed = 1; + }; +}; + +@interface B : NSObject +{ + A a; +} +@end +@interface C : B +{ + A1 b; +} +@end + +@implementation B +- (id) init +{ + PASS(1 == A_init, "a constructor called before -init"); + PASS(1 == B_init, "b constructor called before -init"); + PASS(0 == A_destroyed, "a destructor not called before -init"); + PASS(0 == B_destroyed, "b destructor not called before -init"); + return self; +} +@end + +@implementation C @end +int main(void) +{ + // Make sure constructors / destructors are called even without -init + [[C alloc] release]; + // Reset state + A_init = B_init = A_destroyed = B_destroyed = 0; + // Check init is called in the middle + [[C new] release]; + return 0; +} +#else +int main(void) +{ + return 0; +} +#endif diff --git a/Tests/base/NSObject/test00.m b/Tests/base/NSObject/test00.m new file mode 100644 index 000000000..7db3865aa --- /dev/null +++ b/Tests/base/NSObject/test00.m @@ -0,0 +1,12 @@ +#import "Testing.h" +#import +#import +#import + +int main() +{ + Class theClass = NSClassFromString(@"NSObject"); + PASS(theClass == [NSObject class], + "'NSObject' %s","uses +class to return self"); + return 0; +} diff --git a/Tests/base/NSObject/test01.m b/Tests/base/NSObject/test01.m new file mode 100644 index 000000000..6fa0e9582 --- /dev/null +++ b/Tests/base/NSObject/test01.m @@ -0,0 +1,63 @@ +#import "Testing.h" +#import +#import +#import +@interface MyEvilClass : NSObject +{ + Class class; + const char *name; + long version; + unsigned long info; + /* not sure which of these is correct */ + Class class_; + const char *name_; + long version_; + unsigned long info_; +} +-(void)setInfo:(unsigned long)info; +@end + +@implementation MyEvilClass +-(void)setInfo:(unsigned long)theInfo +{ + info = theInfo; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id evilObject; + PASS([NSObject isClass] && + [NSString isClass] && + [NSArray isClass], + "-isClass returns YES on a Class"); + + PASS((![[[NSObject new] autorelease] isClass] && + ![[NSString stringWithCString:"foo"] isClass] && + ![[[NSArray new] autorelease] isClass]), + "-isClass returns NO on an instance"); + + evilObject = [MyEvilClass new]; + [evilObject setInfo:1]; + PASS(![evilObject isClass], + "-isClass returns NO on an instance (special test for broken libobjc)"); + + PASS(([[[NSObject new] autorelease] isKindOfClass:[NSObject class]] && + [[[NSString new] autorelease] isKindOfClass:[NSString class]] && + ![[[NSObject new] autorelease] isKindOfClass:[NSString class]] && + [[[NSString new] autorelease] isKindOfClass:[NSObject class]] && + ![[[NSString new] autorelease] isKindOfClass:[NSArray class]] && + [[[NSMutableString new] autorelease] isKindOfClass:[NSString class]]), + "-isKindOfClass: works"); + + /* should return YES if receiver and argument are both NSObject */ + PASS([NSObject isKindOfClass:[NSObject class]] && + ![NSString isKindOfClass:[NSString class]] && + ![NSObject isKindOfClass:[NSString class]] && + [NSString isKindOfClass:[NSObject class]], + "+isKindOfClass: works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSObject/test02.m b/Tests/base/NSObject/test02.m new file mode 100644 index 000000000..943cf4319 --- /dev/null +++ b/Tests/base/NSObject/test02.m @@ -0,0 +1,55 @@ +#import "Testing.h" +#import +#import +/* Nicola Pero, Tue Dec 18 17:54:53 GMT 2001 */ +@protocol DoingNothing +- (void) doNothing; +@end + +@protocol DoingNothingCategory +- (void) doNothingCategory; +@end + + +@interface NicolaTest : NSObject +{ +} +@end + +@implementation NicolaTest +- (void) doNothing +{ + return; +} +@end + +@interface NicolaTest (Category) +@end + +@implementation NicolaTest (Category) +- (void) doNothingCategory +{ + return; +} +@end + + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + PASS([NicolaTest conformsToProtocol:@protocol(DoingNothing)], + "+conformsToProtocol returns YES on an implemented protocol"); + PASS([NicolaTest conformsToProtocol:@protocol(DoingNothingCategory)], + "+conformsToProtocol returns YES on a protocol implemented in a category"); + PASS(![NicolaTest conformsToProtocol:@protocol(NSCoding)], + "+conformsToProtocol returns NO on an unimplemented protocol"); + PASS([[NicolaTest new] conformsToProtocol:@protocol(DoingNothing)], + "-conformsToProtocol returns YES on an implemented protocol"); + PASS([[NicolaTest new] conformsToProtocol:@protocol(DoingNothingCategory)], + "-conformsToProtocol returns YES on a protocol implemented in a category"); + PASS(![[NicolaTest new] conformsToProtocol:@protocol(NSCoding)], + "-conformsToProtocol returns NO on an unimplemented protocol"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSOperation/TestInfo b/Tests/base/NSOperation/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSOperation/basic.m b/Tests/base/NSOperation/basic.m new file mode 100644 index 000000000..94f235833 --- /dev/null +++ b/Tests/base/NSOperation/basic.m @@ -0,0 +1,122 @@ +#import +#import +#import +#import "ObjectTesting.h" + + +int main() +{ + id obj1; + id obj2; + NSMutableArray *testObjs = [[NSMutableArray alloc] init]; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + test_alloc(@"NSOperation"); + obj1 = [NSOperation new]; + PASS((obj1 != nil), "can create an operation"); + [testObjs addObject: obj1]; + test_NSObject(@"NSOperation", testObjs); + + PASS(([obj1 isReady] == YES), "operation is ready"); + PASS(([obj1 isConcurrent] == NO), "operation is not concurrent"); + PASS(([obj1 isCancelled] == NO), "operation is not cancelled"); + PASS(([obj1 isExecuting] == NO), "operation is not executing"); + PASS(([obj1 isFinished] == NO), "operation is not finished"); + PASS(([[obj1 dependencies] isEqual: [NSArray array]]), + "operation has no dependencies"); + PASS(([obj1 queuePriority] == NSOperationQueuePriorityNormal), + "operation has normal priority"); + [obj1 setQueuePriority: 10000]; + PASS(([obj1 queuePriority] == NSOperationQueuePriorityVeryHigh), + "operation has very high priority"); + + obj2 = [NSOperation new]; + [obj2 addDependency: obj1]; + PASS(([[obj2 dependencies] isEqual: testObjs]), + "operation has added dependency"); + PASS(([obj2 isReady] == NO), "operation with dependency is not ready"); + [obj1 cancel]; + PASS(([[obj2 dependencies] isEqual: testObjs]), + "cancelled dependency continues"); + PASS(([obj1 isCancelled] == YES), "operation is cancelled"); + PASS(([[obj2 dependencies] isEqual: testObjs]), + "cancelled dependency continues"); + PASS(([obj2 isReady] == NO), "operation with cancelled dependency not ready"); + [obj2 removeDependency: obj1]; + PASS(([[obj2 dependencies] isEqual: [NSArray array]]), + "dependency removal works"); + PASS(([obj2 isReady] == YES), "operation without dependency is ready"); + + [obj1 release]; + obj1 = [NSOperation new]; + [testObjs replaceObjectAtIndex: 0 withObject: obj1]; + [obj2 addDependency: obj1]; + [obj1 start]; + + [NSThread sleepForTimeInterval: 1.0]; + PASS(([obj1 isFinished] == YES), "operation is finished"); + PASS(([obj1 isReady] == YES), "a finished operation is ready"); + PASS(([[obj2 dependencies] isEqual: testObjs]), + "finished dependency continues"); + PASS(([obj2 isReady] == YES), "operation with finished dependency is ready"); + + [obj2 removeDependency: obj1]; + [obj1 release]; + obj1 = [NSOperation new]; + [testObjs replaceObjectAtIndex: 0 withObject: obj1]; + [obj2 addDependency: obj1]; + [obj2 cancel]; + PASS(([obj2 isReady] == YES), + "a cancelled object is ready even with a dependency"); + + [obj2 start]; + PASS(([obj2 isFinished] == YES), + "a cancelled object can finish"); + + PASS_EXCEPTION([obj2 start];, + NSInvalidArgumentException, + "NSOperation cannot be started twice"); + + PASS(([obj2 waitUntilFinished], YES), "wait returns at once"); + + + test_alloc(@"NSOperationQueue"); + obj1 = [NSOperationQueue new]; + PASS((obj1 != nil), "can create an operation queue"); + [testObjs removeAllObjects]; + [testObjs addObject: obj1]; + test_NSObject(@"NSOperationQueue", testObjs); + + PASS(([obj1 isSuspended] == NO), "not suspended by default"); + [obj1 setSuspended: YES]; + PASS(([obj1 isSuspended] == YES), "set suspended yes"); + [obj1 setSuspended: NO]; + PASS(([obj1 isSuspended] == NO), "set suspended no"); + + PASS(([[obj1 name] length] > 0), "name has a default"); + [obj1 setName: @"mine"]; + PASS(([[obj1 name] isEqual: @"mine"] == YES), "set name OK"); + [obj1 setName: nil]; + PASS(([[obj1 name] isEqual: @""]), "setting null name gives empty string"); + + PASS(([obj1 maxConcurrentOperationCount] == NSOperationQueueDefaultMaxConcurrentOperationCount), "max concurrent set by default"); + [obj1 setMaxConcurrentOperationCount: 1]; + PASS(([obj1 maxConcurrentOperationCount] == 1), "max concurrent set to one"); + [obj1 setMaxConcurrentOperationCount: 0]; + PASS(([obj1 maxConcurrentOperationCount] == 0), "max concurrent set to zero"); + [obj1 setMaxConcurrentOperationCount: 1000000]; + PASS(([obj1 maxConcurrentOperationCount] == 1000000), "max concurrent set to a million"); + [obj1 setMaxConcurrentOperationCount: NSOperationQueueDefaultMaxConcurrentOperationCount]; + PASS(([obj1 maxConcurrentOperationCount] == NSOperationQueueDefaultMaxConcurrentOperationCount), "max concurrent set to default"); + PASS_EXCEPTION([obj1 setMaxConcurrentOperationCount: -1000000];, + NSInvalidArgumentException, + "NSOperationQueue cannot be given negative count"); + + obj2 = [NSOperation new]; + [obj1 addOperation: obj2]; + [NSThread sleepForTimeInterval: 1.0]; + PASS(([obj2 isFinished] == YES), "queue ran operation"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSOperation/concurrent.m b/Tests/base/NSOperation/concurrent.m new file mode 100644 index 000000000..0823f2b87 --- /dev/null +++ b/Tests/base/NSOperation/concurrent.m @@ -0,0 +1,146 @@ +#import +#import +#import +#import +#import +#import +#import "ObjectTesting.h" + +// concurrent operation +@interface MyOperation : NSOperation +{ + int calculation; + + BOOL executing; + BOOL finished; +} +- (void) completeOperation; +@end + +@implementation MyOperation + +- (id) initWithValue: (int)aVal +{ + self = [super init]; + if (self) { + calculation = aVal; + executing = NO; + finished = NO; + } + return self; +} + +- (BOOL) isConcurrent { return YES; } +- (BOOL) isExecuting { return executing; } +- (BOOL) isFinished { return finished; } +- (int) getCalculation { return calculation; } + +- (void) main +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + [self willChangeValueForKey:@"isExecuting"]; + executing = YES; + [self didChangeValueForKey:@"isExecuting"]; + // Do the main work of the operation here. + calculation = 2 * calculation; + + [self completeOperation]; + [pool release]; +} + +- (void) start +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + // Always check for cancellation before launching the task. + if ([self isCancelled]) + { + // Must move the operation to the finished state if it is canceled. + [self willChangeValueForKey: @"isFinished"]; + finished = YES; + [self didChangeValueForKey: @"isFinished"]; + return; + } + + // As the operation is not canceled, begin executing the task. + [NSThread detachNewThreadSelector: @selector(main) + toTarget: self + withObject: nil]; + [pool release]; +} + +- (void) completeOperation +{ + [self willChangeValueForKey: @"isFinished"]; + [self willChangeValueForKey: @"isExecuting"]; + + executing = NO; + finished = YES; + + [self didChangeValueForKey: @"isExecuting"]; + [self didChangeValueForKey: @"isFinished"]; +} + +@end + + +int main() +{ + id obj; + NSOperationQueue *q; + int i; + NSMutableArray *a; + + START_SET("concurrent operations") + + // single concurrent operation + obj = [[MyOperation alloc] initWithValue: 1]; + q = [NSOperationQueue new]; + [q addOperation: obj]; + [q waitUntilAllOperationsAreFinished]; + PASS(([obj isFinished] == YES), "operation ran"); + PASS(([obj isExecuting] == NO), "operation is not executing"); + PASS(([obj getCalculation] == 2), "operation was performed"); + [obj release]; + + // multiple concurrent operations + [q setMaxConcurrentOperationCount: 10]; + a = [NSMutableArray array]; + for (i = 0; i < 5; ++i) + { + obj = [[MyOperation alloc] initWithValue: i]; + [a addObject: obj]; + [q addOperation: obj]; + } + [q waitUntilAllOperationsAreFinished]; + PASS(([obj isFinished] == YES), "operation ran"); + PASS(([obj isExecuting] == NO), "operation is not executing"); + + for (i = 0; i < 5; ++i) + { + obj = [a objectAtIndex: i]; + PASS(([obj getCalculation] == (2*i)), "operation was performed"); + } + + // multiple concurrent operations + [q setMaxConcurrentOperationCount: 5]; + a = [NSMutableArray array]; + for (i = 0; i < 10; ++i) + { + obj = [[MyOperation alloc] initWithValue: i]; + [a addObject: obj]; + } + [q addOperations: a waitUntilFinished: YES]; + PASS(([obj isFinished] == YES), "operation ran"); + PASS(([obj isExecuting] == NO), "operation is not executing"); + + for (i = 0; i < 10; ++i) + { + obj = [a objectAtIndex: i]; + PASS(([obj getCalculation] == (2*i)), "operation was performed"); + } + + END_SET("concurrent operations") + return 0; +} diff --git a/Tests/base/NSOperation/threads.m b/Tests/base/NSOperation/threads.m new file mode 100644 index 000000000..a6ca30370 --- /dev/null +++ b/Tests/base/NSOperation/threads.m @@ -0,0 +1,258 @@ +#import +#import +#import +#import +#import +#import +#import "ObjectTesting.h" + + +@interface ThreadCounter : NSObject +{ + unsigned count; +} +- (unsigned) count; +- (void) increment: (NSNotification*)n; +- (void) reset; +@end + +@implementation ThreadCounter +- (unsigned) count +{ + return count; +} + +- (void) dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver: self]; + [super dealloc]; +} + +- (void) increment: (NSNotification*)n +{ + count++; +} + +- (id) init +{ + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector(increment:) + name: NSThreadWillExitNotification + object: nil]; + return self; +} + +- (void) reset +{ + count = 0; +} + +@end + +@interface OpFlag : NSOperation +{ + NSThread *thread; + BOOL flag; +} +- (void) main; +- (BOOL) ran; +- (NSThread*) thread; +@end + +@implementation OpFlag +- (void) main +{ + flag = YES; + thread = [NSThread currentThread]; +} +- (BOOL) ran +{ + return flag; +} +- (NSThread*) thread +{ + return thread; +} +@end + +@interface OpExit : OpFlag +@end + +@implementation OpExit +- (void) main +{ + [super main]; + [NSThread exit]; +} +@end + +@interface OpRaise : OpFlag +@end + +@implementation OpRaise +- (void) main +{ + [super main]; + [NSException raise: NSGenericException format: @"done"]; +} +@end + +@interface OpOrder : NSOperation +@end +@implementation OpOrder +static NSLock *lock = nil; +static NSMutableArray *list = nil; ++ (void) initialize +{ + lock = [NSLock new]; + list = [NSMutableArray new]; +} +- (void) main +{ + [lock lock]; + [list addObject: self]; + [lock unlock]; +} +@end + +int main() +{ + ThreadCounter *cnt; + id old; + id obj; + NSMutableArray *a; + NSOperationQueue *q; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + cnt = [ThreadCounter new]; + PASS((cnt != nil && [cnt count] == 0), "counter was set up"); + + // Check that operation runs in current thread. + obj = [OpFlag new]; + [obj start]; + PASS(([obj ran] == YES), "operation ran"); + PASS(([obj thread] == [NSThread currentThread]), "operation ran in this thread"); + [obj release]; + + // Check that monitoring of another thread works. + obj = [OpFlag new]; + [NSThread detachNewThreadSelector: @selector(start) + toTarget: obj + withObject: nil]; + [NSThread sleepForTimeInterval: 0.1]; + PASS(([obj isFinished] == YES), "operation finished"); + PASS(([obj ran] == YES), "operation ran"); + PASS(([obj thread] != [NSThread currentThread]), "operation ran in other thread"); + [obj release]; + + // Check that exit from thread in -main causes operation tracking to fail. + obj = [OpExit new]; + [NSThread detachNewThreadSelector: @selector(start) + toTarget: obj + withObject: nil]; + [NSThread sleepForTimeInterval: 0.1]; + PASS(([obj isFinished] == NO), "operation exited"); + PASS(([obj ran] == YES), "operation ran"); + PASS(([obj thread] != [NSThread currentThread]), "operation ran in other thread"); + PASS(([obj isExecuting] == YES), "operation seems to be running"); + [obj release]; + + // Check that raising exception in -main causes operation tracking to fail. + obj = [OpRaise new]; + PASS_EXCEPTION([obj start];, + NSGenericException, + "NSOperation exceptions propogate from main"); + PASS(([obj isFinished] == NO), "operation failed to finish"); + PASS(([obj ran] == YES), "operation ran"); + PASS(([obj thread] == [NSThread currentThread]), "operation ran in this thread"); + PASS(([obj isExecuting] == YES), "operation seems to be running"); + [obj release]; + + obj = [OpFlag new]; + [obj start]; + PASS(([obj ran] == YES), "operation ran"); + PASS(([obj thread] == [NSThread currentThread]), "operation ran in this thread"); + [obj release]; + + obj = [OpFlag new]; + q = [NSOperationQueue new]; + [cnt reset]; + [q addOperation: obj]; + [q waitUntilAllOperationsAreFinished]; + PASS(([obj ran] == YES), "operation ran"); + PASS(([obj thread] != [NSThread currentThread]), "operation ran in other thread"); + + PASS(([cnt count] == 0), "thread did not exit immediately"); + [obj release]; + /* Observer behavior on OSX 10.6 is that the thread exits after five seconds ... but who knows what that might change to. */ + [NSThread sleepForTimeInterval: 6.0]; + PASS(([cnt count] == 1), "thread exit occurs after six seconds"); + + PASS(([NSOperationQueue currentQueue] == [NSOperationQueue mainQueue]), "current queue outside -main is main queue"); + PASS(([NSOperationQueue mainQueue] != nil), "main queue is not nil"); + obj = [OpFlag new]; + [q addOperation: obj]; + [q waitUntilAllOperationsAreFinished]; + PASS(([obj isFinished] == YES), "main queue runs an operation"); + PASS(([obj thread] != [NSThread currentThread]), "operation ran in other thread"); + + [q setSuspended: YES]; + obj = [OpFlag new]; + [q addOperation: obj]; + [NSThread sleepForTimeInterval: 0.1]; + PASS(([obj isFinished] == NO), "suspend works"); + [q setSuspended: NO]; + [q waitUntilAllOperationsAreFinished]; + PASS(([obj isFinished] == YES), "unsuspend works"); + [obj release]; + + [q setMaxConcurrentOperationCount: 0]; + obj = [OpFlag new]; + [q addOperation: obj]; + [NSThread sleepForTimeInterval: 0.1]; + PASS(([obj isFinished] == NO), "max operation count of zero suspends queue"); + [q setMaxConcurrentOperationCount: 1]; + [q waitUntilAllOperationsAreFinished]; + PASS(([obj isFinished] == YES), "resetting max operation queue sarts it"); + [obj release]; + + a = [NSMutableArray array]; + + [q setSuspended: YES]; + obj = [OpOrder new]; + [a addObject: obj]; + [obj release]; + obj = [OpOrder new]; + [a addObject: obj]; + [obj release]; + obj = [OpOrder new]; + [a addObject: obj]; + [obj release]; + [q setSuspended: NO]; + [q addOperations: a waitUntilFinished: YES]; + PASS(([list isEqual: a]), "operations ran in order of addition"); + + [list removeAllObjects]; + [a removeAllObjects]; + [q setSuspended: YES]; + old = [OpOrder new]; + [a addObject: old]; + [old release]; + [old setQueuePriority: NSOperationQueuePriorityLow]; + obj = [OpOrder new]; + [a addObject: obj]; + [obj release]; + [old addDependency: obj]; + obj = [OpOrder new]; + [a addObject: obj]; + [obj release]; + [obj setQueuePriority: NSOperationQueuePriorityHigh]; + [obj addDependency: old]; + [q setSuspended: NO]; + [q addOperations: a waitUntilFinished: YES]; + PASS(([list objectAtIndex: 0] == [a objectAtIndex: 1] && [list objectAtIndex: 1] == [a objectAtIndex: 0]), "operations ran in order of dependency"); + PASS(1 == [[old dependencies] count], "dependencies not removed when done") + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSPointerArray/TestInfo b/Tests/base/NSPointerArray/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSPointerArray/basic.m b/Tests/base/NSPointerArray/basic.m new file mode 100644 index 000000000..b45edd17c --- /dev/null +++ b/Tests/base/NSPointerArray/basic.m @@ -0,0 +1,20 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSPointerArray *testObj; + + testObj = [[NSPointerArray new] autorelease]; + [testObj addPointer: @"hello"]; + test_alloc(@"NSPointerArray"); + test_NSObject(@"NSPointerArray", [NSArray arrayWithObject: testObj]); + test_NSCopying(@"NSPointerArray",@"NSPointerArray", + [NSArray arrayWithObject: testObj], NO, YES); + // test_NSCoding([NSArray arrayWithObject: testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSPointerArray/create.m b/Tests/base/NSPointerArray/create.m new file mode 100644 index 000000000..14e8acd4d --- /dev/null +++ b/Tests/base/NSPointerArray/create.m @@ -0,0 +1,48 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableString *ms; + NSString *val1, *val2, *val3; + NSPointerArray *obj, *old; + NSUInteger rc; + id vals[3]; + + val1 = @"Hello"; + val2 = @"Goodbye"; + val3 = @"Testing"; + + vals[0] = val1; + vals[1] = val2; + vals[2] = val3; + + obj = [[NSPointerArray new] autorelease]; + PASS(obj != nil + && [obj isKindOfClass:[NSPointerArray class]] + && [obj count] == 0, + "+new creates an empty pointer array"); + + [obj addPointer: (void*)@"hello"]; + PASS([obj count] == 1, "+addPointer: increments count"); + [obj addPointer: nil]; + PASS([obj count] == 2, "+addPointer: works with nil"); + + [obj insertPointer: (void*)vals[0] atIndex: 0]; + [obj insertPointer: (void*)vals[1] atIndex: 0]; + [obj insertPointer: (void*)vals[2] atIndex: 0]; + PASS([obj count] == 5 && [obj pointerAtIndex: 2] == (void*)vals[0], + "+insertPointer:atIndex: works"); + + obj = [NSPointerArray pointerArrayWithWeakObjects]; + ms = [@"hello" mutableCopy]; + rc = [ms retainCount]; + [obj addPointer: ms]; + PASS(rc == [ms retainCount], "array with weak references doesn't retain"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/NSPointerArray/general.m b/Tests/base/NSPointerArray/general.m new file mode 100644 index 000000000..a599a2e20 --- /dev/null +++ b/Tests/base/NSPointerArray/general.m @@ -0,0 +1,10 @@ +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSPredicate/TestInfo b/Tests/base/NSPredicate/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSPredicate/basic.m b/Tests/base/NSPredicate/basic.m new file mode 100644 index 000000000..1b14c68d9 --- /dev/null +++ b/Tests/base/NSPredicate/basic.m @@ -0,0 +1,164 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import +#import +#import +#import + +void +testKVC(NSDictionary *dict) +{ + PASS([@"A Title" isEqual: [dict valueForKey: @"title"]], "valueForKeyPath: with string"); + PASS([@"A Title" isEqual: [dict valueForKeyPath: @"title"]], "valueForKeyPath: with string"); + PASS([@"John" isEqual: [dict valueForKeyPath: @"Record1.Name"]], "valueForKeyPath: with string"); + PASS(30 == [[dict valueForKeyPath: @"Record2.Age"] intValue], "valueForKeyPath: with int"); +} + +void +testContains(NSDictionary *dict) +{ + NSPredicate *p; + + p = [NSPredicate predicateWithFormat: @"%@ CONTAINS %@", @"AABBBAA", @"BBB"]; + PASS([p evaluateWithObject: dict], "%%@ CONTAINS %%@"); + p = [NSPredicate predicateWithFormat: @"%@ IN %@", @"BBB", @"AABBBAA"]; + PASS([p evaluateWithObject: dict], "%%@ IN %%@"); +} + +void +testString(NSDictionary *dict) +{ + NSPredicate *p; + + p = [NSPredicate predicateWithFormat: @"%K == %@", @"Record1.Name", @"John"]; + PASS([p evaluateWithObject: dict], "%%K == %%@"); + p = [NSPredicate predicateWithFormat: @"%K MATCHES[c] %@", @"Record1.Name", @"john"]; + PASS([p evaluateWithObject: dict], "%%K MATCHES[c] %%@"); + p = [NSPredicate predicateWithFormat: @"%K BEGINSWITH %@", @"Record1.Name", @"Jo"]; + PASS([p evaluateWithObject: dict], "%%K BEGINSWITH %%@"); + p = [NSPredicate predicateWithFormat: @"(%K == %@) AND (%K == %@)", @"Record1.Name", @"John", @"Record2.Name", @"Mary"]; + PASS([p evaluateWithObject: dict], "(%%K == %%@) AND (%%K == %%@)"); +} + +void +testInteger(NSDictionary *dict) +{ + NSPredicate *p; + + p = [NSPredicate predicateWithFormat: @"%K == %d", @"Record1.Age", 34]; + PASS([p evaluateWithObject: dict], "%%K == %%d"); + p = [NSPredicate predicateWithFormat: @"%K = %@", @"Record1.Age", [NSNumber numberWithInt: 34]]; + PASS([p evaluateWithObject: dict], "%%K = %%@"); + p = [NSPredicate predicateWithFormat: @"%K == %@", @"Record1.Age", [NSNumber numberWithInt: 34]]; + PASS([p evaluateWithObject: dict], "%%K == %%@"); + p = [NSPredicate predicateWithFormat: @"%K < %d", @"Record1.Age", 40]; + PASS([p evaluateWithObject: dict], "%%K < %%d"); + p = [NSPredicate predicateWithFormat: @"%K < %@", @"Record1.Age", [NSNumber numberWithInt: 40]]; + PASS([p evaluateWithObject: dict], "%%K < %%@"); + p = [NSPredicate predicateWithFormat: @"%K <= %@", @"Record1.Age", [NSNumber numberWithInt: 40]]; + PASS([p evaluateWithObject: dict], "%%K <= %%@"); + p = [NSPredicate predicateWithFormat: @"%K <= %@", @"Record1.Age", [NSNumber numberWithInt: 34]]; + PASS([p evaluateWithObject: dict], "%%K <= %%@"); + p = [NSPredicate predicateWithFormat: @"%K > %@", @"Record1.Age", [NSNumber numberWithInt: 20]]; + PASS([p evaluateWithObject: dict], "%%K > %%@"); + p = [NSPredicate predicateWithFormat: @"%K >= %@", @"Record1.Age", [NSNumber numberWithInt: 34]]; + PASS([p evaluateWithObject: dict], "%%K >= %%@"); + p = [NSPredicate predicateWithFormat: @"%K >= %@", @"Record1.Age", [NSNumber numberWithInt: 20]]; + PASS([p evaluateWithObject: dict], "%%K >= %%@"); + p = [NSPredicate predicateWithFormat: @"%K != %@", @"Record1.Age", [NSNumber numberWithInt: 20]]; + PASS([p evaluateWithObject: dict], "%%K != %%@"); + p = [NSPredicate predicateWithFormat: @"%K <> %@", @"Record1.Age", [NSNumber numberWithInt: 20]]; + PASS([p evaluateWithObject: dict], "%%K <> %%@"); + p = [NSPredicate predicateWithFormat: @"%K BETWEEN %@", @"Record1.Age", [NSArray arrayWithObjects: [NSNumber numberWithInt: 20], [NSNumber numberWithInt: 40], nil]]; + PASS([p evaluateWithObject: dict], "%%K BETWEEN %%@"); + p = [NSPredicate predicateWithFormat: @"(%K == %d) OR (%K == %d)", @"Record1.Age", 34, @"Record2.Age", 34]; + PASS([p evaluateWithObject: dict], "(%%K == %%d) OR (%%K == %%d)"); + + +} + +void +testFloat(NSDictionary *dict) +{ + NSPredicate *p; + + p = [NSPredicate predicateWithFormat: @"%K < %f", @"Record1.Age", 40.5]; + PASS([p evaluateWithObject: dict], "%%K < %%f"); + p = [NSPredicate predicateWithFormat: @"%f > %K", 40.5, @"Record1.Age"]; + PASS([p evaluateWithObject: dict], "%%f > %%K"); +} + +void +testAttregate(NSDictionary *dict) +{ + NSPredicate *p; + + p = [NSPredicate predicateWithFormat: @"%@ IN %K", @"Kid1", @"Record1.Children"]; + PASS([p evaluateWithObject: dict], "%%@ IN %%K"); + p = [NSPredicate predicateWithFormat: @"Any %K == %@", @"Record2.Children", @"Girl1"]; + PASS([p evaluateWithObject: dict], "Any %%K == %%@"); +} + +int main() +{ + NSArray *filtered; + NSArray *pitches; + NSArray *expect; + NSMutableDictionary *dict; + NSPredicate *p; + NSDictionary *d; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + dict = [[NSMutableDictionary alloc] init]; + [dict setObject: @"A Title" forKey: @"title"]; + + d = [NSDictionary dictionaryWithObjectsAndKeys: + @"John", @"Name", + [NSNumber numberWithInt: 34], @"Age", + [NSArray arrayWithObjects: @"Kid1", @"Kid2", nil], @"Children", + nil]; + [dict setObject: d forKey: @"Record1"]; + + d = [NSDictionary dictionaryWithObjectsAndKeys: + @"Mary", @"Name", + [NSNumber numberWithInt: 30], @"Age", + [NSArray arrayWithObjects: @"Kid1", @"Girl1", nil], @"Children", + nil]; + [dict setObject: d forKey: @"Record2"]; + + testKVC(dict); + testContains(dict); + testString(dict); + testInteger(dict); + testFloat(dict); + testAttregate(dict); + [dict release]; + + pitches = [NSArray arrayWithObjects: + @"Do", @"Re", @"Mi", @"Fa", @"So", @"La", nil]; + expect = [NSArray arrayWithObjects: @"Do", nil]; + + filtered = [pitches filteredArrayUsingPredicate: + [NSPredicate predicateWithFormat: @"SELF == 'Do'"]]; + PASS([filtered isEqual: expect], "filter with SELF"); + + filtered = [pitches filteredArrayUsingPredicate: + [NSPredicate predicateWithFormat: @"description == 'Do'"]]; + PASS([filtered isEqual: expect], "filter with description"); + + filtered = [pitches filteredArrayUsingPredicate: + [NSPredicate predicateWithFormat: @"SELF == '%@'", @"Do"]]; + PASS([filtered isEqual: [NSArray array]], "filter with format"); + + PASS([NSExpression expressionForEvaluatedObject] + == [NSExpression expressionForEvaluatedObject], + "expressionForEvaluatedObject is unique"); + + p = [NSPredicate predicateWithFormat: @"SELF == 'aaa'"]; + PASS([p evaluateWithObject: @"aaa"], "SELF equality works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSProcessInfo/TestInfo b/Tests/base/NSProcessInfo/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSProcessInfo/basic.m b/Tests/base/NSProcessInfo/basic.m new file mode 100644 index 000000000..6af39994a --- /dev/null +++ b/Tests/base/NSProcessInfo/basic.m @@ -0,0 +1,14 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSProcessInfo *pi; + test_alloc(@"NSProcessInfo"); + pi = [NSProcessInfo processInfo]; + test_NSObject(@"NSProcessInfo", [NSArray arrayWithObject:pi]); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSProcessInfo/general.m b/Tests/base/NSProcessInfo/general.m new file mode 100644 index 000000000..b6318b381 --- /dev/null +++ b/Tests/base/NSProcessInfo/general.m @@ -0,0 +1,47 @@ +#import "Testing.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSProcessInfo *info = [NSProcessInfo processInfo]; + id obj; + unsigned int val; + PASS(info != nil, "NSProcessInfo understands [+processInfo]"); + + obj = [info arguments]; + PASS((info != nil && + [obj isKindOfClass:[NSArray class]] && + [obj count] != 0), + "NSProcessInfo has arguments"); + + obj = [info environment]; + PASS((obj != nil && + [obj isKindOfClass:[NSDictionary class]]), + "NSProcessInfo has environment"); + + obj = [info processName]; + PASS((obj != nil && + [obj isKindOfClass:[NSString class]] && + [obj length] > 0), + "-processName is non-nil"); + + obj = [info globallyUniqueString]; + PASS((obj != nil && + [obj isKindOfClass:[NSString class]] && + [obj length] > 0), + "-globallyUniqueString works"); + + obj = [info operatingSystemName]; + PASS((obj != nil && + [obj isKindOfClass:[NSString class]] && + [obj length] > 0), + "-operatingSystemName works"); + val = [info operatingSystem]; + PASS(val != 0, "-operatingSystem works"); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSProxy/TestInfo b/Tests/base/NSProxy/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSProxy/basic.m b/Tests/base/NSProxy/basic.m new file mode 100644 index 000000000..bb21489cf --- /dev/null +++ b/Tests/base/NSProxy/basic.m @@ -0,0 +1,36 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + char *prefix = "Class 'NSProxy'"; + Class theClass = Nil; + id obj0; + id obj1; + NSZone *testZone = NSCreateZone(1024,1024,1); + + theClass = [NSProxy class]; + PASS(theClass != Nil, "%s exists",prefix); + obj0 = [NSProxy alloc]; + PASS(obj0 != nil, "%s has working alloc",prefix); + PASS_EXCEPTION([obj0 isKindOfClass:theClass];, NSInvalidArgumentException, + "NSProxy -isKindOfClass raises exception"); + + PASS_EXCEPTION([obj0 isMemberOfClass:theClass];, + NSInvalidArgumentException, + "NSProxy -isKindOfClass raises exception"); + + obj1 = [NSProxy allocWithZone:testZone]; + PASS(obj1 != nil, "%s has working allocWithZone:",prefix); + PASS(NSZoneFromPointer(obj1) == testZone, "%s uses zone for alloc",prefix); + PASS([obj1 zone] == testZone, "%s -zone works",prefix); + + PASS([obj1 hash] != 0, "%s has working -hash",prefix); + PASS([obj1 isEqual:obj1] == YES, "%s has working -isEqual:",prefix); + PASS([obj1 class] == theClass, "%s has working -class",prefix); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSProxy/test00.m b/Tests/base/NSProxy/test00.m new file mode 100644 index 000000000..5891e9366 --- /dev/null +++ b/Tests/base/NSProxy/test00.m @@ -0,0 +1,142 @@ +#import "Testing.h" +#import +#import +#import +#import + +@interface MyString : NSString +{ + id _remote; +} +@end + +@interface MyProxy : NSProxy +{ + id _remote; +} +@end + +@implementation MyString +- (id) init +{ + _remote = nil; + return self; +} +- (void) dealloc +{ + [_remote release]; +} +- (unichar) characterAtIndex: (NSUInteger)i +{ + return [_remote characterAtIndex: i]; +} +- (NSUInteger) length +{ + return [_remote length]; +} +- (void) setRemote:(id)remote +{ + ASSIGN(_remote,remote); +} +- (id) remote +{ + return _remote; +} +@end + +@implementation MyProxy +- (id) init +{ + _remote = nil; + return self; +} +- (void) dealloc +{ + [_remote release]; +} +- (NSUInteger) hash +{ + if (_remote) + return [_remote hash]; + else + return [super hash]; +} +- (BOOL) isEqual: (id)other +{ + if (_remote) + return [_remote isEqual: other]; + else + return [super isEqual: other]; +} +- (void) setRemote:(id)remote +{ + ASSIGN(_remote,remote); +} +- (NSString *) description +{ + return [_remote description]; +} +- (id) remote +{ + return _remote; +} +- (NSMethodSignature *) methodSignatureForSelector:(SEL)aSelector +{ + NSMethodSignature *sig = [_remote methodSignatureForSelector:aSelector]; + if (sig == nil) + sig = [self methodSignatureForSelector:aSelector]; + return sig; +} +- (void) forwardInvocation:(NSInvocation *)inv +{ + [inv setTarget:_remote]; + [inv invoke]; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + char *prefix = "The class 'NSProxy' "; + Class theClass = NSClassFromString(@"NSProxy"); + id obj = nil; + id rem = @"Remote"; + id sub = nil; + + PASS(theClass == [NSProxy class], "uses +class to return self"); + PASS([[NSProxy alloc] isProxy] == YES, + "%s implements -isProxy to return YES",prefix); + PASS([[NSProxy alloc] description] != nil, "%s implements -description",prefix); + obj = [[MyProxy alloc] init]; + PASS(obj != nil, "Can create a MyProxy instance"); + PASS([obj isEqual: obj], "proxy isEqual: to self without remote"); + [obj setRemote: rem]; + PASS([obj remote] == rem, "Can set the remote object for the proxy"); + sub = [[MyString alloc] init]; + PASS(sub != nil, "Can create a MyString instance"); + [sub setRemote: rem]; + PASS([sub remote] == rem, "Can set the remote object for the subclass"); + PASS([obj length] == [rem length], "Get the length of the remote object"); + PASS([sub length] == [rem length], "Get the length of the subclass object"); + PASS([obj isEqual: rem], "proxy isEqual: to remote"); + PASS([obj isEqual: sub], "proxy isEqual: to subclass"); + PASS([sub isEqual: rem], "subclass isEqual: to remote"); + PASS([sub isEqual: obj], "subclass isEqual: to proxy"); + PASS([rem isEqual: obj], "remote isEqual: to proxy"); + PASS([rem isEqual: sub], "remote isEqual: to subclass"); + PASS([obj isEqualToString: rem], "proxy isEqualToString: to remote"); + PASS([obj isEqualToString: sub], "proxy isEqualToString: to subclass"); + PASS([sub isEqualToString: rem], "subclass isEqualToString: to remote"); + PASS([sub isEqualToString: obj], "subclass isEqualToString: to proxy"); + PASS([rem isEqualToString: obj], "remote isEqualToString: to proxy"); + PASS([rem isEqualToString: sub], "remote isEqualToString: to subclass"); + PASS([obj compare: rem] == NSOrderedSame, "proxy compare: remote"); + PASS([obj compare: sub] == NSOrderedSame, "proxy compare: subclass"); + PASS([sub compare: rem] == NSOrderedSame, "subclass compare: remote"); + PASS([sub compare: obj] == NSOrderedSame, "subclass compare: proxy"); + PASS([rem compare: obj] == NSOrderedSame, "remote compare: proxy"); + PASS([rem compare: sub] == NSOrderedSame, "remote compare: subclass"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSProxy/test01.m b/Tests/base/NSProxy/test01.m new file mode 100644 index 000000000..58e464bb6 --- /dev/null +++ b/Tests/base/NSProxy/test01.m @@ -0,0 +1,258 @@ +#define _GNU_SOURCE +#define _ISOC99_SOURCE +#import + +#import "Testing.h" + +#include + +typedef struct _GSFinePoint GSFinePoint; +struct _GSFinePoint +{ + double x; + double y; +}; +GSFinePoint +GSMakeFinePoint(double x, double y) +{ + GSFinePoint point; + point.x = x; + point.y = y; + return point; +} +BOOL +GSEqualFinePoints(GSFinePoint aPoint, GSFinePoint bPoint) +{ + return ((aPoint.x == bPoint.x) + && (aPoint.y == bPoint.y)) ? YES : NO; +} + +typedef struct _GSBitField GSBitField; +struct _GSBitField +{ + unsigned int first:1; + unsigned int unused:1; + unsigned int second:1; +}; +GSBitField +GSMakeBitField(BOOL first, BOOL second) +{ + GSBitField field; + field.first = first; + field.second = second; + return field; +} +BOOL +GSEqualBitFields(GSBitField aField, GSBitField bField) +{ + return ((aField.first == bField.first) + && (aField.second == bField.second)) ? YES : NO; +} + +NSDecimal +GSMakeDecimal(unsigned long long mantissa, short exponent, BOOL negative) +{ + NSDecimalNumber *d; + NSDecimal dec; + + d = [NSDecimalNumber decimalNumberWithMantissa: mantissa + exponent: exponent + isNegative: negative]; + dec = [d decimalValue]; + return dec; +} + +NSDecimal +GSDecimalMultiply(NSDecimal left,NSDecimal right) +{ + NSDecimal dec; + NSDecimalMultiply(&dec,&left,&right,NSRoundPlain); + return dec; +} + +BOOL +GSDecimalCompare(NSDecimal left,NSDecimal right) +{ + return NSDecimalCompare(&left,&right); +} + +@interface TypeTester : NSObject +{ +} +-(void)voidPvoid; +-(signed char)sCharPsChar:(signed char)v; +-(unsigned char)uCharPuChar:(unsigned char)v; +-(short)shortPshort:(short)v; +-(unsigned short)uShortPuShort:(unsigned short)v; +-(int)intPint:(int)v; +-(unsigned int)uIntPuInt:(unsigned int)v; +-(long)longPlong:(long)v; +-(unsigned long)uLongPuLong:(unsigned long)v; +-(long long)longlongPlonglong:(long long)v; +-(unsigned long long)ulonglongPulonglong:(unsigned long long)v; +-(float)floatPfloat:(float)v; +-(double)doublePdouble:(double)v; +-(long double)longdoublePlongdouble:(long double)v; +-(id)idPid:(id)v; + +-(NSStringEncoding)enumPenum:(NSStringEncoding)v; +-(NSRange)rangePrange:(NSRange)v; +-(NSPoint)pointPpoint:(NSPoint)v; +-(NSDecimal)decimalPdecimal:(NSDecimal)v; + +-(GSFinePoint)finePointPfinePoint:(GSFinePoint)v; +-(GSBitField)bitFieldPbitField:(GSBitField)v; + +@end + +@implementation TypeTester +-(void)voidPvoid {} +-(signed char)sCharPsChar:(signed char)v { return v - 1; } +-(unsigned char)uCharPuChar:(unsigned char)v { return v - 1; } +-(short)shortPshort:(short)v { return v - 1; } +-(unsigned short)uShortPuShort:(unsigned short)v { return v - 1; } +-(int)intPint:(int)v { return v - 1; } +-(unsigned int)uIntPuInt:(unsigned int)v { return v - 1; } +-(long)longPlong:(long)v { return v - 1; } +-(unsigned long)uLongPuLong:(unsigned long)v { return v - 1; } +-(long long)longlongPlonglong:(long long)v { return v - 1; } +-(unsigned long long)ulonglongPulonglong:(unsigned long long)v { return v - 1; } +-(float)floatPfloat:(float)v { return v - 1.0; } +-(double)doublePdouble:(double)v { return v - 1.0; } +-(long double)longdoublePlongdouble:(long double)v { return v - 1.0; } +-(id)idPid:(id)v { return v == [NSProcessInfo processInfo] ? [NSNull null] : nil; } + +-(NSStringEncoding)enumPenum:(NSStringEncoding)v { return v == NSSymbolStringEncoding ? NSNEXTSTEPStringEncoding : 0; } +-(NSRange)rangePrange:(NSRange)v { return NSMakeRange(v.length,v.location); } +-(NSPoint)pointPpoint:(NSPoint)v { return NSMakePoint(v.y,v.x); } +-(NSDecimal)decimalPdecimal:(NSDecimal)v { return GSDecimalMultiply(v,v); } + +-(GSFinePoint)finePointPfinePoint:(GSFinePoint)v { return GSMakeFinePoint((double)v.y,(double)v.x); } +-(GSBitField)bitFieldPbitField:(GSBitField)v { return GSMakeBitField(v.second,v.first); } + +@end + +@interface MyProxy : NSProxy +{ + id _remote; +} +@end + +@implementation MyProxy +-(id) init +{ + _remote = nil; + return self; +} +- (void) dealloc +{ + [_remote release]; + [super dealloc]; +} +-(void) setRemote:(id)remote +{ + ASSIGN(_remote,remote); +} +-(NSString *) description +{ + return [_remote description]; +} +-(id) remote +{ + return _remote; +} +- (NSMethodSignature *) methodSignatureForSelector:(SEL)aSelector +{ + NSMethodSignature *sig = [_remote methodSignatureForSelector:aSelector]; + if (sig == nil) + sig = [self methodSignatureForSelector:aSelector]; + return sig; +} +- (void) forwardInvocation:(NSInvocation *)inv +{ + [inv setTarget:_remote]; + [inv invoke]; +} +@end + +int +main(int argc, char *argv[]) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id obj = nil; + id rem = [TypeTester new]; + GSFinePoint f0; + GSFinePoint f1; + NSPoint p0; + NSPoint p1; + NSRange r0; + NSRange r1; + + obj = [[MyProxy alloc] init]; + [obj setRemote:rem]; + + [obj voidPvoid]; //shoudn't raise + PASS([obj sCharPsChar: 128] == 127, "Proxy signed char") + PASS([obj uCharPuChar: 255] == 254, "Proxy unsigned char") + PASS([obj shortPshort: SHRT_MAX] == (SHRT_MAX - 1), "Proxy signed short") + PASS([obj uShortPuShort: USHRT_MAX] == (USHRT_MAX - 1), + "Proxy unsigned short"); + PASS([obj intPint: INT_MAX] == (INT_MAX - 1), + "Proxy signed int") + PASS([obj uIntPuInt: UINT_MAX] == (UINT_MAX - 1U), + "Proxy unsigned int") + PASS([obj longPlong: LONG_MAX] == (LONG_MAX - 1L), + "Proxy signed long") + PASS([obj uLongPuLong: ULONG_MAX] == (ULONG_MAX - 1UL), + "Proxy unsigned long") + pass([obj longlongPlonglong: LLONG_MAX] == (LLONG_MAX - 1LL), + "Proxy signed long long"); + PASS([obj ulonglongPulonglong: ULLONG_MAX] == (ULLONG_MAX - 1ULL), + "Proxy unsigned long long") + pass([obj floatPfloat: (float)3.14] == ((float)3.14 - (float)1.0), + "Proxy float"); + pass([obj doublePdouble: (double)3.14] == ((double)3.14 - (double)1.0), + "Proxy double"); + + PASS([obj idPid: [NSProcessInfo processInfo]] == [NSNull null], + "Proxy id") + PASS([obj enumPenum: NSSymbolStringEncoding] == NSNEXTSTEPStringEncoding, + "Proxy enum") + r0 = [obj rangePrange: NSMakeRange(243,437)]; + r1 = NSMakeRange(437,243); + PASS(NSEqualRanges(r0, r1), "Proxy NSRange") + p0 = [obj pointPpoint: NSMakePoint(243.0F,437.0F)]; + p1 = NSMakePoint(437.0F,243.0F); + PASS(NSEqualPoints(p0, p1), "Proxy NSPoint") + f0 = [obj finePointPfinePoint: GSMakeFinePoint(243.0L,437.0L)]; + f1 = GSMakeFinePoint(437.0L,243.0L); + PASS(GSEqualFinePoints(f0, f1), "Proxy GSFinePoint") +#if 0 + /* These next two are disabled because they test passing structures as + * parameters, a feature which has never worked and which maybe doesn't + * need to. + * We should enable these tests if/when the capability is ever implemented. + */ + BOOL ok; + + ok = GSDecimalCompare([obj decimalPdecimal: GSMakeDecimal(321,7,YES)], + GSDecimalMultiply(GSMakeDecimal(321,7,YES),GSMakeDecimal(321,7,YES)))==0; + PASS(ok, "Proxy NSDecimal") +#endif +#if 0 + /* + Disabled since this currently causes segfaults. Yet this feature is hardly ever used. + Note also: file:///usr/share/doc/libffi-dev/html/Missing-Features.html#Missing-Features: + libffi is missing a few features. We welcome patches to add support for these. + + * There is no support for calling varargs functions. This may work on some platforms, depending on how the ABI is defined, but it is not reliable. + * There is no support for bit fields in structures. + * The closure API is + * The raw†API is undocumented. + */ + PASS(GSEqualBitFields([obj bitFieldPbitField: GSMakeBitField(0,1)],GSMakeBitField(1,0)), "Proxy GSBitField") +#endif + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSRunLoop/TestInfo b/Tests/base/NSRunLoop/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSRunLoop/basic.m b/Tests/base/NSRunLoop/basic.m new file mode 100644 index 000000000..cf9947118 --- /dev/null +++ b/Tests/base/NSRunLoop/basic.m @@ -0,0 +1,21 @@ +#import "ObjectTesting.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id testObj; + + PASS([NSRunLoop new] == nil, "run loop initialises to nil"); + testObj = [NSRunLoop currentRunLoop]; + test_NSObject(@"NSRunLoop", [NSArray arrayWithObject:testObj]); + + PASS([NSTimer new] == nil, "timer initialises to nil"); + ASSIGN(testObj, [[NSTimer alloc] initWithFireDate: 0 interval: 0 target: [NSObject class] selector: @selector(description) userInfo: nil repeats: NO]); + test_NSObject(@"NSTimer", [NSArray arrayWithObject:testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSRunLoop/general.m b/Tests/base/NSRunLoop/general.m new file mode 100644 index 000000000..95c0363a3 --- /dev/null +++ b/Tests/base/NSRunLoop/general.m @@ -0,0 +1,36 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMethodSignature *sig; + NSInvocation *inv; + NSTimer *tim; + NSRunLoop *run; + NSDate *date; + + sig = [NSTimer instanceMethodSignatureForSelector:@selector(isValid)]; + inv = [NSInvocation invocationWithMethodSignature: sig]; + + run = [NSRunLoop currentRunLoop]; + PASS(run != nil, "NSRunLoop understands [+currentRunLoop]"); + PASS([run currentMode] == nil, "-currentMode returns nil"); + + PASS_RUNS(date = [NSDate dateWithTimeIntervalSinceNow:3]; + [run runUntilDate:date];, + "-runUntilDate: works"); + PASS_RUNS(date = [NSDate dateWithTimeIntervalSinceNow:5]; + tim = [NSTimer scheduledTimerWithTimeInterval: 2.0 + invocation:inv + repeats:YES];, + "-runUntilDate: works with a timer"); + + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSRunLoop/performers.m b/Tests/base/NSRunLoop/performers.m new file mode 100644 index 000000000..39c970dc0 --- /dev/null +++ b/Tests/base/NSRunLoop/performers.m @@ -0,0 +1,112 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +#include + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSRunLoop *run; + NSDate *date; + NSMutableString *str; + NSFileHandle *fh = [NSFileHandle fileHandleWithStandardInput]; + NSTimeInterval delay = 0.1; + + [fh retain]; + [fh readInBackgroundAndNotify]; + + run = [NSRunLoop currentRunLoop]; + + /* A run loop with no input sources does nothing when you tell it to run. + Thus, we need to provide at least one input source ... */ + + str = [[NSMutableString alloc] init]; + [run performSelector: @selector(appendString:) + target: str + argument: @"foo" + order: 0 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; + [run runUntilDate: date]; + PASS([str isEqual: @"foo"], + "-performSelector:target:argument:order:modes: works for one performer"); + + str = [[NSMutableString alloc] init]; + [run performSelector: @selector(appendString:) + target: str + argument: @"foo" + order: 0 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; + [run runUntilDate: date]; + [run runUntilDate: date]; + PASS([str isEqual: @"foo"], + "-performSelector:target:argument:order:modes: only sends the message once"); + + str = [[NSMutableString alloc] init]; + [run performSelector: @selector(appendString:) + target: str + argument: @"bar" + order: 11 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + [run performSelector: @selector(appendString:) + target: str + argument: @"foo" + order: 10 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; + [run runUntilDate: date]; + PASS([str isEqual: @"foobar"], + "-performSelector:target:argument:order:modes: orders performers correctly"); + + str = [[NSMutableString alloc] init]; + [run performSelector: @selector(appendString:) + target: str + argument: @"foo" + order: 10 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + [run performSelector: @selector(appendString:) + target: str + argument: @"bar" + order: 11 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + [run performSelector: @selector(appendString:) + target: str + argument: @"zot" + order: 11 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + [run cancelPerformSelector: @selector(appendString:) + target: str + argument: @"bar"]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; + [run runUntilDate: date]; + PASS([str isEqual: @"foozot"], + "-cancelPerformSelector:target:argument: works"); + + str = [[NSMutableString alloc] init]; + [run performSelector: @selector(appendString:) + target: str + argument: @"foo" + order: 10 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + [run performSelector: @selector(appendString:) + target: str + argument: @"zot" + order: 11 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]]; + [run cancelPerformSelectorsWithTarget: str]; + date = [NSDate dateWithTimeIntervalSinceNow: delay]; + [run runUntilDate: date]; + PASS([str isEqualToString: @""], "-cancelPerformSelectorsWithTarget: works %s",[str cString]); + + [fh closeFile]; + [fh release]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSRunLoop/thread.m b/Tests/base/NSRunLoop/thread.m new file mode 100644 index 000000000..97a43ee38 --- /dev/null +++ b/Tests/base/NSRunLoop/thread.m @@ -0,0 +1,212 @@ +#import "ObjectTesting.h" + +#import +#import +#import +#import +#import +#import +#import + +@interface ThreadTest : NSObject { + char acceptEmptyBlocks; + char acceptTimerBlocks; + char blockForEmpty; + char blockForInput; + char blockForTimer; + char limitForEmpty; + char limitForInput; + char limitForTimer; + char moreForEmpty; + char moreForInput; + char moreForTimer; + char performed; +} +- (void) notified: (NSNotification*)n; +- (void) timeout: (NSTimer*)t; +- (void) thread1: (id)o; +@end + +@implementation ThreadTest + +- (void) notified: (NSNotification*)n +{ + NSLog(@"Notified: %@", n); +} + +- (void) timeout: (NSTimer*)t +{ +} + +- (void) thread1: (id)o +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSNotificationCenter *nc; + NSRunLoop *loop; + NSFileHandle *fh; + NSTimer *timer; + NSDate *end; + NSDate *start; + + nc = [NSNotificationCenter defaultCenter]; + loop = [NSRunLoop currentRunLoop]; + + end = [loop limitDateForMode: NSDefaultRunLoopMode]; + if (end == nil) + limitForEmpty = 'N'; + else + limitForEmpty = 'Y'; + + end = [NSDate dateWithTimeIntervalSinceNow: 0.2]; + start = [NSDate date]; + if ([loop runMode: NSDefaultRunLoopMode beforeDate: end] == YES) + moreForEmpty = 'Y'; + else + moreForEmpty = 'N'; + if (fabs([start timeIntervalSinceNow]) < 0.01) + blockForEmpty = 'N'; + else + blockForEmpty = 'Y'; + + end = [NSDate dateWithTimeIntervalSinceNow: 0.2]; + start = [NSDate date]; + [loop acceptInputForMode: NSDefaultRunLoopMode beforeDate: end]; + if (fabs([start timeIntervalSinceNow]) < 0.01) + acceptEmptyBlocks = 'N'; + else + acceptEmptyBlocks = 'Y'; + + timer = [NSTimer timerWithTimeInterval: 2.0 + target: self + selector: @selector(timeout:) + userInfo: nil + repeats: NO]; + [loop addTimer: timer forMode: NSDefaultRunLoopMode]; + end = [loop limitDateForMode: NSDefaultRunLoopMode]; + if (fabs([end timeIntervalSinceDate: [timer fireDate]]) < 0.01) + limitForTimer = 'Y'; + else + limitForTimer = 'N'; + end = [NSDate dateWithTimeIntervalSinceNow: 0.2]; + start = [NSDate date]; + if ([loop runMode: NSDefaultRunLoopMode beforeDate: end] == YES) + moreForTimer = 'Y'; + else + moreForTimer = 'N'; + if (fabs([start timeIntervalSinceNow]) < 0.01) + blockForTimer = 'N'; + else + blockForTimer = 'Y'; + + end = [NSDate dateWithTimeIntervalSinceNow: 0.2]; + start = [NSDate date]; + [loop acceptInputForMode: NSDefaultRunLoopMode beforeDate: end]; + if (fabs([start timeIntervalSinceNow]) < 0.01) + acceptTimerBlocks = 'N'; + else + acceptTimerBlocks = 'Y'; + + [timer invalidate]; + + fh = [NSFileHandle fileHandleWithStandardInput]; + [nc addObserver: self selector:@selector(notified:) + name: nil object:fh]; + [fh readInBackgroundAndNotify]; + end = [loop limitDateForMode: NSDefaultRunLoopMode]; + if ([end isEqual: [NSDate distantFuture]] == YES) + limitForInput = 'Y'; + else + limitForInput = 'N'; + end = [NSDate dateWithTimeIntervalSinceNow: 0.2]; + start = [NSDate date]; + if ([loop runMode: NSDefaultRunLoopMode beforeDate: end] == YES) + moreForInput = 'Y'; + else + moreForInput = 'N'; + [timer invalidate]; + if (fabs([start timeIntervalSinceNow]) < 0.01) + blockForInput = 'N'; + else + blockForInput = 'Y'; + [nc removeObserver: self]; + [pool release]; +} + +- (void) thread2: (id)o +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSRunLoop *loop; + NSDate *end; + + loop = [NSRunLoop currentRunLoop]; + + [NSTimer scheduledTimerWithTimeInterval: 2.0 + target: self + selector: @selector(timeout:) + userInfo: nil + repeats: NO]; + + end = [NSDate dateWithTimeIntervalSinceNow: 2.0]; + while ([end timeIntervalSinceNow] > 0) + { + [loop runUntilDate: end]; + } + [pool release]; +} + +- (void) threadEvent: (id)ignored +{ + performed = 'Y'; +} + +- (void) run +{ + NSDate *until = [NSDate dateWithTimeIntervalSinceNow: 5.0]; + NSThread *t; + + [NSTimer scheduledTimerWithTimeInterval: 5.0 + target: self + selector: @selector(timeout:) + userInfo: nil + repeats: YES]; + + [NSThread detachNewThreadSelector: @selector(thread1:) + toTarget: self + withObject: nil]; + t = [[NSThread alloc] initWithTarget: self + selector: @selector(thread2:) + object: nil]; + [t start]; + + [self performSelector: @selector(threadEvent:) + onThread: t + withObject: nil + waitUntilDone: NO]; + while ([until timeIntervalSinceNow] > 0) + { + [[NSRunLoop currentRunLoop] runUntilDate: until]; + } + + PASS(acceptEmptyBlocks == 'N', "Accept with no inputs or timers will exit"); + PASS(acceptTimerBlocks == 'Y', "Accept with timers will not exit"); + PASS(blockForEmpty == 'N', "A loop with no inputs or timers will exit"); + PASS(blockForInput == 'Y', "A loop with an input source will block"); + PASS(blockForTimer == 'Y', "A loop with a timer will block"); + PASS(limitForEmpty == 'N', "A loop with no inputs or timers has no limit"); + PASS(limitForInput == 'Y', "A loop with an input source has distant future"); + PASS(limitForTimer == 'Y', "A loop with a timer has timer fire date"); + PASS(moreForEmpty == 'N', "A loop with no inputs or timers has no more"); + PASS(moreForInput == 'Y', "A loop with an input source has more"); + PASS(moreForTimer == 'Y', "A loop with a timer has more"); + PASS(performed == 'Y', "Methods will be performed in a loop without inputs"); +} + +@end + +int main(int argc, char *argv[]) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + [[[ThreadTest new] autorelease] run]; + [pool release]; + return 0; +} diff --git a/Tests/base/NSScanner/TestInfo b/Tests/base/NSScanner/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSScanner/test00.m b/Tests/base/NSScanner/test00.m new file mode 100644 index 000000000..2323008d2 --- /dev/null +++ b/Tests/base/NSScanner/test00.m @@ -0,0 +1,60 @@ +#import "Testing.h" +#import +#import +#import +#import +#import + +static BOOL scanAWord(NSScanner *theScanner, NSCharacterSet *cSet) +{ + BOOL ret = ([theScanner scanUpToCharactersFromSet:cSet intoString:NULL] + && [theScanner scanCharactersFromSet:cSet intoString:NULL]); + return ret; +} + +static BOOL scanThreeWords(NSString *string,NSCharacterSet *separators) +{ + NSScanner *scanner = [NSScanner scannerWithString:string]; + /* so it doesn't skip the whitespace */ + [scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@""]]; + return ((scanAWord(scanner,separators) + && ![scanner isAtEnd] + && scanAWord(scanner,separators) + && ![scanner isAtEnd] + && scanAWord(scanner,separators) + && [scanner isAtEnd])); +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *str = nil; + id charSet = nil; + + charSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + + str = [NSString stringWithCString:"one\ntwo\nthree\n"]; + PASS(scanThreeWords(str,charSet), + "scanning three words separated by newlines"); + + str = @"one two three "; + PASS(scanThreeWords(str,charSet), + "scanning three words separated by spaces"); + + str = @"one\ttwo\tthree\t"; + PASS(scanThreeWords(str,charSet), + "scanning three words separated by tabs"); + + str = @"one \ntwo \nthree \n"; + PASS(scanThreeWords(str,charSet), + "scanning three words separated by newlines and spaces"); + + charSet = [charSet mutableCopy]; + [charSet addCharactersInString:@";"]; + str = @"one ;two ;three ;"; + PASS(scanThreeWords(str,charSet), + "scanning three words separated by spaces and semi-colons"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSScanner/test01.m b/Tests/base/NSScanner/test01.m new file mode 100644 index 000000000..44d3f0564 --- /dev/null +++ b/Tests/base/NSScanner/test01.m @@ -0,0 +1,124 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import + +static BOOL scanInt(int value, int *retp) +{ + NSString *str = [[NSNumber numberWithInt:value] description]; + NSScanner *scn = [NSScanner scannerWithString:str]; + return ([scn scanInt:retp] && value == *retp); +} +/* this didn't seem to be used in any of the NSScanner guile tests + so this function is untested. + */ +static BOOL scanIntOverflow(int value, int *retp) +{ + NSString *str = [[NSNumber numberWithFloat:value] description]; + NSScanner *scn = [NSScanner scannerWithString:str]; + int intmax = 2147483647; + int intmin = (0 - (intmax - 1)); + + return ([scn scanInt:retp] + && (0 > value) ? (intmin == *retp) : (intmax == *retp)); +} + +#if defined(GNUSTEP_BASE_LIBRARY) +static BOOL scanRadixUnsigned(NSString *str, + int expectValue, + unsigned int expectedValue, + int expectedScanLoc, + int *retp) +{ + NSScanner *scn = [NSScanner scannerWithString:str]; + [scn scanRadixUnsignedInt:retp]; + return ((expectValue == 1) ? (expectedValue == *retp) : YES + && expectedScanLoc == [scn scanLocation]); +} +#endif + +static BOOL scanHex(NSString *str, + int expectValue, + unsigned int expectedValue, + int expectedScanLoc, + int *retp) +{ + NSScanner *scn = [NSScanner scannerWithString:str]; + [scn scanHexInt:retp]; + return ((expectValue == 1) ? (expectedValue == *retp) : YES + && expectedScanLoc == [scn scanLocation]); +} +static BOOL scanDouble(NSString *str, + double expectedValue, + double *retp) +{ + NSScanner *scn = [NSScanner scannerWithString:str]; + [scn scanDouble:retp]; + return ((0.00000000001 >= fabs(expectedValue - *retp)) + && [str length] == [scn scanLocation]); +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + int ret; + double dret; + int intmax = 2147483647; + int intmin = (0 - (intmax - 1)); + NSScanner *scn; + + PASS(scanInt((intmax - 20),&ret), "NSScanner large ints"); + PASS(scanInt((intmin + 20),&ret), "NSScanner small ints"); + + scn = [NSScanner scannerWithString:@"1234F00"]; + PASS(([scn scanInt:&ret] && ([scn scanLocation] == 4)), + "NSScanner non-digits terminate scan"); + + scn = [NSScanner scannerWithString:@"junk"]; + PASS((![scn scanInt:&ret] && ([scn scanLocation] == 0)), + "NSScanner non-digits terminate scan"); + + scn = [NSScanner scannerWithString:@"junk"]; + PASS(![scn scanInt:&ret] && ([scn scanLocation] == 0), + "NSScanner non-digits dont consume characters to be skipped"); + +#if defined(GNUSTEP_BASE_LIBRARY) + PASS(scanRadixUnsigned(@"1234FOO", 1, 1234, 4, &ret) + && scanRadixUnsigned(@"01234FOO", 1, 01234, 5, &ret) + && scanRadixUnsigned(@"0x1234FOO", 1, 0x1234F, 7, &ret) + && scanRadixUnsigned(@"0X1234FOO", 1, 0x1234F, 7, &ret) + && scanRadixUnsigned(@"012348FOO", 1, 01234, 5, &ret), + "NSScanner radiux unsigned (non-digits terminate scan)"); + + PASS(scanRadixUnsigned(@"FOO", 0, 0, 0, &ret) + && scanRadixUnsigned(@" FOO", 0, 0, 0, &ret) + && scanRadixUnsigned(@" 0x ", 0, 0, 0, &ret), + "NSScanner radiux unsigned (non-digits dont move scan)"); +#endif + + PASS(scanHex(@"1234FOO", 1, 0x1234F, 5, &ret) + && scanHex(@"01234FOO", 1, 0x1234F, 6, &ret), + "NSScanner hex (non-digits terminate scan)"); + /* dbl1 = 123.456; + dbl2 = 123.45678901234567890123456789012345678901234567; + dbl3 = 1.23456789; + */ + PASS(scanDouble(@"123.456",123.456,&dret) + && scanDouble(@"123.45678901234567890123456789012345678901234567", + 123.45678901234567890123456789012345678901234567,&dret) + && scanDouble(@"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123456789e+100", 1.23456789, &dret), + "NSScanner scans doubles"); + + PASS(scanDouble(@"1e0", 1, &dret) + && scanDouble(@"1e1", 10, &dret) + && scanDouble(@"1e+1", 10, &dret) + && scanDouble(@"1e+10", 1e10, &dret) + && scanDouble(@"1e-1", 1e-1, &dret) + && scanDouble(@"1e-10", 1e-10, &dret), + "NSScanner scans double with exponents"); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSSet/TestInfo b/Tests/base/NSSet/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSSet/basic.m b/Tests/base/NSSet/basic.m new file mode 100644 index 000000000..f5e128290 --- /dev/null +++ b/Tests/base/NSSet/basic.m @@ -0,0 +1,28 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSSet *testObj; + NSMutableArray *testObjs = [NSMutableArray new]; + + testObj = [NSSet new]; + [testObjs addObject:testObj]; + PASS(testObj != nil && [testObj count] == 0, + "can create an empty set"); + + testObj = [NSSet setWithObject:@"Hello"]; + [testObjs addObject:testObj]; + PASS(testObj != nil && [testObj count] == 1, "can create a set with one element"); + + test_NSObject(@"NSSet", testObjs); + test_NSCoding(testObjs); + test_NSCopying(@"NSSet", @"NSMutableSet", testObjs, YES, NO); + test_NSMutableCopying(@"NSSet", @"NSMutableSet", testObjs); + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSSortDescriptor/TestInfo b/Tests/base/NSSortDescriptor/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSSortDescriptor/basic.m b/Tests/base/NSSortDescriptor/basic.m new file mode 100644 index 000000000..eeeeac8e0 --- /dev/null +++ b/Tests/base/NSSortDescriptor/basic.m @@ -0,0 +1,66 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *array; + NSSortDescriptor *s1; + NSSortDescriptor *s2; + NSSortDescriptor *s3; + NSSortDescriptor *s4; + NSDictionary *d1; + NSDictionary *d2; + NSDictionary *d3; + NSDictionary *d4; + NSArray *a1; + NSArray *a2; + NSArray *a3; + + s1 = [[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES]; + PASS(s1 != nil, "can create a sort descriptor"); + + array = [NSArray arrayWithObject: s1]; + test_NSObject(@"NSSortDescriptor", array); + test_NSCoding(array); + test_NSCopying(@"NSSortDescriptor", @"NSSortDescriptor", array, NO, NO); + + s2 = [[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES]; + s3 = [[NSSortDescriptor alloc] initWithKey: @"other" ascending: YES]; + s4 = [[NSSortDescriptor alloc] initWithKey: @"other" ascending: NO]; + PASS([s1 hash] == [s2 hash], "hash for similar descriptors is the same"); + PASS([s1 isEqual: s2], "similar descriptors are equal"); + PASS(![s1 isEqual: s3], "different keyed descriptors are not equal"); + PASS(![s3 isEqual: s4], "different ordered descriptors are not equal"); + + d1 = [NSDictionary dictionaryWithObjectsAndKeys: + @"1", @"name", + @"1", @"other", + nil]; + d2 = [NSDictionary dictionaryWithObjectsAndKeys: + @"1", @"name", + @"2", @"other", + nil]; + d3 = [NSDictionary dictionaryWithObjectsAndKeys: + @"2", @"name", + @"1", @"other", + nil]; + d4 = [NSDictionary dictionaryWithObjectsAndKeys: + @"2", @"name", + @"2", @"other", + nil]; + PASS([s3 compareObject: d3 toObject: d4] == NSOrderedAscending, + "basic comparison works for ascending descriptor"); + PASS([s4 compareObject: d3 toObject: d4] == NSOrderedDescending, + "basic comparison works for descending descriptor"); + + array = [NSArray arrayWithObjects: s3, s1, nil]; + a1 = [NSArray arrayWithObjects: d1, d2, d3, d4, nil]; + a2 = [NSArray arrayWithObjects: d1, d3, d2, d4, nil]; + a3 = [a1 sortedArrayUsingDescriptors: array]; + PASS([a2 isEqual: a3], "simple multilevel sort works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSStream/TestInfo b/Tests/base/NSStream/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSStream/basic.m b/Tests/base/NSStream/basic.m new file mode 100644 index 000000000..079d68d40 --- /dev/null +++ b/Tests/base/NSStream/basic.m @@ -0,0 +1,18 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSInputStream *t1; + NSOutputStream *t2; + NSHost *host = [NSHost hostWithName:@"localhost"]; + + [NSStream getStreamsToHost:host port:80 inputStream:&t1 outputStream:&t2]; + + test_NSObject(@"NSStream", [NSArray arrayWithObjects:t1, t2, nil]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSStream/memandfile.m b/Tests/base/NSStream/memandfile.m new file mode 100644 index 000000000..c2e8f5a83 --- /dev/null +++ b/Tests/base/NSStream/memandfile.m @@ -0,0 +1,58 @@ +/** + * This test tests synchronized copying between mem and file + */ +#import "ObjectTesting.h" +#import +#import + +static void copyStream(NSInputStream *input, NSOutputStream *output) +{ + uint8_t buffer[4096]; + + [input open]; + [output open]; + while([input hasBytesAvailable]) + { + int len = [input read:buffer maxLength:4096]; + uint8_t *p = buffer; + while(len>0) + { + int written = [output write:p maxLength:len]; + p = p + written; + len = len - written; + } + } + [input close]; + [output close]; +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + // first test, file to memory copy + NSString *path = @"memandfile.m"; + NSData *goldData = [NSData dataWithContentsOfFile:path]; + NSInputStream *input = [NSInputStream inputStreamWithFileAtPath:path]; + NSOutputStream *output = [NSOutputStream outputStreamToMemory]; + + copyStream(input, output); + + NSData *answer = [output propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; + PASS([goldData isEqualToData:answer], "file to memory copy ok"); + + // second test, memory to file copy + NSString *pathO = @"temp"; + NSInputStream *input2 = [NSInputStream inputStreamWithData:goldData]; + NSOutputStream *output2 = [NSOutputStream outputStreamToFileAtPath:pathO append:NO]; + + copyStream(input2, output2); + + NSData *answer2 = [NSData dataWithContentsOfFile:pathO]; + PASS([goldData isEqualToData:answer2], "memory to file copy ok"); + + [[NSFileManager defaultManager] removeFileAtPath: pathO handler: nil]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSStream/memandfile_2.m b/Tests/base/NSStream/memandfile_2.m new file mode 100644 index 000000000..421d46eff --- /dev/null +++ b/Tests/base/NSStream/memandfile_2.m @@ -0,0 +1,154 @@ +/** + * This test tests asynchronized copying between mem and file using a runloop + */ +#import "ObjectTesting.h" +#import +#import + +static NSOutputStream *defaultOutput = nil; +static NSInputStream *defaultInput = nil; + +@interface Listener1 : NSObject +@end + +@interface Listener2 : NSObject +@end + +@implementation Listener1 + +- (void)stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ + static uint8_t buffer[4096]; + switch (streamEvent) + { + case NSStreamEventHasBytesAvailable: + { + int len = [(NSInputStream*)theStream read: buffer maxLength: 4096]; + uint8_t *p = buffer; + + if (len==0) + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + } + else + { + while(len>0) + { + int written = [defaultOutput write: p maxLength: len]; + p = p + written; + len = len - written; + } + } + break; + } + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + break; + } + default: + { + NSAssert1(1, @"Error! code is %d", [[theStream streamError] code]); + break; + } + } +} + +@end + +@implementation Listener2 + +- (void)stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ + static uint8_t *p; + static uint8_t buffer[4096]; + static int len = 0; + + switch (streamEvent) + { + case NSStreamEventHasSpaceAvailable: + { + if (len==0) + { + len = [defaultInput read: buffer maxLength: 4096]; + p = buffer; + } + if (len==0) + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + } + else + { + int written = [(NSOutputStream*)theStream write: p maxLength: len]; + p = p + written; + len = len - written; + } + break; + } + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + break; + } + default: + { + NSAssert1(1, @"Error! code is %d", [[theStream streamError] code]); + break; + } + } +} + +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + + // first test, file to memory copy + NSString *path = @"memandfile.m"; + NSData *goldData = [NSData dataWithContentsOfFile: path]; + NSInputStream *input = [NSInputStream inputStreamWithFileAtPath: path]; + NSOutputStream *output = [NSOutputStream outputStreamToMemory]; + Listener1 *l1 = [[Listener1 new] autorelease]; + + [input setDelegate: l1]; + [input scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [input open]; + [output open]; + defaultOutput = output; + [rl run]; + + NSData *answer = [output propertyForKey: NSStreamDataWrittenToMemoryStreamKey]; + PASS([goldData isEqualToData: answer], "file to memory copy ok"); + + // second test, memory to file copy + NSString *pathO = @"temp"; + NSInputStream *input2 = [NSInputStream inputStreamWithData: goldData]; + NSOutputStream *output2 = [NSOutputStream outputStreamToFileAtPath: pathO append: NO]; + Listener1 *l2 = [[Listener2 new] autorelease]; + + [output2 setDelegate: l2]; + [output2 scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [input2 open]; + [output2 open]; + defaultInput = input2; + [rl run]; + + NSData *answer2 = [NSData dataWithContentsOfFile: pathO]; + PASS([goldData isEqualToData: answer2], "memory to file copy ok"); + + [[NSFileManager defaultManager] removeFileAtPath: pathO handler: nil]; + + [arp release]; + return 0; +} + diff --git a/Tests/base/NSStream/pipe.m b/Tests/base/NSStream/pipe.m new file mode 100644 index 000000000..32f878821 --- /dev/null +++ b/Tests/base/NSStream/pipe.m @@ -0,0 +1,90 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +/** + * This test tests a pipe using NSStream + */ +#import "ObjectTesting.h" +#import +#import + +static NSOutputStream *defaultOutput = nil; +static NSInputStream *defaultInput = nil; +static NSData *goldData; +static NSMutableData *testData; + +@interface Listener : NSObject +@end + +@implementation Listener + +- (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent +{ + static uint8_t buffer[4096]; + static int writePointer=0; + + switch (streamEvent) + { + case NSStreamEventHasSpaceAvailable: + { + NSAssert(theStream==defaultOutput, @"Wrong stream for writing"); + if (writePointer<[goldData length]) + { + int writeReturn = [defaultOutput write:[goldData bytes]+writePointer + maxLength:[goldData length]-writePointer]; + writePointer += writeReturn; + } + else + [defaultOutput close]; + break; + } + case NSStreamEventHasBytesAvailable: + { + int readSize; + NSAssert(theStream==defaultInput, @"Wrong stream for reading"); + readSize = [defaultInput read:buffer maxLength:4096]; + NSAssert(readSize>=0, @"read error"); + if (readSize==0) + [defaultInput close]; + else + [testData appendBytes:buffer length:readSize]; + break; + } + case NSStreamEventErrorOccurred: + { + NSAssert1(1, @"Error! code is %d", [[theStream streamError] code]); + break; + } + default: + break; + } +} + +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + Listener *li = [[Listener new] autorelease]; + NSString *path = @"pipe.m"; + + [NSStream pipeWithInputStream:&defaultInput outputStream:&defaultOutput]; + goldData = [NSData dataWithContentsOfFile:path]; + testData = [NSMutableData dataWithCapacity:4096]; + [defaultInput setDelegate:li]; + [defaultOutput setDelegate:li]; + [defaultInput scheduleInRunLoop:rl forMode:NSDefaultRunLoopMode]; + [defaultOutput scheduleInRunLoop:rl forMode:NSDefaultRunLoopMode]; + [defaultInput open]; + [defaultOutput open]; + [rl run]; + + PASS([goldData isEqualToData:testData], "Local pipe"); + [arp release]; + return 0; +} +#else +int main() +{ + return 0; +} +#endif diff --git a/Tests/base/NSStream/socket.m b/Tests/base/NSStream/socket.m new file mode 100644 index 000000000..f8d91cf7e --- /dev/null +++ b/Tests/base/NSStream/socket.m @@ -0,0 +1,180 @@ +/** + * This test tests basic client side socket + */ +#import "ObjectTesting.h" +#import +#import + +#if defined(GS_USE_GNUTLS) +#define SSL_SUPPORTED GS_USE_GNUTLS +#else +#define SSL_SUPPORTED 1 /* Assume Apple supports it */ +#endif + +static NSOutputStream *defaultOutput = nil; +static NSInputStream *defaultInput = nil; +static int byteCount = 0; + +static const uint8_t * rawstring = "GET / HTTP/1.0\r\n\r\n"; +static BOOL done = NO; + +@interface Listener : NSObject +@end + +@implementation Listener + +- (void)stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ + static uint8_t buffer[4096]; + static BOOL doneWrite = NO; + int readSize; +NSLog(@"Got %d on %p", streamEvent, theStream); + switch (streamEvent) + { + case NSStreamEventOpenCompleted: + { + if (theStream == defaultOutput) + { + doneWrite = NO; + } + break; + } + case NSStreamEventHasSpaceAvailable: + { + NSAssert(theStream==defaultOutput, @"Wrong stream for reading"); + if (doneWrite == NO) + { + // there may be a problem so that write is not complete. + // However, since this is so short it is pretty much always ok. + NSLog(@"Written request"); + doneWrite = YES; + [defaultOutput write: rawstring + maxLength: strlen((char*)rawstring)]; + } +/* + else + { + [defaultOutput close]; + [defaultOutput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Closed %p", defaultOutput); + } +*/ + break; + } + case NSStreamEventHasBytesAvailable: + { + NSAssert(theStream==defaultInput, @"Wrong stream for reading"); + readSize = [defaultInput read: buffer maxLength: 4096]; + if (readSize < 0) + { + // it is possible that readSize<0 but not an Error. + // For example would block + NSAssert([defaultInput streamError]==nil, @"read error"); + } + if (readSize == 0) + { + [defaultInput close]; + [defaultInput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Closed %p", defaultInput); + } + else + { + byteCount += readSize; + NSLog(@"Read %d: %*.*s", readSize, readSize, readSize, buffer); + } + break; + } + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Close %p", theStream); + done = YES; + break; + } + default: + { + NSAssert1(1, @"Error! code is %d", [[theStream streamError] code]); + break; + } + } +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSRunLoop *rl; + NSHost *host; + Listener *li; + NSDate *d; + + rl = [NSRunLoop currentRunLoop]; + host = [NSHost hostWithName: @"www.google.com"]; + //host = [NSHost hostWithName: @"localhost"]; + +#if 0 + li = [[Listener new] autorelease]; + [NSStream getStreamsToHost: host port: 80 + inputStream: &defaultInput outputStream: &defaultOutput]; + + [defaultInput setDelegate: li]; + [defaultOutput setDelegate: li]; + [defaultInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [defaultOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [defaultInput open]; + [defaultOutput open]; + + d = [NSDate dateWithTimeIntervalSinceNow: 30]; + while (done == NO && [d timeIntervalSinceNow] > 0.0) + { + [rl runMode: NSDefaultRunLoopMode beforeDate: d]; + } + + // I cannot verify the content at www.google.com, + // so as long as it has something, that is PASSing + PASS(byteCount>0, "read www.google.com"); + [defaultInput setDelegate: nil]; + [defaultOutput setDelegate: nil]; +#endif + + START_SET("NSStream SSL") + if (!SSL_SUPPORTED) + SKIP("NSStream SSL functions not supported\nThe GNU TLS library was not provided when GNUstep-base was configured/built.") + done = NO; + byteCount = 0; + defaultInput = nil; + defaultOutput = nil; + li = [[Listener new] autorelease]; + [NSStream getStreamsToHost: host port: 443 + inputStream: &defaultInput outputStream: &defaultOutput]; + + [defaultInput setDelegate: li]; + [defaultOutput setDelegate: li]; + [defaultInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [defaultOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [defaultInput setProperty: NSStreamSocketSecurityLevelNegotiatedSSL + forKey: NSStreamSocketSecurityLevelKey]; + [defaultOutput setProperty: NSStreamSocketSecurityLevelNegotiatedSSL + forKey: NSStreamSocketSecurityLevelKey]; + [defaultInput open]; + [defaultOutput open]; + + d = [NSDate dateWithTimeIntervalSinceNow: 30]; + while (done == NO && [d timeIntervalSinceNow] > 0.0) + { + [rl runMode: NSDefaultRunLoopMode beforeDate: d]; + } + + PASS(byteCount>0, "read www.google.com https"); + [defaultInput setDelegate: nil]; + [defaultOutput setDelegate: nil]; + END_SET("NSStream SSL") + + [arp release]; + return 0; +} + +@end diff --git a/Tests/base/NSStream/socket_cs.m b/Tests/base/NSStream/socket_cs.m new file mode 100644 index 000000000..d5aa4492d --- /dev/null +++ b/Tests/base/NSStream/socket_cs.m @@ -0,0 +1,404 @@ +#if defined(GNUSTEP_BASE_LIBRARY) +/** + * This test tests client and server socket + */ +#import "ObjectTesting.h" +#import +#import + +static GSServerStream *serverStream; +static NSOutputStream *serverOutput = nil; +static NSOutputStream *clientOutput = nil; +static NSInputStream *serverInput = nil; +static NSInputStream *clientInput = nil; +static NSData *goldData; +static NSMutableData *testData; + +@interface ClientListener : NSObject +{ + uint8_t buffer[4096]; + int writePointer; +} +@end + +@implementation ClientListener + +- (void)stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ +NSLog(@"Client %p %d", theStream, streamEvent); + switch (streamEvent) + { + case NSStreamEventOpenCompleted: + { + if (theStream==clientOutput) + writePointer = 0; + break; + } + case NSStreamEventHasSpaceAvailable: + { + NSAssert(theStream==clientOutput, @"Wrong stream for writing"); + if (writePointer<[goldData length]) + { + int writeReturn = [clientOutput write: [goldData bytes]+writePointer + maxLength: [goldData length]-writePointer]; + NSLog(@"Client %p wrote %d", clientOutput, writeReturn); + if (writeReturn < 0) + NSLog(@"Error ... %@", [clientOutput streamError]); + writePointer += writeReturn; + } + else + { + writePointer = 0; + [clientOutput close]; + [clientOutput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Client close %p", clientOutput); + } + break; + } + case NSStreamEventHasBytesAvailable: + { + int readSize; + NSAssert(theStream==clientInput, @"Wrong stream for reading"); + readSize = [clientInput read: buffer maxLength: 4096]; + NSLog(@"Client %p read %d", clientInput, readSize); + if (readSize < 0) + { + NSLog(@"Error ... %@", [clientInput streamError]); + // it is possible that readSize<0 but not an Error. + // For example would block + } + else if (readSize == 0) + { + [clientInput close]; + [clientInput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Client close %p", clientInput); + } + else + { + [testData appendBytes: buffer length: readSize]; + } + break; + } + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Client close %p", theStream); + break; + } + case NSStreamEventErrorOccurred: + { + NSLog(@"Error code is %d ... %@", + [[theStream streamError] code], [theStream streamError]); + break; + } + default: + break; + } +} + +@end + +@interface ServerListener : NSObject +{ + uint8_t buffer[4096]; + int readSize; + int writeSize; + BOOL readable; + BOOL writable; +} +@end + +@implementation ServerListener + +- (void)stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ +NSLog(@"Server %p %d", theStream, streamEvent); + switch (streamEvent) + { + case NSStreamEventHasBytesAvailable: + { + if (theStream==serverStream) + { + NSAssert(serverInput==nil, @"accept twice"); + [serverStream acceptWithInputStream: &serverInput + outputStream: &serverOutput]; + if (serverInput) // it is ok to accept nothing + { + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + [serverInput scheduleInRunLoop: rl + forMode: NSDefaultRunLoopMode]; + [serverOutput scheduleInRunLoop: rl + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server input stream is %p", serverInput); + NSLog(@"Server output stream is %p", serverOutput); + [serverInput retain]; + [serverOutput retain]; + [serverInput setDelegate: self]; + [serverOutput setDelegate: self]; + [serverInput open]; + [serverOutput open]; + readSize = 0; + writeSize = 0; + [serverStream close]; + [serverStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + } + } + if (theStream == serverInput) + { + readable = YES; + } + break; + } + case NSStreamEventHasSpaceAvailable: + { + NSAssert(theStream==serverOutput, @"Wrong stream for writing"); + writable = YES; + break; + } + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server close %p", theStream); + if (theStream == serverInput && writeSize == readSize) + { + [serverOutput close]; + [serverOutput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server output close %p", serverOutput); + } + break; + } + case NSStreamEventErrorOccurred: + { + NSLog(@"Error code is %d ... %@", + [[theStream streamError] code], [theStream streamError]); + break; + } + default: + break; + } + + while ((readable == YES && writeSize == readSize) + || (writable == YES && writeSize < readSize)) + { + if (readable == YES && writeSize == readSize) + { + readSize = [serverInput read: buffer maxLength: 4096]; + readable = NO; + NSLog(@"Server %p read %d", serverInput, readSize); + writeSize = 0; + if (readSize == 0) + { + [serverInput close]; + [serverInput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server input close %p", serverInput); + [serverOutput close]; + [serverOutput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server output close %p", serverOutput); + } + else if (readSize < 0) + { + NSLog(@"Error ... %@", [clientInput streamError]); + readSize = 0; + } + } + if (writable == YES && writeSize < readSize) + { + int writeReturn = [serverOutput write: buffer+writeSize + maxLength: readSize-writeSize]; + NSLog(@"Server %p wrote %d", serverOutput, writeReturn); + writable = NO; + if (writeReturn == 0) + { + [serverOutput close]; + [serverOutput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server close %p", serverOutput); + [serverInput close]; + [serverInput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server input close %p", serverInput); + } + else if (writeReturn > 0) + { + writeSize += writeReturn; + } + else if (writeReturn < 0) + { + NSLog(@"Error ... %@", [serverOutput streamError]); + } + + /* If we have finished writing and there is no more data coming, + * we can close the output stream. + */ + if (writeSize == readSize + && [serverInput streamStatus] == NSStreamStatusClosed) + { + [serverOutput close]; + [serverOutput removeFromRunLoop: [NSRunLoop currentRunLoop] + forMode: NSDefaultRunLoopMode]; + NSLog(@"Server output close %p", serverOutput); + } + } + } +} + +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + NSHost *host = [NSHost hostWithAddress: @"127.0.0.1"]; + ServerListener *sli; + ClientListener *cli; + NSString *path = @"socket_cs.m"; + NSString *socketPath = @"test-socket"; + + [[NSFileManager defaultManager] removeFileAtPath: socketPath handler: nil]; + NSLog(@"sending and receiving on %@: %@", host, [host address]); + goldData = [NSData dataWithContentsOfFile: path]; + testData = [NSMutableData dataWithCapacity: 4096]; + + sli = [ServerListener new]; + cli = [ClientListener new]; + serverStream + = [GSServerStream serverStreamToAddr: [host address] port: 54321]; + [serverStream setDelegate: sli]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [serverStream open]; + [NSStream getStreamsToHost: host + port: 54321 + inputStream: &clientInput + outputStream: &clientOutput]; + NSLog(@"Client input stream is %p", clientInput); + NSLog(@"Client output stream is %p", clientOutput); + [clientInput setDelegate: cli]; + [clientOutput setDelegate: cli]; + [clientInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [clientOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [clientInput open]; + [clientOutput open]; + + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 30]]; + PASS([goldData isEqualToData: testData], "Local tcp"); + + DESTROY(serverInput); + DESTROY(serverOutput); + clientInput = nil; + clientOutput = nil; + DESTROY(sli); + DESTROY(cli); + [testData setLength: 0]; + + sli = [ServerListener new]; + cli = [ClientListener new]; + serverStream + = [GSServerStream serverStreamToAddr: [host address] port: 54321]; + [serverStream setDelegate: sli]; + [serverStream open]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [NSStream getStreamsToHost: host + port: 54321 + inputStream: &clientInput + outputStream: &clientOutput]; + NSLog(@"Client input stream is %p", clientInput); + NSLog(@"Client output stream is %p", clientOutput); + [clientInput setDelegate: cli]; + [clientOutput setDelegate: cli]; + [clientInput open]; + [clientOutput open]; + [clientInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [clientOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 30]]; + PASS([goldData isEqualToData: testData], "Local tcp (blocking open)"); + + DESTROY(serverInput); + DESTROY(serverOutput); + clientInput = nil; + clientOutput = nil; + DESTROY(sli); + DESTROY(cli); + [testData setLength: 0]; + + sli = [ServerListener new]; + cli = [ClientListener new]; + serverStream = [GSServerStream serverStreamToAddr: socketPath]; + [serverStream setDelegate: sli]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [serverStream open]; + [NSStream getLocalStreamsToPath: socketPath + inputStream: &clientInput + outputStream: &clientOutput]; + NSLog(@"Client input stream is %p", clientInput); + NSLog(@"Client output stream is %p", clientOutput); + [clientInput setDelegate: cli]; + [clientOutput setDelegate: cli]; + [clientInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [clientOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [clientInput open]; + [clientOutput open]; + + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 30]]; + + PASS([goldData isEqualToData: testData], "Local socket"); + + DESTROY(serverInput); + DESTROY(serverOutput); + clientInput = nil; + clientOutput = nil; + DESTROY(sli); + DESTROY(cli); + [testData setLength: 0]; + [[NSFileManager defaultManager] removeFileAtPath: socketPath handler: nil]; + + sli = [ServerListener new]; + cli = [ClientListener new]; + serverStream = [GSServerStream serverStreamToAddr: socketPath]; + [serverStream setDelegate: sli]; + [serverStream open]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [NSStream getLocalStreamsToPath: socketPath + inputStream: &clientInput + outputStream: &clientOutput]; + NSLog(@"Client input stream is %p", clientInput); + NSLog(@"Client output stream is %p", clientOutput); + [clientInput setDelegate: cli]; + [clientOutput setDelegate: cli]; + [clientInput open]; + [clientOutput open]; + [clientInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [clientOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 30]]; + + PASS([goldData isEqualToData: testData], "Local socket (blocking open)"); + + DESTROY(serverInput); + DESTROY(serverOutput); + clientInput = nil; + clientOutput = nil; + DESTROY(sli); + DESTROY(cli); + [testData setLength: 0]; + [[NSFileManager defaultManager] removeFileAtPath: socketPath handler: nil]; + + [arp release]; + return 0; +} +#else +int main() +{ + return 0; +} +#endif diff --git a/Tests/base/NSString/NSString_base.m b/Tests/base/NSString/NSString_base.m new file mode 100644 index 000000000..8f59b63c2 --- /dev/null +++ b/Tests/base/NSString/NSString_base.m @@ -0,0 +1,17 @@ +/* +copyright 2004 Alexander Malmberg + +Test -base's cluster of NSString classes. This tests the optimized +implementations of many NSString methods in GSString and its subclasses. +*/ + +#import "NSString_tests.h" + +#import + +int main(int argc,char **argv) +{ + TestNSStringClass([NSString class]); + return 0; +} + diff --git a/Tests/base/NSString/NSString_custom.m b/Tests/base/NSString/NSString_custom.m new file mode 100644 index 000000000..2c46dbbc0 --- /dev/null +++ b/Tests/base/NSString/NSString_custom.m @@ -0,0 +1,119 @@ +/* +copyright 2004 Alexander Malmberg + +Test that a minimal custom subclass works. This tests the generic +implementations of the NSString methods in NSString itself. +*/ + +#import "NSString_tests.h" + +#import + +@interface CustomString : NSString +{ + unichar *characters; + NSUInteger length; +} + +@end + +@implementation CustomString + +- initWithBytes: (void *)c + length: (NSUInteger)l + encoding: (NSStringEncoding)encoding +{ + if (l > 0) + { + if (encoding == NSUnicodeStringEncoding) + { + characters = malloc(l); + memcpy(characters, c, l); + } + else + { + NSString *s; + + s = [[NSString alloc] initWithBytes: c + length: l + encoding: encoding]; + if (s == nil) return nil; + l = [s length] * sizeof(unichar); + characters = malloc(l); + [s getCharacters: characters]; + [s release]; + } + } + length = l / sizeof(unichar); + return self; +} + +- initWithBytesNoCopy: (void *)c + length: (NSUInteger)l + encoding: (NSStringEncoding)encoding + freeWhenDone: (BOOL)freeWhenDone +{ + if (l > 0) + { + if (encoding == NSUnicodeStringEncoding) + { + characters = malloc(l); + memcpy(characters, c, l); + } + else + { + NSString *s; + + s = [[NSString alloc] initWithBytesNoCopy: c + length: l + encoding: encoding + freeWhenDone: freeWhenDone]; + if (s == nil) return nil; + l = [s length] * sizeof(unichar); + characters = malloc(l); + [s getCharacters: characters]; + [s release]; + } + } + length = l / sizeof(unichar); + return self; +} + +- initWithCharactersNoCopy: (void *)c + length: (NSUInteger)l + freeWhenDone: (BOOL)flag +{ + return [self initWithBytesNoCopy: c + length: l*sizeof(unichar) + encoding: NSUnicodeStringEncoding + freeWhenDone: flag]; +} + +- (void) dealloc +{ + if (characters) + { + free(characters); + characters = NULL; + } + [super dealloc]; +} + +- (NSUInteger) length +{ + return length; +} + +- (unichar) characterAtIndex: (NSUInteger)index +{ + return characters[index]; +} + +@end + + +int main(int argc,char **argv) +{ + TestNSStringClass([CustomString class]); + return 0; +} diff --git a/Tests/base/NSString/NSString_tests.h b/Tests/base/NSString/NSString_tests.h new file mode 100644 index 000000000..ffcb529de --- /dev/null +++ b/Tests/base/NSString/NSString_tests.h @@ -0,0 +1,316 @@ +/* +copyright 2004 Alexander Malmberg + +portions: +copyright (C) 2003 Free Software Foundation, Inc. +Author: Alexander Malmberg + + +Test whether a class is a working concrete subclass of NSString. This file +should be included _once_ in a test that wants to test a particular class. +*/ + + + +#import "Testing.h" +#import +#import +#import +#import + +/* +This is the main entry point to this file. Call it with a class that's +supposed to be a concrete NSString subclass. +*/ +void TestNSStringClass(Class stringClass); + +/* Solaris, in particular, can't handle a NULL string in a printf statement */ +#define FORMAT_STRING(str) ((str) ? str : "NULL") + + +#define IS_VALID_OBJECT(obj) (object_getClass((id)obj) != zombieClass) + + +Class stringClass; + + +/* +Basic sanity test. +*/ +BOOL test_initWithCString(void) +{ + NSString *test1 = [[stringClass alloc] initWithCString: "ascii"]; + NSString *sanity = @"ascii"; + + if (!test1) + return NO; + + if (![sanity isEqualToString: test1]) + return NO; + if (![test1 isEqualToString: sanity]) + return NO; + if (![test1 isEqual: sanity]) + return NO; + + return YES; +} + + +/* +Test encoding and decoding in various character encodings. +*/ +BOOL test_encodings_helper(NSStringEncoding encoding, + unsigned char *bytes, int bytes_length, + unichar *characters, int characters_length) +{ + BOOL ok = YES; + + NSData *referenceData = [[NSData alloc] + initWithBytes: bytes + length: bytes_length]; + NSString *referenceString = [[stringClass alloc] + initWithCharacters: characters + length: characters_length]; + + NSData *encodedData; + NSString *decodedString; + + + decodedString = [[stringClass alloc] + initWithData: referenceData + encoding: encoding]; + + if (![decodedString isEqual: referenceString]) + { + printf("decoding data %s in encoding %i gave string %s\n", + FORMAT_STRING(POBJECT(referenceData)), encoding, + FORMAT_STRING([decodedString lossyCString])); + ok = NO; + } + + encodedData = [referenceString dataUsingEncoding: encoding]; + if (![encodedData isEqual: referenceData]) + { + printf("encoding string %s in encoding %i gave data %s\n", + FORMAT_STRING([referenceString lossyCString]), encoding, + FORMAT_STRING(POBJECT(encodedData))); + ok = NO; + } + + DESTROY(decodedString); + DESTROY(referenceData); + DESTROY(referenceString); + + return ok; +} + +BOOL test_encoding(void) +{ + BOOL ok = YES; + + { + NSData *d = [[NSData alloc] initWithBytes: "foo" length: 3]; + NSString *s = [[stringClass alloc] initWithData: d encoding: 0]; + + PASS(s == nil, "-initWithData:encoding: gives nil for invalid encodings") + + DESTROY(d); + } + + + ok = ok && test_encodings_helper(NSASCIIStringEncoding, + (unsigned char[]){65, 66, 67}, 3, + (unichar[]){65, 66, 67}, 3); + + ok = ok && test_encodings_helper(NSUTF8StringEncoding, + (unsigned char[]){65, 66, 67}, 3, + (unichar[]){65, 66, 67}, 3); + + ok = ok && test_encodings_helper(NSUTF8StringEncoding, + (unsigned char[]){0xc3, 0xa5, 0xc3, 0xa4, 0xc3, 0xb6, + 0xd7, 0xa9, 0xd7, 0x9c, 0xd7, 0x95, 0xd7, 0x9d}, 14, + (unichar[]){0xe5, 0xe4, 0xf6, 0x5e9, 0x5dc, 0x5d5, 0x5dd}, 7); + + /* Codepoint U+2F801 CJK Compatiblity Ideograph */ + ok = ok && test_encodings_helper(NSUTF8StringEncoding, + (unsigned char[]){0xf0, 0xaf, 0xa0, 0x81}, 4, + (unichar[]){0xd87e, 0xdc01}, 2); + +#if defined(GNUSTEP_BASE_LIBRARY) + ok = ok && test_encodings_helper(NSISOHebrewStringEncoding, + (unsigned char[]){0xf9, 0xec, 0xe5, 0xed}, 4, + (unichar[]){0x5e9, 0x5dc, 0x5d5, 0x5dd}, 4); +#endif + + ok = ok && test_encodings_helper(NSISOLatin1StringEncoding, + (unsigned char[]){116, 101, 115, 116, 45, 229, 228, 246}, 8, + (unichar[]){116, 101, 115, 116, 45, 229, 228, 246}, 8); + + ok = ok && test_encodings_helper(NSUTF8StringEncoding, + (unsigned char[]){0xe0, 0xb8, 0xa0, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xa9, + 0xe0, 0xb8, 0xb2, 0xe0, 0xb9, 0x84, 0xe0, 0xb8, 0x97, + 0xe0, 0xb8, 0xa2}, 21, + (unichar[]){0xe20, 0xe32, 0xe29, 0xe32, 0xe44, 0xe17, 0xe22}, 7); + +/* +; (test-data-string +; '(#xc0 #xd2 #xc9 #xd2 #xe4 #xb7 #xc2) 59 ; iso-8859-11, not yet implemented +; '(#xe20 #xe32 #xe29 +; #xe32 #xe44 #xe17 +; #xe22) #t #t) +*/ + +#if defined(GNUSTEP_BASE_LIBRARY) + ok = ok && test_encodings_helper(NSBIG5StringEncoding, + (unsigned char[]){0x41, 0x42, 0x43, 0x20, 0xa7, 0x41, 0xa6, 0x6e, 0x21}, 9, + (unichar[]){0x41, 0x42, 0x43, 0x20, 0x4f60, 0x597d, 0x21}, 7); +#endif + + return ok; +} + + +BOOL test_getCString_maxLength_range_remainingRange(void) +{ + NS_DURING + unsigned char *referenceBytes; + int referenceBytesLength; + NSString *referenceString; + unsigned char buffer[16]; + NSRange remainingRange; + int i, j; + BOOL ok = YES; + + switch ([NSString defaultCStringEncoding]) + { + case NSUTF8StringEncoding: + referenceBytes =(unsigned char []){0x41, 0xc3, 0xa5, 0x42}; + referenceBytesLength = 4; + referenceString = [stringClass stringWithCharacters: + (unichar []){0x41, 0xe5, 0x42} + length: 3]; + break; + default: + printf("Have no reference string for c-string encoding %i," + " skipping test.\n", [NSString defaultCStringEncoding]); + NS_VALUERETURN(YES, BOOL); + } + + for (i = 0; i < referenceBytesLength; i++) + { + [referenceString getCString: buffer + maxLength: i + range: NSMakeRange(0, [referenceString length]) + remainingRange: &remainingRange]; + + for (j = 0; j <= i ; j++) + if (buffer[j] == 0 || buffer[j] != referenceBytes[j]) + break; + if (buffer[j]!= 0) + { + PASS(0, "-getCString: maxLength: %i range: remainingRange: failed", + i); + ok = NO; + } + } + NS_VALUERETURN(ok, BOOL); + NS_HANDLER + printf("%s\n", POBJECT(localException)); + return NO; + NS_ENDHANDLER +} + + +void test_return_self_optimizations(void) +{ + NSAutoreleasePool *arp; + NSString *string, *returnValue; + Class zombieClass = NSClassFromString(@"NSZombie"); + + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: NULL + length: 0]; + returnValue = [string lowercaseString]; + [string release]; + PASS((IS_VALID_OBJECT(returnValue) && [@"" isEqual: returnValue]), + "-lowercaseString returns a valid instance"); + DESTROY(arp); + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: NULL + length: 0]; + returnValue = [string uppercaseString]; + [string release]; + PASS((IS_VALID_OBJECT(returnValue) && [@"" isEqual: returnValue]), + "-uppercaseString returns a valid instance"); + DESTROY(arp); + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: NULL + length: 0]; + returnValue = [string capitalizedString]; + [string release]; + PASS((IS_VALID_OBJECT(returnValue) && [@"" isEqual: returnValue]), + "-capitalizedString returns a valid instance"); + DESTROY(arp); + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: NULL + length: 0]; + returnValue = [string description]; + PASS((IS_VALID_OBJECT(returnValue) && [@"" isEqual: returnValue]), + "-description returns a valid instance"); + [string release]; + DESTROY(arp); + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: NULL + length: 0]; + returnValue = [string stringByExpandingTildeInPath]; + [string release]; + PASS([@"" isEqual: returnValue], "-stringByExpandingTildeInPath returns a valid instance (1)"); + DESTROY(arp); + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: (unichar[]){0x41} + length: 1]; + returnValue = [string stringByExpandingTildeInPath]; + [string release]; + PASS((IS_VALID_OBJECT(returnValue) && [@"A" isEqual: returnValue]), + "-stringByExpandingTildeInPath returns a valid instance (2)"); + DESTROY(arp); + + arp = [NSAutoreleasePool new]; + string = [[stringClass alloc] initWithCharacters: (unichar[]){0x41} + length: 1]; + returnValue = [string stringByAbbreviatingWithTildeInPath]; + [string release]; + PASS((IS_VALID_OBJECT(returnValue) && [@"A" isEqual: returnValue]), + "-stringByAbbreviatingWithTildeInPath returns a valid instance"); + DESTROY(arp); + + /* + TODO: + -stringByPaddingToLength:... + -stringByResolvingSymlinksInPath + -stringByTrimmingCharactersInSet: + */ +} + + +void TestNSStringClass(Class aStringClass) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + stringClass = aStringClass; + + PASS(test_initWithCString(), "-initWithCString: works"); + PASS(test_encoding(), "character set encoding/decoding works"); + PASS(test_getCString_maxLength_range_remainingRange(), "-getCString:maxLength:range:remainingRange: works"); + + test_return_self_optimizations(); + + [arp release]; arp = nil; +} + diff --git a/Tests/base/NSString/NSString_zero_hash.m b/Tests/base/NSString/NSString_zero_hash.m new file mode 100644 index 000000000..cc40e2d48 --- /dev/null +++ b/Tests/base/NSString/NSString_zero_hash.m @@ -0,0 +1,40 @@ +/* +copyright 2004 Alexander Malmberg +*/ + +#import "Testing.h" + +#import + +int main(int argc, char **argv) +{ + NSString *s = @"!)9\" ;"; + unsigned int h; + +/* + Generate a (hopefully ASCII printable) string with a given hash. + + h = 0x50000000; + while (h > 0) + { + int a,b; + + a = h/33; + b = h%33; + if (a) + while (b < 32) + a--, b += 33; + printf("%10i = %10i * 33 + %3i '%c'\n",h,a,b,b); + h = a; + }*/ + + h = [s hash]; + PASS(h != 0, "[NSConstantString hash] does not return 0"); + + s = [[NSString alloc] initWithString: s]; + h = [s hash]; + PASS(h != 0, "[NSString hash] does not return 0"); + + return 0; +} + diff --git a/Tests/base/NSString/TestInfo b/Tests/base/NSString/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSString/basic.m b/Tests/base/NSString/basic.m new file mode 100644 index 000000000..320fcb7f1 --- /dev/null +++ b/Tests/base/NSString/basic.m @@ -0,0 +1,49 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + unichar u0 = 'a'; + unichar u1 = 0xfe66; + char buf[32]; + NSString *s; + NSString *testObj = [NSString stringWithCString: "Hello\n"]; + + test_alloc(@"NSString"); + test_NSObject(@"NSString",[NSArray arrayWithObject:testObj]); + test_NSCoding([NSArray arrayWithObject:testObj]); + test_NSCopying(@"NSString", @"NSMutableString", + [NSArray arrayWithObject:testObj], NO, NO); + test_NSMutableCopying(@"NSString", @"NSMutableString", + [NSArray arrayWithObject:testObj]); + + /* Test non-ASCII strings. */ + testObj = [@"\"\\U00C4\\U00DF\"" propertyList]; + test_NSMutableCopying(@"NSString", @"NSMutableString", + [NSArray arrayWithObject:testObj]); + + PASS([(s = [[NSString alloc] initWithCharacters: &u0 length: 1]) + isKindOfClass: [NSString class]] + && ![s isKindOfClass: [NSMutableString class]], + "initWithCharacters:length: creates mutable string for ascii"); + + PASS([(s = [[NSString alloc] initWithCharacters: &u1 length: 1]) + isKindOfClass: [NSString class]] + && ![s isKindOfClass: [NSMutableString class]], + "initWithCharacters:length: creates mutable string for unicode"); + + PASS_EXCEPTION([[NSString alloc] initWithString: nil];, + NSInvalidArgumentException, + "NSString -initWithString: does not allow nil argument"); + + PASS([@"he" getCString: buf maxLength: 2 encoding: NSASCIIStringEncoding]==NO, + "buffer exact length fails"); + PASS([@"hell" getCString: buf maxLength: 5 encoding: NSASCIIStringEncoding], + "buffer length+1 works"); + PASS(strcmp(buf, "hell") == 0, "getCString:maxLength:encoding"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/bom.m b/Tests/base/NSString/bom.m new file mode 100644 index 000000000..fe5e8e8cc --- /dev/null +++ b/Tests/base/NSString/bom.m @@ -0,0 +1,48 @@ +/* + Copyright (C) 2006 Free SoftwareFoundation, Inc. + + Written by: David Ayers + Date: March 2006 + + This file is part of the GNUstep Base Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* +Testing of Various Byte Order Markers. +*/ + +#import "Testing.h" +#import + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSString *file=@"utf8bom.txt"; + NSString *contents; + NSData *data; + + contents = [NSString stringWithContentsOfFile: file]; + PASS([contents hasPrefix:@"This"], "stringWithContentsOfFile: UTF-8 BOM"); + + data = [NSData dataWithContentsOfFile: file]; + contents = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]; + PASS([contents hasPrefix:@"This"], "initWithData:encoding: UTF-8 BOM"); + + [pool release]; + return 0; +} + diff --git a/Tests/base/NSString/boolValue.m b/Tests/base/NSString/boolValue.m new file mode 100644 index 000000000..819b90fda --- /dev/null +++ b/Tests/base/NSString/boolValue.m @@ -0,0 +1,48 @@ +/* +copyright 2008 David Ayers + +Tests that boolValue of certain strings return the correct value. +*/ + +#import "Testing.h" + +#import +#import + +int main(int argc, char **argv) +{ + NSString *constantStringY[]={ + @"y",@"Y",@"t",@"T",@"1",@"9", + @"-y",@"-Y",@"-t",@"-T",@"-1",@"-9", + @"Yes",@"YES",@"yes" + }; + NSString *constantStringN[]={ + @"n",@"N",@"f",@"F",@"0",@"00", + @"-n",@"-N",@"-f",@"-F",@"-0",@"-00", + @"No",@"NO",@"no", + @"0.0",@"0,0", + @"0.1",@"0,1" + }; + NSString *normalString; + NSMutableString *mutableString; + unsigned i; + + [NSAutoreleasePool new]; + for (i=0;i<(sizeof(constantStringY)/sizeof(constantStringY[0]));i++) + { + PASS([constantStringY[i] boolValue] == YES, "constant:%s == YES", [constantStringY[i] lossyCString]); + PASS([constantStringN[i] boolValue] == NO, "constant:%s == NO", [constantStringN[i] lossyCString]); + + normalString = [NSString stringWithString:constantStringY[i]]; + PASS([normalString boolValue] == YES, "normal:%s == YES", [normalString lossyCString]); + normalString = [NSString stringWithString:constantStringN[i]]; + PASS([normalString boolValue] == NO, "normal:%s == NO", [normalString lossyCString]); + + mutableString = (id)[NSMutableString stringWithString:constantStringY[i]]; + PASS([mutableString boolValue] == YES, "mutable:%s == YES", [mutableString lossyCString]); + mutableString = (id)[NSMutableString stringWithString:constantStringN[i]]; + PASS([mutableString boolValue] == NO, "mutable:%s == NO", [mutableString lossyCString]); + } + + return 0; +} diff --git a/Tests/base/NSString/nuls_in_strings.m b/Tests/base/NSString/nuls_in_strings.m new file mode 100644 index 000000000..066c0b75c --- /dev/null +++ b/Tests/base/NSString/nuls_in_strings.m @@ -0,0 +1,28 @@ +/* +copyright 2004 Alexander Malmberg + +Tests that nul characters are handled correctly in strings and string +constants. +*/ + +#import "Testing.h" + +#import + +int main(int argc, char **argv) +{ + NSString *constantString=@"a\0b"; + NSString *normalString; + unichar characters[3]={'a',0,'b'}; + + normalString = [[NSString alloc] initWithCharacters: characters length: 3]; + + PASS([constantString length] == 3, "nuls in constant strings"); + PASS([normalString length] == 3, "nuls in non-constant strings"); + PASS([constantString hash] == [normalString hash], "hashes match"); + PASS([normalString isEqual: constantString] + && [constantString isEqual: normalString], "compare as equal"); + + return 0; +} + diff --git a/Tests/base/NSString/order.m b/Tests/base/NSString/order.m new file mode 100644 index 000000000..19f5e3844 --- /dev/null +++ b/Tests/base/NSString/order.m @@ -0,0 +1,74 @@ +/* + Copyright (C) 2008 Free SoftwareFoundation, Inc. + +*/ + +/* +Testing of Various Byte Order conversion. +*/ + +#import "Testing.h" +#import + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + NSString *s1 = @"A"; + NSString *s2; + NSData *d; + const uint8_t *b; + + d = [s1 dataUsingEncoding: NSUTF16BigEndianStringEncoding]; + b = [d bytes]; + PASS([d length] > 1 && b[0] == 0 && b[1] == 65, "UTF-16 BE OK"); + if (testPassed) + { + s2 = [[NSString alloc] initWithBytes: b + length: 2 + encoding: NSUTF16BigEndianStringEncoding]; + PASS([s1 isEqual: s2], "UTF-16 BE reverse OK"); + [s2 release]; + } + + d = [s1 dataUsingEncoding: NSUTF16LittleEndianStringEncoding]; + b = [d bytes]; + PASS([d length] > 1 && b[0] == 65 && b[1] == 0, "UTF-16 LE OK"); + if (testPassed) + { + s2 = [[NSString alloc] initWithBytes: b + length: 2 + encoding: NSUTF16LittleEndianStringEncoding]; + PASS([s1 isEqual: s2], "UTF-16 LE reverse OK"); + [s2 release]; + } + + d = [s1 dataUsingEncoding: NSUTF32BigEndianStringEncoding]; + b = [d bytes]; + PASS([d length] > 3 && b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 65, + "UTF-32 BE OK"); + if (testPassed) + { + s2 = [[NSString alloc] initWithBytes: b + length: 4 + encoding: NSUTF32BigEndianStringEncoding]; + PASS([s1 isEqual: s2], "UTF-32 BE reverse OK"); + [s2 release]; + } + + d = [s1 dataUsingEncoding: NSUTF32LittleEndianStringEncoding]; + b = [d bytes]; + PASS([d length] > 3 && b[0] == 65 && b[1] == 0 && b[2] == 0 && b[3] == 0, + "UTF-32 LE OK"); + if (testPassed) + { + s2 = [[NSString alloc] initWithBytes: b + length: 4 + encoding: NSUTF32LittleEndianStringEncoding]; + PASS([s1 isEqual: s2], "UTF-32 LE reverse OK"); + [s2 release]; + } + + [pool release]; + return 0; +} + diff --git a/Tests/base/NSString/test00.m b/Tests/base/NSString/test00.m new file mode 100644 index 000000000..257cb0fe4 --- /dev/null +++ b/Tests/base/NSString/test00.m @@ -0,0 +1,361 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import +#import + +static BOOL rangesEqual(NSRange r1, NSRange r2) +{ + if (&r1 == &r2) + return YES; + + if (r1.length == 0 && r2.length == 0) + return YES; + + return (r1.length == r2.length && r1.location == r2.location); +} + +static void strCompare (char *s0, char *s1, NSComparisonResult ci, + NSComparisonResult cs, NSComparisonResult lci, + NSComparisonResult lcs, NSRange ra) +{ + NSString *cs0, *cs1, *us0, *us1; /* cstrings and unicode strings */ + NSMutableData *d; + unichar *b; + int l; + int opts; + char *txt,*type; + NSComparisonResult want, res; + cs0 = nil; + cs1 = nil; + us0 = nil; + us1 = nil; + + PASS_RUNS(cs0 = [NSString stringWithCString:s0]; + l = [cs0 length]; + d = [NSMutableData dataWithLength:(l * 2)]; + b = [d mutableBytes]; + [cs0 getCharacters:b]; + us0 = [NSString stringWithCharacters:b length:l]; + + cs1 = [NSString stringWithCString:s1]; + l = [cs1 length]; + d = [NSMutableData dataWithLength:(l * 2)]; + b = [d mutableBytes]; + [cs1 getCharacters:b]; + us1 = [NSString stringWithCharacters:b length:l];, + "create strings for compare is ok"); + opts = NSCaseInsensitiveSearch; + type = "case insensitive comparison for"; + switch (ci) + { + case NSOrderedAscending: + txt = "NSOrderedAscending"; + break; + case NSOrderedDescending: + txt = "NSOrderedDescending"; + break; + case NSOrderedSame: + txt = "NSOrderedSame"; + break; + default: + txt = ""; + } + want = ci; + + res = [cs0 compare:cs1 options:opts range:ra]; + PASS(res == want, "CCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:us1 options:opts range:ra]; + PASS(res == want, "UUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:cs1 options:opts range:ra]; + PASS(res == want, "UCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [cs0 compare:us1 options:opts range:ra]; + PASS(res == want, "CUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + opts = 0; + type = "case sensitive comparison for"; + switch (cs) + { + case NSOrderedAscending: + txt = "NSOrderedAscending"; + break; + case NSOrderedDescending: + txt = "NSOrderedDescending"; + break; + case NSOrderedSame: + txt = "NSOrderedSame"; + break; + } + want = cs; + res = [cs0 compare:cs1 options:opts range:ra]; + PASS(res == want, "CCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:us1 options:opts range:ra]; + PASS(res == want, "UUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:cs1 options:opts range:ra]; + PASS(res == want, "UCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [cs0 compare:us1 options:opts range:ra]; + PASS(res == want, "CUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + opts = NSCaseInsensitiveSearch | NSLiteralSearch; + type = "case insensitive literal comparison for"; + switch (lci) + { + case NSOrderedAscending: + txt = "NSOrderedAscending"; + break; + case NSOrderedDescending: + txt = "NSOrderedDescending"; + break; + case NSOrderedSame: + txt = "NSOrderedSame"; + break; + } + want = lci; + res = [cs0 compare:cs1 options:opts range:ra]; + PASS(res == want, "CCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:us1 options:opts range:ra]; + PASS(res == want, "UUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:cs1 options:opts range:ra]; + PASS(res == want, "UCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [cs0 compare:us1 options:opts range:ra]; + PASS(res == want, "CUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + opts = NSLiteralSearch; + type = "case sensitive literal comparison for"; + switch (lcs) + { + case NSOrderedAscending: + txt = "NSOrderedAscending"; + break; + case NSOrderedDescending: + txt = "NSOrderedDescending"; + break; + case NSOrderedSame: + txt = "NSOrderedSame"; + break; + } + want = lcs; + res = [cs0 compare:cs1 options:opts range:ra]; + PASS(res == want, "CCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:us1 options:opts range:ra]; + PASS(res == want, "UUString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [us0 compare:cs1 options:opts range:ra]; + PASS(res == want, "UCString %s '%s' and '%s' %s ", type, s0, s1, txt); + + res = [cs0 compare:us1 options:opts range:ra]; + PASS(res == want, "CUString %s '%s' and '%s' %s ", type, s0, s1, txt); + +} + +static void strRange(char *s0, char *s1, unsigned int opts, + NSRange range, NSRange want) +{ + NSString *cs0, *cs1, *us0, *us1 = nil; /* cstrings and unicode strings */ + NSMutableData *d; + unichar *b; + int l; + NSRange res; + + cs0 = nil; + cs1 = nil; + us0 = nil; + us1 = nil; + + PASS_RUNS(cs0 = [NSString stringWithCString:s0]; + l = [cs0 length]; + d = [NSMutableData dataWithLength:(l * 2)]; + b = [d mutableBytes]; + [cs0 getCharacters:b]; + us0 = [NSString stringWithCharacters:b length:l]; + + cs1 = [NSString stringWithCString:s1]; + l = [cs1 length]; + d = [NSMutableData dataWithLength:(l * 2)]; + b = [d mutableBytes]; + [cs1 getCharacters:b]; + us1 = [NSString stringWithCharacters:b length:l];, + "create strings for range is ok"); + + res = [cs0 rangeOfString:cs1 options:opts range:range]; + PASS(rangesEqual(res,want), "CCString range for '%s' and '%s' is ok",s0,s1); + + res = [us0 rangeOfString:us1 options:opts range:range]; + PASS(rangesEqual(res,want), "UUString range for '%s' and '%s' is ok",s0,s1); + + res = [us0 rangeOfString:cs1 options:opts range:range]; + PASS(rangesEqual(res,want), "UCString range for '%s' and '%s' is ok",s0,s1); + + res = [cs0 rangeOfString:us1 options:opts range:range]; + PASS(rangesEqual(res,want), "CUString range for '%s' and '%s' is ok",s0,s1); +} + +static void strRangeFromSet(char *s, NSCharacterSet *c, unsigned int o, NSRange range, NSRange want) +{ + NSString *cs0, *cs1, *us0, *us1 = nil; /* cstrings and unicode strings */ + NSMutableData *d; + unichar *b; + int l; + NSRange res; + + cs0 = nil; + cs1 = nil; + us0 = nil; + us1 = nil; + PASS_RUNS(cs0 = [NSString stringWithCString:s]; + l = [cs0 length]; + d = [NSMutableData dataWithLength:(l * 2)]; + b = [d mutableBytes]; + [cs0 getCharacters:b]; + us0 = [NSString stringWithCharacters:b length:l]; + + cs1 = [NSMutableString stringWithCString:s]; + l = [cs1 length]; + d = [NSMutableData dataWithLength:(l * 2)]; + b = [d mutableBytes]; + [cs1 getCharacters:b]; + us1 = [NSMutableString stringWithCharacters:b length:l];, + "create strings for range"); + + res = [cs0 rangeOfCharacterFromSet:c options:o range:range]; + PASS(rangesEqual(res,want), "CString range for '%s' is ok",s); + + res = [us0 rangeOfCharacterFromSet:c options:o range:range]; + PASS(rangesEqual(res,want), "UString range for '%s' is ok",s); + + res = [cs1 rangeOfCharacterFromSet:c options:o range:range]; + PASS(rangesEqual(res,want), "MCString range for '%s' is ok",s); + + res = [us1 rangeOfCharacterFromSet:c options:o range:range]; + PASS(rangesEqual(res,want), "MUString range for '%s' is ok",s); +} +static void testLineRange(char *s, NSRange range, NSRange want) +{ + NSRange res; + NSString *cs0; + int l; + + cs0 = [NSString stringWithCString:s]; + l = [cs0 length]; + res = [cs0 lineRangeForRange:range]; + PASS(rangesEqual(res,want), "lineRangeForRange: with '%s' is ok",s); +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS_EXCEPTION([NSString stringWithUTF8String: 0], + NSInvalidArgumentException, + "stringWithUTF8String raises for NULL"); + + PASS_EXCEPTION([NSString stringWithCString: 0 + encoding: NSASCIIStringEncoding], + NSInvalidArgumentException, + "initWithCString raises for NULL"); + + PASS_EXCEPTION([@"Hello" substringWithRange:NSMakeRange(6,4)];, + NSRangeException, + "NSString extracting substring with range beyond end of string"); + + PASS_EXCEPTION([@"Hello" compare: @"Hello" + options:NSLiteralSearch + range:NSMakeRange(4,3)];, + NSRangeException, + "NSString comparison with range beyond end of string"); + + strCompare("hello", "hello", NSOrderedSame, NSOrderedSame, NSOrderedSame, + NSOrderedSame,NSMakeRange(0,5)); + strCompare("", "",NSOrderedSame, NSOrderedSame, NSOrderedSame, NSOrderedSame, + NSMakeRange(0,0)); + strCompare("hello", "Hello", NSOrderedSame, NSOrderedDescending, NSOrderedSame, + NSOrderedDescending,NSMakeRange(0,5)); + strCompare("Hello", "hello", NSOrderedSame, NSOrderedAscending, NSOrderedSame, + NSOrderedAscending, NSMakeRange(0,5)); + strCompare("abc", "ab", NSOrderedDescending, NSOrderedDescending, + NSOrderedDescending, NSOrderedDescending, NSMakeRange(0,3)); + strCompare("ab", "abc", NSOrderedAscending, NSOrderedAscending, + NSOrderedAscending, NSOrderedAscending, NSMakeRange(0,2)); + strCompare("", "a", NSOrderedAscending, NSOrderedAscending, NSOrderedAscending, + NSOrderedAscending, NSMakeRange(0,0)); + strCompare("a", "", NSOrderedDescending, NSOrderedDescending, + NSOrderedDescending, NSOrderedDescending, NSMakeRange(0,1)); + strCompare("a", "", NSOrderedSame, NSOrderedSame, NSOrderedSame, NSOrderedSame, + NSMakeRange(0,0)); + strCompare("Location", "LoCaTiOn", NSOrderedSame, NSOrderedDescending, + NSOrderedSame, NSOrderedDescending, NSMakeRange(0,8)); + strCompare("1234567890_!@$%^&*()QWERTYUIOP{}ASDFGHJKL:;'ZXCVBNM,./<>?", + "1234567890_!@$%^&*()qwertyuiop{}asdfghjkl:;'zxcvbnm,./<>?", + NSOrderedSame, NSOrderedAscending, NSOrderedSame, + NSOrderedAscending, NSMakeRange(0,57)); + strCompare("1234567890_!@$%^&*()QWERTYUIOP{}ASDFGHJKL:;'ZXCVBNM,./<>?", + "1234567890_!@$%^&*()qwertyuiop{}asdfghjkl:;'zxcvbnm,./<>", + NSOrderedSame, NSOrderedAscending, NSOrderedSame, + NSOrderedAscending, NSMakeRange(0,56)); + strCompare("1234567890_!@$%^&*()QWERTYUIOP{}ASDFGHJKL:;'ZXCVBNM,./<>?", + "1234567890_!@$%^&*()qwertyuiop{}asdfghjkl:;'zxcvbnm,./<>?", + NSOrderedAscending, NSOrderedAscending, NSOrderedAscending, + NSOrderedAscending, NSMakeRange(0,56)); + strCompare("abcdefg", "ABCDEFG", NSOrderedSame, NSOrderedDescending, + NSOrderedSame, NSOrderedDescending, NSMakeRange(0, 7)); + strCompare("abcdefg", "CDE", NSOrderedSame, NSOrderedDescending, + NSOrderedSame, NSOrderedDescending, NSMakeRange(2,3)); + strCompare("abcdefg", "CDEF", NSOrderedAscending, NSOrderedDescending, + NSOrderedAscending, NSOrderedDescending, NSMakeRange(2,3)); + + strRange("hello", "hello", NSAnchoredSearch, NSMakeRange(0,5), NSMakeRange(0,5)); + strRange("hello", "hello", NSAnchoredSearch | NSBackwardsSearch, NSMakeRange(0,5), NSMakeRange(0,5)); + strRange("hello", "hElLo", NSLiteralSearch, NSMakeRange(0,5), NSMakeRange(0,0)); + strRange("hello", "hElLo", NSCaseInsensitiveSearch, NSMakeRange(0,5), NSMakeRange(0,5)); + strRange("hello", "hell", NSAnchoredSearch, NSMakeRange(0,5), NSMakeRange(0,4)); + strRange("hello", "hel", NSBackwardsSearch, NSMakeRange(0,5), NSMakeRange(0,3)); + strRange("hello", "he", NSLiteralSearch, NSMakeRange(0,5), NSMakeRange(0,2)); + strRange("hello", "h", NSLiteralSearch, NSMakeRange(0,5), NSMakeRange(0,1)); + strRange("hello", "", NSLiteralSearch, NSMakeRange(0,5), NSMakeRange(0,0)); + strRange("hello", "el", NSLiteralSearch, NSMakeRange(0,5), NSMakeRange(1,2)); + strRange("hello", "el", NSLiteralSearch, NSMakeRange(0,2), NSMakeRange(0,0)); + strRange("hello", "el", NSLiteralSearch, NSMakeRange(2,3), NSMakeRange(0,0)); + strRange("hello", "ell", NSLiteralSearch, NSMakeRange(0,5), NSMakeRange(1,3)); + strRange("hello", "lo", NSLiteralSearch, NSMakeRange(2,3), NSMakeRange(3,2)); + strRange("boaboaboa", "abo", NSLiteralSearch, NSMakeRange(0,9), NSMakeRange(2,3)); + strRange("boaboaboa", "abo", NSBackwardsSearch, NSMakeRange(0,9), NSMakeRange(5,3)); + strRange("boaboaboa", "ABO", NSCaseInsensitiveSearch, NSMakeRange(0,9), NSMakeRange(2,3)); + strRange("boaboaboa", "abo", NSCaseInsensitiveSearch | NSBackwardsSearch, + NSMakeRange(0,9), NSMakeRange(5,3)); + + strRangeFromSet("boaboaboa", + [NSCharacterSet alphanumericCharacterSet], + NSCaseInsensitiveSearch | NSBackwardsSearch, + NSMakeRange(0,9), NSMakeRange(8,1)); + + strRangeFromSet("boaboaboa", + [NSCharacterSet whitespaceCharacterSet], + NSCaseInsensitiveSearch | NSBackwardsSearch, + NSMakeRange(0,9), NSMakeRange(NSNotFound,0)); + + strRangeFromSet("bo boaboa", + [NSCharacterSet whitespaceCharacterSet], + NSCaseInsensitiveSearch | NSBackwardsSearch, + NSMakeRange(0,9), NSMakeRange(2,1)); + + testLineRange("This is a line of text\n", NSMakeRange(10, 10), NSMakeRange(0, 23)); + testLineRange("This is a line of text\r\n", NSMakeRange(10, 10), NSMakeRange(0, 24)); + testLineRange("This is a line of text\r\r", NSMakeRange(10, 10), NSMakeRange(0, 23)); + + PASS([@"1.2e3" doubleValue] == 1.2e3, "Simple double conversion works"); + PASS([@"4.5E6" floatValue] == 4.5e6, "Simple float conversion works"); + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test01.m b/Tests/base/NSString/test01.m new file mode 100644 index 000000000..b79eed71b --- /dev/null +++ b/Tests/base/NSString/test01.m @@ -0,0 +1,71 @@ +#import "Testing.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + PASS([[@"" pathComponents] count] == 0, "pathComponents ''"); + PASS([[@"usr" pathComponents] count] == 1, "pathComponents 'usr'"); + PASS([[@"usr/" pathComponents] count] == 2, "pathComponents 'usr/'"); + PASS([[@"usr/bin" pathComponents] count] == 2, "pathComponents 'usr/bin'"); + PASS([[@"usr//bin" pathComponents] count] == 2, "pathComponents 'usr//bin'"); + PASS([[@"usr///bin" pathComponents] count] == 2, "pathComponents 'usr///bin'"); + PASS([[@"/" pathComponents] count] == 1, "pathComponents '/'"); + PASS([[@"/usr" pathComponents] count] == 2, "pathComponents '/usr'"); + PASS([[@"/usr/" pathComponents] count] == 3, "pathComponents '/usr/'"); + PASS([[@"/usr/bin" pathComponents] count] == 3, "pathComponents '/usr/bin'"); + PASS([[@"/usr//bin" pathComponents] count] == 3, "pathComponents '/usr//bin'"); + PASS([[@"/usr///bin" pathComponents] count] == 3, "pathComponents '/usr///bin'"); + PASS([[@"" stringByAppendingPathComponent:@""] isEqual:@""], + "'' stringByAppendingPathComponent: ''"); + PASS([[@"" stringByAppendingPathComponent:@"usr"] isEqual:@"usr"], + "'' stringByAppendingPathComponent: 'usr'"); + PASS([[@"" stringByAppendingPathComponent:@"usr/"] isEqual:@"usr"], + "'' stringByAppendingPathComponent: 'usr/'"); + PASS([[@"" stringByAppendingPathComponent:@"/usr"] isEqual:@"/usr"], + "'' stringByAppendingPathComponent: '/usr'"); + PASS([[@"" stringByAppendingPathComponent:@"/usr/"] isEqual:@"/usr"], + "'' stringByAppendingPathComponent: '/usr/'"); + PASS([[@"/" stringByAppendingPathComponent:@""] isEqual:@"/"], + "'/' stringByAppendingPathComponent: ''"); + PASS([[@"/" stringByAppendingPathComponent:@"usr"] isEqual:@"/usr"], + "'/' stringByAppendingPathComponent: 'usr'"); + PASS([[@"/" stringByAppendingPathComponent:@"usr/"] isEqual:@"/usr"], + "'/' stringByAppendingPathComponent: 'usr/'"); + PASS([[@"/" stringByAppendingPathComponent:@"/usr"] isEqual:@"/usr"], + "'/' stringByAppendingPathComponent: '/usr'"); + PASS([[@"/" stringByAppendingPathComponent:@"/usr/"] isEqual:@"/usr"], + "'/' stringByAppendingPathComponent: '/usr/'"); + PASS([[@"usr" stringByAppendingPathComponent:@""] isEqual:@"usr"], + "'usr' stringByAppendingPathComponent: ''"); + PASS([[@"usr" stringByAppendingPathComponent:@"bin"] isEqual:@"usr/bin"], + "'usr' stringByAppendingPathComponent: 'bin'"); + PASS([[@"usr" stringByAppendingPathComponent:@"bin/"] isEqual:@"usr/bin"], + "'usr' stringByAppendingPathComponent: 'bin/'"); + PASS([[@"usr" stringByAppendingPathComponent:@"/bin"] isEqual:@"usr/bin"], + "'usr' stringByAppendingPathComponent: '/bin'"); + PASS([[@"usr" stringByAppendingPathComponent:@"/bin/"] isEqual:@"usr/bin"], + "'usr' stringByAppendingPathComponent: '/bin/'"); + PASS([[@"/usr" stringByAppendingPathComponent:@""] isEqual:@"/usr"], + "'/usr' stringByAppendingPathComponent: ''"); + PASS([[@"/usr" stringByAppendingPathComponent:@"bin"] isEqual:@"/usr/bin"], + "'/usr' stringByAppendingPathComponent: 'bin'"); + PASS([[@"/usr" stringByAppendingPathComponent:@"bin/"] isEqual:@"/usr/bin"], + "'/usr' stringByAppendingPathComponent: 'bin/'"); + PASS([[@"/usr" stringByAppendingPathComponent:@"/bin"] isEqual:@"/usr/bin"], + "'/usr' stringByAppendingPathComponent: '/bin'"); + PASS([[@"/usr" stringByAppendingPathComponent:@"/bin/"] isEqual:@"/usr/bin"], + "'/usr' stringByAppendingPathComponent: '/bin/'"); + PASS([[@"/usr/" stringByAppendingPathComponent:@""] isEqual:@"/usr"], + "'/usr/' stringByAppendingPathComponent: ''"); + PASS([[@"/usr/" stringByAppendingPathComponent:@"bin"] isEqual:@"/usr/bin"], + "'/usr/' stringByAppendingPathComponent: 'bin'"); + PASS([[@"/usr/" stringByAppendingPathComponent:@"bin/"] isEqual:@"/usr/bin"], + "'/usr/' stringByAppendingPathComponent: 'bin/'"); + PASS([[@"/usr/" stringByAppendingPathComponent:@"/bin/"] isEqual:@"/usr/bin"], + "'/usr/' stringByAppendingPathComponent: '/bin/'"); + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test02.m b/Tests/base/NSString/test02.m new file mode 100644 index 000000000..f737ff426 --- /dev/null +++ b/Tests/base/NSString/test02.m @@ -0,0 +1,349 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *result; + char *testPath = NULL; + char *resultPath = NULL; + + PASS([[[@"home" pathComponents] objectAtIndex:0] isEqual: @"home"], + "[@\"home\" pathComponents] == @\"home\"]"); + + result = [@"/home" pathComponents]; + PASS([[result objectAtIndex:0] isEqual: @"/"] + && [[result objectAtIndex:1] isEqual: @"home"], + "[@\"/home\" pathComponents] == (@\"/\", @\"home\"])"); + + result = [@"/home/" pathComponents]; + PASS([[result objectAtIndex:0] isEqual: @"/"] + && [[result objectAtIndex:1] isEqual: @"home"] + && [[result objectAtIndex:2] isEqual: @"/"], + "[@\"/home\" pathComponents] == (@\"/\", @\"home\",\"/\")]"); + + result = [@"/home/nicola" pathComponents]; + PASS([[result objectAtIndex:0] isEqual: @"/"] + && [[result objectAtIndex:1] isEqual: @"home"] + && [[result objectAtIndex:2] isEqual: @"nicola"], + "[@\"/home/nicola\" pathComponents] == (@\"/\", @\"home\",\"nicola\")]"); + + result = [@"//home//nicola" pathComponents]; + PASS([[result objectAtIndex:0] isEqual: @"/"] + && [[result objectAtIndex:1] isEqual: @"home"] + && [[result objectAtIndex:2] isEqual: @"nicola"], + "[@\"//home//nicola\" pathComponents] == (@\"/\", @\"home\",\"nicola\")]"); + PASS([[@"home/nicola.jpg" pathExtension] isEqual: @"jpg"], + "[@\"home/nicola.jpg\" pathExtension] == @\"jpg\""); + + PASS([[@"/home/nicola.jpg" pathExtension] isEqual: @"jpg"], + "[@\"/home/nicola.jpg\\\" pathExtension] == @\"jpg\""); + + PASS([[@"home/nicola" pathExtension] isEqual: @""], + "[@\"home/nicola\" pathExtension] == @\"\""); + + PASS([[@"home/nicola/" pathExtension] isEqual: @""], + "[@\"home/nicola\" pathExtension] == @\"\""); + + PASS([[@"/home/nicola..jpg" pathExtension] isEqual: @"jpg"], + "[@\"/home/nicola..jpg\" pathExtension] == @\"jpg\""); + + PASS([[@"/home/nicola.jpg/" pathExtension] isEqual: @"jpg"], + "[@\"/home/nicola.jpg/\" pathExtension] == @\"jpg\""); + + PASS([[@"/home/nicola.jpg/extra" pathExtension] isEqual: @""], + "[@\"/home/nicola.jpg/extra\" pathExtension] == @\"\""); + + PASS([[@"/home/nicola./" pathExtension] isEqual: @""], + "[@\"/home/nicola./\" pathExtension] == @\"\""); + + PASS([[@"/home" stringByAppendingPathComponent: @"nicola.jpg"] isEqual: @"/home/nicola.jpg"], + "'/home' stringByAppendingPathComponent: 'nicola.jpg' == '/home/nicola.jpg'"); + + PASS([[@"/home/" stringByAppendingPathComponent: @"nicola.jpg"] isEqual: @"/home/nicola.jpg"], + "'/home/' stringByAppendingPathComponent: 'nicola.jpg' == '/home/nicola.jpg'"); + + PASS([[@"/" stringByAppendingPathComponent: @"nicola.jpg"] isEqual: @"/nicola.jpg"], + "'/' stringByAppendingPathComponent: 'nicola.jpg' == '/nicola.jpg'"); + + PASS([[@"" stringByAppendingPathComponent: @"nicola.jpg"] isEqual: @"nicola.jpg"], + "'' stringByAppendingPathComponent: 'nicola.jpg' == 'nicola.jpg'"); + + PASS([[@"/home/nicola.jpg" stringByAppendingPathExtension: @"jpg"] isEqual: @"/home/nicola.jpg.jpg"], + "'/home/nicola.jpg' stringByAppendingPathExtension:'jpg' == '/home/nicola.jpg.jpg'"); + + PASS([[@"/home/nicola." stringByAppendingPathExtension: @"jpg"] isEqual: @"/home/nicola..jpg"], + "'/home/nicola.' stringByAppendingPathExtension:'jpg' == '/home/nicola..jpg'"); + + /* in the guile version of this test the description was different than the + test i've updated it for the description to be the same as the test not + sure which is correct but the test PASSes */ + PASS([[@"/home/nicola/" stringByAppendingPathExtension: @"jpg"] isEqual: @"/home/nicola.jpg"], + "'/home/nicola/' stringByAppendingPathExtension:'jpg' == '/home/nicola.jpg'"); + + PASS([[@"nicola" stringByAppendingPathExtension: @"jpg"] isEqual: @"nicola.jpg"], + "'nicola' stringByAppendingPathExtension:'jpg' == 'nicola.jpg'"); + + PASS([[@"nicola" stringByAppendingPathExtension: @"jpg"] isEqual: @"nicola.jpg"], + "'nicola' stringByAppendingPathExtension:'jpg' == 'nicola.jpg'"); + + /* string by deleting last path component tests */ + + PASS([[@"/home/nicola.jpg" stringByDeletingLastPathComponent] isEqual: @"/home"], + "'/home/nicola.jpg' stringByDeletingLastPathComponent == '/home'"); + + PASS([[@"/home/nicola/" stringByDeletingLastPathComponent] isEqual: @"/home"], + "'/home/nicola/' stringByDeletingLastPathComponent == '/home'"); + PASS([[@"/home/nicola" stringByDeletingLastPathComponent] isEqual: @"/home"], + "'/home/nicola' stringByDeletingLastPathComponent == '/'"); + PASS([[@"/home/" stringByDeletingLastPathComponent] isEqual: @"/"], + "'/home/' stringByDeletingLastPathComponent == '/'"); + PASS([[@"/home" stringByDeletingLastPathComponent] isEqual: @"/"], + "'/home' stringByDeletingLastPathComponent == '/'"); + PASS([[@"/" stringByDeletingLastPathComponent] isEqual: @"/"], + "'/' stringByDeletingLastPathComponent == '/'"); + PASS([[@"hello" stringByDeletingLastPathComponent] isEqual: @""], + "'hello' stringByDeletingLastPathComponent == ''"); + PASS_EQUAL([@"/hello/there/.." stringByDeletingLastPathComponent], + @"/hello/there", + "'/hello/there/..' stringByDeletingLastPathComponent == '/hello/there'"); + PASS_EQUAL([@"/hello/there/." stringByDeletingLastPathComponent], + @"/hello/there", + "'/hello/there/.' stringByDeletingLastPathComponent == '/hello/there'"); + PASS_EQUAL([@"/hello/../there" stringByDeletingLastPathComponent], + @"/hello/..", + "'/hello/../there' stringByDeletingLastPathComponent == '/hello/..'"); + PASS_EQUAL([@"/hello//../there" stringByDeletingLastPathComponent], + @"/hello/..", + "'/hello//../there' stringByDeletingLastPathComponent == '/hello/..'"); + +/* Check behavior for UNC absolute and relative paths. + */ +#ifdef GNUSTEP_BASE_LIBRARY + GSPathHandling("gnustep"); + + // UNC + PASS_EQUAL([@"//host/share/file.jpg" stringByDeletingLastPathComponent], + @"//host/share/", + "'//host/file.jpg' stringByDeletingLastPathComponent == '//host/'"); + + // UNC + PASS_EQUAL([@"//host/share/" stringByDeletingLastPathComponent], + @"//host/share/", + "'//host/share/' stringByDeletingLastPathComponent == '//host/share/'"); + + // Not UNC + PASS_EQUAL([@"///host/share/" stringByDeletingLastPathComponent], + @"/host", + "'///host/share/' stringByDeletingLastPathComponent == '/host'"); + + // Not UNC + PASS_EQUAL([@"//host/share" stringByDeletingLastPathComponent], + @"/host", + "'//host/share' stringByDeletingLastPathComponent == '/host'"); + + // Not UNC + PASS_EQUAL([@"//dir/" stringByDeletingLastPathComponent], + @"/", + "'//dir/' stringByDeletingLastPathComponent == '/'"); + + GSPathHandling("unix"); +#endif + +/* Check behavior when UNC paths are not supported. + */ + PASS([[@"//host/share/file.jpg" stringByDeletingLastPathComponent] + isEqual: @"/host/share"], + "'//host/file.jpg' stringByDeletingLastPathComponent == '/host/share'"); + PASS([[@"//host/share/" stringByDeletingLastPathComponent] + isEqual: @"/host"], + "'//host/share/' stringByDeletingLastPathComponent == '/host'"); + PASS([[@"//host/share" stringByDeletingLastPathComponent] + isEqual: @"/host"], + "'//host/share' stringByDeletingLastPathComponent == '/host'"); + PASS([[@"//dir/" stringByDeletingLastPathComponent] isEqual: @"/"], + "'//dir/' stringByDeletingLastPathComponent == '/'"); + +#ifdef GNUSTEP_BASE_LIBRARY + GSPathHandling("gnustep"); +#endif + + /* delete path extension tests */ + PASS([[@"/home/nicola.jpg" stringByDeletingPathExtension] isEqual: @"/home/nicola"], + "'/home/nicola.jpg' stringByDeletingPathExtension == '/home/nicola'"); + PASS([[@"/home/" stringByDeletingPathExtension] isEqual: @"/home"], + "'/home/' stringByDeletingPathExtension == '/home'"); + PASS([[@"nicola.jpg" stringByDeletingPathExtension] isEqual: @"nicola"], + "'nicola.jpg' stringByDeletingPathExtension == 'nicola'"); + PASS([[@"nicola..jpg" stringByDeletingPathExtension] isEqual: @"nicola."], + "'nicola..jpg' stringByDeletingPathExtension == 'nicola.'"); + PASS([[@".jpg" stringByDeletingPathExtension] isEqual: @".jpg"], + "'.jpg' stringByDeletingPathExtension == '.jpg'"); + PASS([[@"/" stringByDeletingPathExtension] isEqual: @"/"], + "'/' stringByDeletingPathExtension == '/'"); + + /* stringByExpandingTildeInPath tests */ + + PASS([[@"/home/nicola/nil" stringByExpandingTildeInPath] + isEqual: @"/home/nicola/nil"], + "'/home/nicola/nil' stringByExpandingTildeInPath: == '/home/nicola/nil'"); + PASS(![[@"~/nil" stringByExpandingTildeInPath] + isEqual: @"~/nil"], + "'~/nil' stringByExpandingTildeInPath: != '~/nil'"); + +#if defined(__MINGW32__) + { + NSString *s = [@"~" stringByAppendingString: NSUserName()]; + PASS(![[s stringByExpandingTildeInPath] isEqual: s], + "'~user' stringByExpandingTildeInPath: != '~user'"); + } +#else + PASS(![[@"~root" stringByExpandingTildeInPath] + isEqual: @"~root"], + "'~root' stringByExpandingTildeInPath: != '~root'"); +#endif + +#ifdef GNUSTEP_BASE_LIBRARY + + PASS_EQUAL([@"//home/user/" stringByStandardizingPath], @"//home/user/", + "//home/user/ stringByStandardizingPath == //home/user/"); + + PASS_EQUAL([@"\\\\home\\user\\" stringByStandardizingPath], + @"\\\\home\\user\\", + "\\\\home\\user\\ stringByStandardizingPath == \\\\home\\user\\"); + + PASS_EQUAL([@"c:\\." stringByStandardizingPath], @"c:\\.", + "'c:\\.' stringByStandardizingPath == 'c:\\.'"); + + PASS_EQUAL([@"c:\\..." stringByStandardizingPath], @"c:\\...", + "'c:\\...' stringByStandardizingPath == 'c:\\...'"); + + PASS([@"c:/home" isAbsolutePath] == YES, + "'c:/home' isAbsolutePath == YES"); + + PASS([@"//host/share/" isAbsolutePath] == YES, + "'//host/share/' isAbsolutePath == YES"); + +#endif + + PASS_EQUAL([@"/home//user/" stringByStandardizingPath], @"/home/user", + "/home//user/ stringByStandardizingPath == /home/user"); + + PASS_EQUAL([@"//home/user" stringByStandardizingPath], @"/home/user", + "//home/user stringByStandardizingPath == /home/user"); + + PASS_EQUAL([@"///home/user" stringByStandardizingPath], @"/home/user", + "///home/user stringByStandardizingPath == /home/user"); + + PASS_EQUAL([@"/home/./user" stringByStandardizingPath], @"/home/user", + "/home/./user stringByStandardizingPath == /home/user"); + + PASS_EQUAL([@"/home/user/." stringByStandardizingPath], @"/home/user", + "/home/user/. stringByStandardizingPath == /home/user"); + + PASS_EQUAL([@"/home/.//././user" stringByStandardizingPath], @"/home/user", + "/home/.//././user stringByStandardizingPath == /home/user"); + +#if defined(GNUSTEP_BASE_LIBRARY) + GSPathHandling("unix"); +#endif + + PASS_EQUAL([@"/home/../nicola" stringByStandardizingPath], @"/nicola", + "/home/../nicola stringByStandardizingPath == /nicola"); + + PASS_EQUAL([@"/here/and/there/../../nicola" stringByStandardizingPath], + @"/here/nicola", + "/here/and/there/../../nicola stringByStandardizingPath == /here/nicola"); + + PASS_EQUAL([@"/here/../../nicola" stringByStandardizingPath], + @"/nicola", + "/here/../../nicola stringByStandardizingPath == /nicola"); + + PASS_EQUAL([@"home/../nicola" stringByStandardizingPath], @"home/../nicola", + "home/../nicola stringByStandardizingPath == home/../nicola"); + + PASS_EQUAL([@"a/b/../c" stringByStandardizingPath], @"a/b/../c", + "a/b/../c stringByStandardizingPath == a/b/../c"); + + NSFileManager *fm = [NSFileManager defaultManager]; + NSString *cwd = [fm currentDirectoryPath]; + NSString *tmpdir = NSTemporaryDirectory(); + NSString *tmpdst = [tmpdir stringByAppendingPathComponent: @"bar"]; + NSString *tmpsrc = [tmpdir stringByAppendingPathComponent: @"foo"]; + + [fm createDirectoryAtPath: tmpdst attributes: nil]; + [fm createSymbolicLinkAtPath: tmpsrc pathContent: @"bar"]; + + [fm changeCurrentDirectoryPath: tmpdir]; + testHopeful = YES; + PASS_EQUAL([@"foo" stringByResolvingSymlinksInPath], @"foo", + "foo->bar relative symlink not expanded by stringByResolvingSymlinksInPath") + testHopeful = NO; + [fm changeCurrentDirectoryPath: cwd]; + + [fm removeFileAtPath: tmpsrc handler: nil]; + [fm createSymbolicLinkAtPath: tmpsrc pathContent: tmpdst]; + +#if !defined(__MINGW32__) + PASS_EQUAL([tmpsrc stringByStandardizingPath], tmpsrc, + "foo->bar symlink not expanded by stringByStandardizingPath") + PASS_EQUAL([tmpsrc stringByResolvingSymlinksInPath], tmpdst, + "foo->bar absolute symlink expanded by stringByResolvingSymlinksInPath") + + [fm changeCurrentDirectoryPath: tmpdir]; + PASS_EQUAL([@"foo" stringByResolvingSymlinksInPath], tmpdst, + "foo->bar relative symlink expanded by stringByResolvingSymlinksInPath") +#endif + + PASS(NO == [[@"~" stringByResolvingSymlinksInPath] isEqual: @"~"], + "tilde is expanded by stringByResolvingSymlinksInPath") + [fm changeCurrentDirectoryPath: cwd]; + + [fm removeFileAtPath: tmpdst handler: nil]; + [fm removeFileAtPath: tmpsrc handler: nil]; + + PASS_EQUAL([@"/.." stringByStandardizingPath], @"/", + "/.. stringByStandardizingPath == /"); + PASS_EQUAL([@"/." stringByStandardizingPath], @"/.", + "/. stringByStandardizingPath == /. (OSX special case)"); + +#if defined(GNUSTEP_BASE_LIBRARY) + GSPathHandling("gnustep"); +#endif + + + result = [NSArray arrayWithObjects: @"nicola",@"core",nil]; + result = [@"home" stringsByAppendingPaths:result]; + PASS([result count] == 2 + && [[result objectAtIndex:0] isEqual: @"home/nicola"] + && [[result objectAtIndex:1] isEqual: @"home/core"], + "stringsByAppendingPaths works"); + + PASS([@"home" isAbsolutePath] == NO, + "'home' isAbsolutePath == NO"); + +#if defined(__MINGW32__) + PASS([@"/home" isAbsolutePath] == NO, + "'/home' isAbsolutePath == NO"); + PASS([@"//host/share" isAbsolutePath] == NO, + "'//host/share' isAbsolutePath == NO"); +#else + PASS([@"/home" isAbsolutePath] == YES, + "'/home' isAbsolutePath == YES"); + PASS([@"//host/share" isAbsolutePath] == YES, + "'//host/share' isAbsolutePath == YES"); +#endif + + result = [NSArray arrayWithObjects: @"nicola",@"core",nil]; + PASS([[NSString pathWithComponents:result] isEqual: @"nicola/core"], + "+pathWithComponents works for relative path"); + result = [NSArray arrayWithObjects: @"/", @"nicola", @"core", nil]; + PASS([[NSString pathWithComponents:result] isEqual: @"/nicola/core"], + "+pathWithComponents works works for absolute path"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test03.m b/Tests/base/NSString/test03.m new file mode 100644 index 000000000..f133e7345 --- /dev/null +++ b/Tests/base/NSString/test03.m @@ -0,0 +1,69 @@ +#import "Testing.h" +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSCharacterSet *ws = [NSCharacterSet whitespaceAndNewlineCharacterSet]; + PASS([[@"" stringByTrimmingLeadSpaces] isEqual:@""], + "'' stringByTrimmingLeadSpaces == ''"); + PASS([[@"home" stringByTrimmingLeadSpaces] isEqual:@"home"], + "'home' stringByTrimmingLeadSpaces == 'home'"); + PASS([[@" hello" stringByTrimmingLeadSpaces] isEqual:@"hello"], + "' hello' stringByTrimmingLeadSpaces == 'hello'"); + PASS([[@"\thello" stringByTrimmingLeadSpaces] isEqual:@"hello"], + "'\\thello' stringByTrimmingLeadSpaces == 'hello'"); + PASS([[@"\nhello" stringByTrimmingLeadSpaces] isEqual:@"hello"], + "'\\nhello' stringByTrimmingLeadSpaces == 'hello'"); + + PASS([[@"" stringByTrimmingTailSpaces] isEqual:@""], + "'' stringByTrimmingTailSpaces == ''"); + PASS([[@"home" stringByTrimmingTailSpaces] isEqual:@"home"], + "'home' stringByTrimmingTailSpaces == 'home'"); + PASS([[@"hello " stringByTrimmingTailSpaces] isEqual:@"hello"], + "'hello ' stringByTrimmingTailSpaces == 'hello'"); + PASS([[@"hello\t" stringByTrimmingTailSpaces] isEqual:@"hello"], + "'hello\\t' stringByTrimmingTailSpaces == 'hello'"); + PASS([[@"hello\n" stringByTrimmingTailSpaces] isEqual:@"hello"], + "'hello\\n' stringByTrimmingTailSpaces == 'hello'"); + + PASS([[@"" stringByTrimmingSpaces] isEqual:@""], + "'' stringByTrimmingSpaces == ''"); + PASS([[@"home" stringByTrimmingSpaces] isEqual:@"home"], + "'home' stringByTrimmingSpaces == 'home'"); + PASS([[@" hello" stringByTrimmingSpaces] isEqual:@"hello"], + "' hello' stringByTrimmingSpaces == 'hello'"); + PASS([[@"\thello" stringByTrimmingSpaces] isEqual:@"hello"], + "'\\thello' stringByTrimmingSpaces == 'hello'"); + PASS([[@"\nhello" stringByTrimmingSpaces] isEqual:@"hello"], + "'\\nhello' stringByTrimmingSpaces == 'hello'"); + + PASS([[@"home" stringByTrimmingCharactersInSet:ws] isEqual: @"home"], + "'home' stringByTrimmingCharactersInSet == 'home'"); + PASS([[@"hello\n" stringByTrimmingCharactersInSet:ws] isEqual: @"hello"], + "'hello\\n' stringByTrimmingCharactersInSet == 'hello'"); + PASS([[@"\nhello" stringByTrimmingCharactersInSet:ws] isEqual: @"hello"], + "'\\nhello' stringByTrimmingCharactersInSet == 'hello'"); + PASS([[@"\nhello\n" stringByTrimmingCharactersInSet:ws] isEqual: @"hello"], + "'\nhello\n' stringByTrimmingCharactersInSet == 'hello'"); + PASS([[@"\n \n" stringByTrimmingCharactersInSet:ws] isEqual: @""], + "'\\n \\n' stringByTrimmingCharactersInSet == ''"); + + PASS([[@"hello" stringByPaddingToLength:3 + withString:@"." + startingAtIndex:0] isEqual:@"hel"], + "'hello' stringByPaddingToLength:3 withString:'.' startingAtIndex:0 == 'hel'"); + PASS([[@"hello" stringByPaddingToLength:8 + withString:@"." + startingAtIndex:0] isEqual:@"hello..."], + "'hello' stringByPaddingToLength:8 withString:'.' startingAtIndex:0 == 'hello...'"); + PASS([[@"hello" stringByPaddingToLength:8 + withString:@"xy" + startingAtIndex:1] isEqual:@"helloyxy"], + "'hello' stringByPaddingToLength:8 withString:'xy' startingAtIndex:0 == 'helloyxy'"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test04.m b/Tests/base/NSString/test04.m new file mode 100644 index 000000000..e738a7297 --- /dev/null +++ b/Tests/base/NSString/test04.m @@ -0,0 +1,19 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *theString; + unichar theUniChar[1] = {0xdd00}; + theString = [NSString stringWithCharacters:theUniChar length:1]; + NS_DURING + PASS(theString == nil, "bad unichar"); + NS_HANDLER + PASS(1,"bar"); + NS_ENDHANDLER + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test05.m b/Tests/base/NSString/test05.m new file mode 100644 index 000000000..164386fab --- /dev/null +++ b/Tests/base/NSString/test05.m @@ -0,0 +1,28 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *theString; + unichar theUniChar[1] = {0xe5}; + theString = [NSString stringWithCharacters:theUniChar length:1]; + + PASS([theString isEqual:[[NSString alloc] initWithCString: [theString cStringUsingEncoding: NSISOLatin1StringEncoding] encoding: NSISOLatin1StringEncoding]],"foo"); + + NS_DURING + PASS([theString isEqual:[[NSString alloc] initWithCString: [theString cString]]],"foo"); + NS_HANDLER + PASS(1,"bar"); + NS_ENDHANDLER + + NS_DURING + PASS([theString isEqual:[[NSMutableString alloc] initWithCString: [theString cString]]],"foo2"); + NS_HANDLER + PASS(1,"bar2"); + NS_ENDHANDLER + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test06.m b/Tests/base/NSString/test06.m new file mode 100644 index 000000000..02cc036fc --- /dev/null +++ b/Tests/base/NSString/test06.m @@ -0,0 +1,1298 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + char c[2]; + unsigned i; + NSString *s; + NSString *e; + + c[1] = 0; + + c[0] = 0; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%00"], "character 0 is escaped"); + c[0] = 1; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%01"], "character 1 is escaped"); + c[0] = 2; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%02"], "character 2 is escaped"); + c[0] = 3; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%03"], "character 3 is escaped"); + c[0] = 4; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%04"], "character 4 is escaped"); + c[0] = 5; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%05"], "character 5 is escaped"); + c[0] = 6; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%06"], "character 6 is escaped"); + c[0] = 7; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%07"], "character 7 is escaped"); + c[0] = 8; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%08"], "character 8 is escaped"); + c[0] = 9; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%09"], "character 9 is escaped"); + c[0] = 10; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%0A"], "character 10 is escaped"); + c[0] = 11; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%0B"], "character 11 is escaped"); + c[0] = 12; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%0C"], "character 12 is escaped"); + c[0] = 13; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%0D"], "character 13 is escaped"); + c[0] = 14; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%0E"], "character 14 is escaped"); + c[0] = 15; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%0F"], "character 15 is escaped"); + c[0] = 16; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%10"], "character 16 is escaped"); + c[0] = 17; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%11"], "character 17 is escaped"); + c[0] = 18; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%12"], "character 18 is escaped"); + c[0] = 19; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%13"], "character 19 is escaped"); + c[0] = 20; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%14"], "character 20 is escaped"); + c[0] = 21; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%15"], "character 21 is escaped"); + c[0] = 22; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%16"], "character 22 is escaped"); + c[0] = 23; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%17"], "character 23 is escaped"); + c[0] = 24; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%18"], "character 24 is escaped"); + c[0] = 25; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%19"], "character 25 is escaped"); + c[0] = 26; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%1A"], "character 26 is escaped"); + c[0] = 27; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%1B"], "character 27 is escaped"); + c[0] = 28; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%1C"], "character 28 is escaped"); + c[0] = 29; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%1D"], "character 29 is escaped"); + c[0] = 30; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%1E"], "character 30 is escaped"); + c[0] = 31; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%1F"], "character 31 is escaped"); + c[0] = 32; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%20"], "character 32 is escaped"); + c[0] = 33; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 33 is not escaped"); + c[0] = 34; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%22"], "character 34 is escaped"); + c[0] = 35; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%23"], "character 35 is escaped"); + c[0] = 36; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 36 is not escaped"); + c[0] = 37; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%25"], "character 37 is escaped"); + c[0] = 38; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 38 is not escaped"); + c[0] = 39; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 39 is not escaped"); + c[0] = 40; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 40 is not escaped"); + c[0] = 41; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 41 is not escaped"); + c[0] = 42; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 42 is not escaped"); + c[0] = 43; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 43 is not escaped"); + c[0] = 44; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 44 is not escaped"); + c[0] = 45; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 45 is not escaped"); + c[0] = 46; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 46 is not escaped"); + c[0] = 47; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 47 is not escaped"); + c[0] = 48; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 48 is not escaped"); + c[0] = 49; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 49 is not escaped"); + c[0] = 50; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 50 is not escaped"); + c[0] = 51; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 51 is not escaped"); + c[0] = 52; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 52 is not escaped"); + c[0] = 53; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 53 is not escaped"); + c[0] = 54; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 54 is not escaped"); + c[0] = 55; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 55 is not escaped"); + c[0] = 56; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 56 is not escaped"); + c[0] = 57; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 57 is not escaped"); + c[0] = 58; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 58 is not escaped"); + c[0] = 59; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 59 is not escaped"); + c[0] = 60; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%3C"], "character 60 is escaped"); + c[0] = 61; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 61 is not escaped"); + c[0] = 62; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%3E"], "character 62 is escaped"); + c[0] = 63; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 63 is not escaped"); + c[0] = 64; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 64 is not escaped"); + c[0] = 65; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 65 is not escaped"); + c[0] = 66; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 66 is not escaped"); + c[0] = 67; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 67 is not escaped"); + c[0] = 68; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 68 is not escaped"); + c[0] = 69; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 69 is not escaped"); + c[0] = 70; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 70 is not escaped"); + c[0] = 71; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 71 is not escaped"); + c[0] = 72; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 72 is not escaped"); + c[0] = 73; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 73 is not escaped"); + c[0] = 74; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 74 is not escaped"); + c[0] = 75; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 75 is not escaped"); + c[0] = 76; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 76 is not escaped"); + c[0] = 77; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 77 is not escaped"); + c[0] = 78; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 78 is not escaped"); + c[0] = 79; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 79 is not escaped"); + c[0] = 80; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 80 is not escaped"); + c[0] = 81; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 81 is not escaped"); + c[0] = 82; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 82 is not escaped"); + c[0] = 83; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 83 is not escaped"); + c[0] = 84; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 84 is not escaped"); + c[0] = 85; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 85 is not escaped"); + c[0] = 86; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 86 is not escaped"); + c[0] = 87; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 87 is not escaped"); + c[0] = 88; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 88 is not escaped"); + c[0] = 89; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 89 is not escaped"); + c[0] = 90; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 90 is not escaped"); + c[0] = 91; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%5B"], "character 91 is escaped"); + c[0] = 92; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%5C"], "character 92 is escaped"); + c[0] = 93; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%5D"], "character 93 is escaped"); + c[0] = 94; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%5E"], "character 94 is escaped"); + c[0] = 95; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 95 is not escaped"); + c[0] = 96; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%60"], "character 96 is escaped"); + c[0] = 97; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 97 is not escaped"); + c[0] = 98; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 98 is not escaped"); + c[0] = 99; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 99 is not escaped"); + c[0] = 100; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 100 is not escaped"); + c[0] = 101; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 101 is not escaped"); + c[0] = 102; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 102 is not escaped"); + c[0] = 103; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 103 is not escaped"); + c[0] = 104; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 104 is not escaped"); + c[0] = 105; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 105 is not escaped"); + c[0] = 106; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 106 is not escaped"); + c[0] = 107; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 107 is not escaped"); + c[0] = 108; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 108 is not escaped"); + c[0] = 109; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 109 is not escaped"); + c[0] = 110; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 110 is not escaped"); + c[0] = 111; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 111 is not escaped"); + c[0] = 112; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 112 is not escaped"); + c[0] = 113; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 113 is not escaped"); + c[0] = 114; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 114 is not escaped"); + c[0] = 115; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 115 is not escaped"); + c[0] = 116; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 116 is not escaped"); + c[0] = 117; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 117 is not escaped"); + c[0] = 118; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 118 is not escaped"); + c[0] = 119; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 119 is not escaped"); + c[0] = 120; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 120 is not escaped"); + c[0] = 121; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 121 is not escaped"); + c[0] = 122; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 122 is not escaped"); + c[0] = 123; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%7B"], "character 123 is escaped"); + c[0] = 124; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%7C"], "character 124 is escaped"); + c[0] = 125; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%7D"], "character 125 is escaped"); + c[0] = 126; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: s], "character 126 is not escaped"); + c[0] = 127; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%7F"], "character 127 is escaped"); + c[0] = 128; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%80"], "character 128 is escaped"); + c[0] = 129; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%81"], "character 129 is escaped"); + c[0] = 130; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%82"], "character 130 is escaped"); + c[0] = 131; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%83"], "character 131 is escaped"); + c[0] = 132; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%84"], "character 132 is escaped"); + c[0] = 133; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%85"], "character 133 is escaped"); + c[0] = 134; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%86"], "character 134 is escaped"); + c[0] = 135; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%87"], "character 135 is escaped"); + c[0] = 136; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%88"], "character 136 is escaped"); + c[0] = 137; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%89"], "character 137 is escaped"); + c[0] = 138; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%8A"], "character 138 is escaped"); + c[0] = 139; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%8B"], "character 139 is escaped"); + c[0] = 140; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%8C"], "character 140 is escaped"); + c[0] = 141; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%8D"], "character 141 is escaped"); + c[0] = 142; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%8E"], "character 142 is escaped"); + c[0] = 143; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%8F"], "character 143 is escaped"); + c[0] = 144; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%90"], "character 144 is escaped"); + c[0] = 145; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%91"], "character 145 is escaped"); + c[0] = 146; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%92"], "character 146 is escaped"); + c[0] = 147; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%93"], "character 147 is escaped"); + c[0] = 148; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%94"], "character 148 is escaped"); + c[0] = 149; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%95"], "character 149 is escaped"); + c[0] = 150; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%96"], "character 150 is escaped"); + c[0] = 151; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%97"], "character 151 is escaped"); + c[0] = 152; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%98"], "character 152 is escaped"); + c[0] = 153; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%99"], "character 153 is escaped"); + c[0] = 154; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%9A"], "character 154 is escaped"); + c[0] = 155; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%9B"], "character 155 is escaped"); + c[0] = 156; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%9C"], "character 156 is escaped"); + c[0] = 157; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%9D"], "character 157 is escaped"); + c[0] = 158; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%9E"], "character 158 is escaped"); + c[0] = 159; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%9F"], "character 159 is escaped"); + c[0] = 160; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A0"], "character 160 is escaped"); + c[0] = 161; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A1"], "character 161 is escaped"); + c[0] = 162; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A2"], "character 162 is escaped"); + c[0] = 163; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A3"], "character 163 is escaped"); + c[0] = 164; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A4"], "character 164 is escaped"); + c[0] = 165; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A5"], "character 165 is escaped"); + c[0] = 166; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A6"], "character 166 is escaped"); + c[0] = 167; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A7"], "character 167 is escaped"); + c[0] = 168; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A8"], "character 168 is escaped"); + c[0] = 169; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%A9"], "character 169 is escaped"); + c[0] = 170; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%AA"], "character 170 is escaped"); + c[0] = 171; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%AB"], "character 171 is escaped"); + c[0] = 172; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%AC"], "character 172 is escaped"); + c[0] = 173; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%AD"], "character 173 is escaped"); + c[0] = 174; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%AE"], "character 174 is escaped"); + c[0] = 175; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%AF"], "character 175 is escaped"); + c[0] = 176; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B0"], "character 176 is escaped"); + c[0] = 177; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B1"], "character 177 is escaped"); + c[0] = 178; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B2"], "character 178 is escaped"); + c[0] = 179; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B3"], "character 179 is escaped"); + c[0] = 180; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B4"], "character 180 is escaped"); + c[0] = 181; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B5"], "character 181 is escaped"); + c[0] = 182; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B6"], "character 182 is escaped"); + c[0] = 183; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B7"], "character 183 is escaped"); + c[0] = 184; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B8"], "character 184 is escaped"); + c[0] = 185; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%B9"], "character 185 is escaped"); + c[0] = 186; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%BA"], "character 186 is escaped"); + c[0] = 187; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%BB"], "character 187 is escaped"); + c[0] = 188; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%BC"], "character 188 is escaped"); + c[0] = 189; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%BD"], "character 189 is escaped"); + c[0] = 190; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%BE"], "character 190 is escaped"); + c[0] = 191; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%BF"], "character 191 is escaped"); + c[0] = 192; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C0"], "character 192 is escaped"); + c[0] = 193; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C1"], "character 193 is escaped"); + c[0] = 194; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C2"], "character 194 is escaped"); + c[0] = 195; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C3"], "character 195 is escaped"); + c[0] = 196; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C4"], "character 196 is escaped"); + c[0] = 197; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C5"], "character 197 is escaped"); + c[0] = 198; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C6"], "character 198 is escaped"); + c[0] = 199; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C7"], "character 199 is escaped"); + c[0] = 200; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C8"], "character 200 is escaped"); + c[0] = 201; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%C9"], "character 201 is escaped"); + c[0] = 202; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%CA"], "character 202 is escaped"); + c[0] = 203; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%CB"], "character 203 is escaped"); + c[0] = 204; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%CC"], "character 204 is escaped"); + c[0] = 205; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%CD"], "character 205 is escaped"); + c[0] = 206; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%CE"], "character 206 is escaped"); + c[0] = 207; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%CF"], "character 207 is escaped"); + c[0] = 208; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D0"], "character 208 is escaped"); + c[0] = 209; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D1"], "character 209 is escaped"); + c[0] = 210; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D2"], "character 210 is escaped"); + c[0] = 211; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D3"], "character 211 is escaped"); + c[0] = 212; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D4"], "character 212 is escaped"); + c[0] = 213; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D5"], "character 213 is escaped"); + c[0] = 214; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D6"], "character 214 is escaped"); + c[0] = 215; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D7"], "character 215 is escaped"); + c[0] = 216; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D8"], "character 216 is escaped"); + c[0] = 217; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%D9"], "character 217 is escaped"); + c[0] = 218; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%DA"], "character 218 is escaped"); + c[0] = 219; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%DB"], "character 219 is escaped"); + c[0] = 220; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%DC"], "character 220 is escaped"); + c[0] = 221; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%DD"], "character 221 is escaped"); + c[0] = 222; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%DE"], "character 222 is escaped"); + c[0] = 223; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%DF"], "character 223 is escaped"); + c[0] = 224; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E0"], "character 224 is escaped"); + c[0] = 225; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E1"], "character 225 is escaped"); + c[0] = 226; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E2"], "character 226 is escaped"); + c[0] = 227; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E3"], "character 227 is escaped"); + c[0] = 228; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E4"], "character 228 is escaped"); + c[0] = 229; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E5"], "character 229 is escaped"); + c[0] = 230; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E6"], "character 230 is escaped"); + c[0] = 231; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E7"], "character 231 is escaped"); + c[0] = 232; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E8"], "character 232 is escaped"); + c[0] = 233; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%E9"], "character 233 is escaped"); + c[0] = 234; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%EA"], "character 234 is escaped"); + c[0] = 235; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%EB"], "character 235 is escaped"); + c[0] = 236; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%EC"], "character 236 is escaped"); + c[0] = 237; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%ED"], "character 237 is escaped"); + c[0] = 238; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%EE"], "character 238 is escaped"); + c[0] = 239; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%EF"], "character 239 is escaped"); + c[0] = 240; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F0"], "character 240 is escaped"); + c[0] = 241; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F1"], "character 241 is escaped"); + c[0] = 242; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F2"], "character 242 is escaped"); + c[0] = 243; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F3"], "character 243 is escaped"); + c[0] = 244; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F4"], "character 244 is escaped"); + c[0] = 245; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F5"], "character 245 is escaped"); + c[0] = 246; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F6"], "character 246 is escaped"); + c[0] = 247; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F7"], "character 247 is escaped"); + c[0] = 248; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F8"], "character 248 is escaped"); + c[0] = 249; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%F9"], "character 249 is escaped"); + c[0] = 250; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%FA"], "character 250 is escaped"); + c[0] = 251; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%FB"], "character 251 is escaped"); + c[0] = 252; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%FC"], "character 252 is escaped"); + c[0] = 253; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%FD"], "character 253 is escaped"); + c[0] = 254; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%FE"], "character 254 is escaped"); + c[0] = 255; + s = [[NSString alloc] + initWithBytes: c length: 1 encoding: NSISOLatin1StringEncoding]; + e = [s stringByAddingPercentEscapesUsingEncoding: NSISOLatin1StringEncoding]; + PASS([e isEqual: @"%FF"], "character 255 is escaped"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/test07.m b/Tests/base/NSString/test07.m new file mode 100644 index 000000000..02cc8b99b --- /dev/null +++ b/Tests/base/NSString/test07.m @@ -0,0 +1,30 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + double d; + + PASS([@"12" intValue] == 12, "simple intValue works"); + PASS([@"-12" intValue] == -12, "negative intValue works"); + PASS([@"+12" intValue] == 12, "positive intValue works"); + PASS([@"1.6" intValue] == 1, "intValue ignores trailing data"); + PASS([@" 12" intValue] == 12, + "intValue with leading space works"); + + d = [@"1.2" doubleValue]; + PASS(d > 1.199999 && d < 1.200001, "simple doubleValue works"); + d = [@"-1.2" doubleValue]; + PASS(d < -1.199999 && d > -1.200001, "negative doubleValue works"); + d = [@"+1.2" doubleValue]; + PASS(d > 1.199999 && d < 1.200001, "positive doubleValue works"); + d = [@"+1.2 x" doubleValue]; + PASS(d > 1.199999 && d < 1.200001, "doubleValue ignores trailing data"); + d = [@" 1.2" doubleValue]; + PASS(d > 1.199999 && d < 1.200001, "doubleValue with leading space works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSString/utf8bom.txt b/Tests/base/NSString/utf8bom.txt new file mode 100644 index 000000000..f67aa80d6 --- /dev/null +++ b/Tests/base/NSString/utf8bom.txt @@ -0,0 +1,3 @@ +This file contains a UTF-8 BOM: +EF BB BF +http://en.wikipedia.org/wiki/Byte_Order_Mark diff --git a/Tests/base/NSTask/GNUmakefile.preamble b/Tests/base/NSTask/GNUmakefile.preamble new file mode 100644 index 000000000..cc5508093 --- /dev/null +++ b/Tests/base/NSTask/GNUmakefile.preamble @@ -0,0 +1,5 @@ + +SUBPROJECTS = Helpers + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSTask/Helpers/GNUmakefile b/Tests/base/NSTask/Helpers/GNUmakefile new file mode 100644 index 000000000..a5abb1642 --- /dev/null +++ b/Tests/base/NSTask/Helpers/GNUmakefile @@ -0,0 +1,21 @@ + +include $(GNUSTEP_MAKEFILES)/common.make + +TOOL_NAME = NSZombie processgroup testcat testecho + +NSZombie_OBJC_FILES = NSZombie.m +NSZombie_NEEDS_GUI = NO + +processgroup_OBJC_FILES = processgroup.m +processgroup_NEEDS_GUI = NO + +testcat_OBJC_FILES = testcat.m +testcat_NEEDS_GUI = NO + +testecho_OBJC_FILES = testecho.m +testecho_NEEDS_GUI = NO + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/tool.make +-include GNUmakefile.postamble + diff --git a/Tests/base/NSTask/Helpers/NSZombie.m b/Tests/base/NSTask/Helpers/NSZombie.m new file mode 100644 index 000000000..70b185689 --- /dev/null +++ b/Tests/base/NSTask/Helpers/NSZombie.m @@ -0,0 +1,14 @@ +#import +#import + +int +main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSObject *anObject = [NSObject new]; + + [anObject release]; + [anObject release]; + [pool release]; + return 0; +} diff --git a/Tests/base/NSTask/Helpers/processgroup.m b/Tests/base/NSTask/Helpers/processgroup.m new file mode 100644 index 000000000..92886ac92 --- /dev/null +++ b/Tests/base/NSTask/Helpers/processgroup.m @@ -0,0 +1,37 @@ +#include +#if !defined(__MINGW32__) +#include +#include +#include +#endif + +/* Test that the process group has been changed (not the same as that of our + * parent) and that we have been detached from any controlling terminal. + */ +int +main(int argc, char **argv) +{ + int i = 0; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + +#if !defined(__MINGW32__) +/* + printf("argc %d\n", argc); + for (i = 0; i < argc; i++) + printf("argv[%d] %s\n", i, argv[i]); + printf("getpgrp %d\n", getpgrp()); + printf("getsid %d\n", getsid(0)); + printf("result of open of /dev/tty is %d\n", open("/dev/tty", O_WRONLY)); +*/ + if (atoi(argv[1]) == getpgrp()) + i = 1; /* pgrp not set properly */ + else if (open("/dev/tty", O_WRONLY) >= 0) + i = 2; /* not detached from tty */ + else + i = 0; /* OK */ +#endif /* __MINGW32__ */ + + [arp release]; + return i; +} + diff --git a/Tests/base/NSTask/Helpers/testcat.m b/Tests/base/NSTask/Helpers/testcat.m new file mode 100644 index 000000000..9e09231cd --- /dev/null +++ b/Tests/base/NSTask/Helpers/testcat.m @@ -0,0 +1,17 @@ +#include + +/* Just cat the GNUmakefle + */ +int +main(int argc, char **argv) +{ + FILE *f = fopen("GNUmakefile", "rb"); + int c; + + while ((c = fgetc(f)) != EOF) + putchar(c); + fclose(f); + fflush(stdout); + return 0; +} + diff --git a/Tests/base/NSTask/Helpers/testecho.m b/Tests/base/NSTask/Helpers/testecho.m new file mode 100644 index 000000000..06f0ab133 --- /dev/null +++ b/Tests/base/NSTask/Helpers/testecho.m @@ -0,0 +1,20 @@ +#import + +int +main(int argc, char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *args = [[NSProcessInfo processInfo] arguments]; + unsigned c = [args count]; + int i; + + for (i = 0; i < c; i++) + { + GSPrintf(stdout, @"%s%@", (i == 0 ? "" : " "), [args objectAtIndex: i]); + } + GSPrintf(stdout, @"\n"); + fflush(stdout); + [arp release]; + return 0; +} + diff --git a/Tests/base/NSTask/TestInfo b/Tests/base/NSTask/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSTask/basic.m b/Tests/base/NSTask/basic.m new file mode 100644 index 000000000..a0c2c0865 --- /dev/null +++ b/Tests/base/NSTask/basic.m @@ -0,0 +1,14 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *testObj = [NSTask new]; + + test_NSObject(@"NSTask", [NSArray arrayWithObject:testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSTask/general.m b/Tests/base/NSTask/general.m new file mode 100644 index 000000000..b91cfbe0e --- /dev/null +++ b/Tests/base/NSTask/general.m @@ -0,0 +1,55 @@ +#import +#import +#import +#import +#import +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSFileManager *mgr; + NSString *helpers; + NSArray *args; + id task; + id info; + id env; + id pth1; + id pth2; + BOOL yes; + + info = [NSProcessInfo processInfo]; + env = [[info environment] mutableCopy]; + yes = YES; + + PASS(info != nil && [info isKindOfClass: [NSProcessInfo class]] + && env != nil && [env isKindOfClass: [NSMutableDictionary class]] + && yes == YES, + "We can build some objects for task tests"); + + mgr = [NSFileManager defaultManager]; + helpers = [mgr currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + + pth1 = [helpers stringByAppendingPathComponent: @"testcat"]; + + /* Try some tasks. Make sure the program we use is common between Unix + and Windows (and others?) */ + task = [NSTask launchedTaskWithLaunchPath: pth1 + arguments: [NSArray array]]; + [task waitUntilExit]; + PASS(YES, "launchedTaskWithLaunchPath:arguments: works"); + + task = [NSTask new]; + args = [NSArray arrayWithObjects: @"xxx", @"yyy", nil]; + pth2 = [helpers stringByAppendingPathComponent: @"testecho"]; + [task setEnvironment: env]; + [task setLaunchPath: pth2]; + [task setArguments: args]; + [task launch]; + [task waitUntilExit]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSTask/launch.m b/Tests/base/NSTask/launch.m new file mode 100644 index 000000000..51415b357 --- /dev/null +++ b/Tests/base/NSTask/launch.m @@ -0,0 +1,75 @@ +#import +#import +#import +#import +#import + +#import "ObjectTesting.h" + +int main() +{ + NSTask *task; + NSPipe *outPipe; + NSFileManager *mgr; + NSString *helpers; + NSFileHandle *outHandle; + NSAutoreleasePool *arp; + NSData *data = nil; + + arp = [[NSAutoreleasePool alloc] init]; + + mgr = [NSFileManager defaultManager]; + helpers = [mgr currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + + task = [[NSTask alloc] init]; + outPipe = [[NSPipe pipe] retain]; + [task setLaunchPath: [helpers stringByAppendingPathComponent: @"testcat"]]; + [task setArguments: [NSArray arrayWithObjects: nil]]; + [task setStandardOutput: outPipe]; + outHandle = [outPipe fileHandleForReading]; + + [task launch]; + PASS([task standardOutput] == outPipe, "standardOutput returns pipe"); + data = [outHandle readDataToEndOfFile]; + PASS([data length] > 0, "was able to read data from subtask"); + NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]); + [task terminate]; + + task = [[NSTask alloc] init]; + outPipe = [[NSPipe pipe] retain]; + [task setLaunchPath: [helpers stringByAppendingPathComponent: @"testecho"]]; + [task setArguments: [NSArray arrayWithObjects: @"Hello", @"there", nil]]; + [task setStandardOutput: outPipe]; + outHandle = [outPipe fileHandleForReading]; + + [task launch]; + data = [outHandle readDataToEndOfFile]; + PASS([data length] > 0, "was able to read data from subtask"); + NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]); + [task terminate]; + + + PASS_EXCEPTION([task launch];, @"NSInvalidArgumentException", + "raised exception on failed launch") + [outPipe release]; + [task release]; + +#if !defined(__MINGW32__) + task = [[NSTask alloc] init]; + [task setLaunchPath: + [helpers stringByAppendingPathComponent: @"processgroup"]]; + [task setArguments: [NSArray arrayWithObjects: + [NSString stringWithFormat: @"%d", getpgrp()], + nil]]; + [task launch]; + [task waitUntilExit]; + PASS([task terminationStatus] == 0, "subtask changes process group"); + [task release]; +#endif + + [arp release]; + + return 0; +} diff --git a/Tests/base/NSTask/zombie.m b/Tests/base/NSTask/zombie.m new file mode 100644 index 000000000..fb88c2c5f --- /dev/null +++ b/Tests/base/NSTask/zombie.m @@ -0,0 +1,51 @@ +#import +#import +#import +#import +#import +#import + +#import "ObjectTesting.h" + +int main() +{ + NSTask *task; + NSPipe *outPipe; + NSFileManager *mgr; + NSString *helpers; + NSFileHandle *outHandle; + NSAutoreleasePool *arp; + NSMutableDictionary *env; + NSData *data = nil; + NSString *str; + + arp = [[NSAutoreleasePool alloc] init]; + + mgr = [NSFileManager defaultManager]; + helpers = [mgr currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + + env = [[[NSProcessInfo processInfo] environment] mutableCopy]; + [env setObject: @"YES" forKey: @"NSZombieEnabled"]; + task = [[NSTask alloc] init]; + outPipe = [[NSPipe pipe] retain]; + [task setLaunchPath: [helpers stringByAppendingPathComponent: @"NSZombie"]]; + [task setArguments: [NSArray arrayWithObjects: nil]]; + [task setStandardError: outPipe]; + [task setEnvironment: env]; + outHandle = [outPipe fileHandleForReading]; + + [task launch]; + data = [outHandle readDataToEndOfFile]; + NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]); + str = [[NSString alloc] initWithData: data + encoding: NSISOLatin1StringEncoding]; + PASS(str != nil && [str rangeOfString: @"sent to deallocated"].length > 0, + "was able to read zombie message from subtask"); + [task terminate]; + + [arp release]; + + return 0; +} diff --git a/Tests/base/NSTimeZone/TestInfo b/Tests/base/NSTimeZone/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSTimeZone/basic.m b/Tests/base/NSTimeZone/basic.m new file mode 100644 index 000000000..700bf1ea3 --- /dev/null +++ b/Tests/base/NSTimeZone/basic.m @@ -0,0 +1,14 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *testObj = [NSTimeZone defaultTimeZone]; + + test_NSObject(@"NSTimeZone", [NSArray arrayWithObject:testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSTimeZone/create.m b/Tests/base/NSTimeZone/create.m new file mode 100644 index 000000000..e88059fde --- /dev/null +++ b/Tests/base/NSTimeZone/create.m @@ -0,0 +1,41 @@ +#import "ObjectTesting.h" +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + id current; + id localh; + + current = [NSTimeZone defaultTimeZone]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]], + "+defaultTimeZone works"); + + current = [NSTimeZone localTimeZone]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]], + "+localTimeZone works"); + + current = [NSTimeZone systemTimeZone]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]], + "+systemTimeZone works"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: 900]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]], + "+timeZoneForSecondsFromGMT works"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: 90000]; + PASS(current == nil, + "+timeZoneForSecondsFromGMT fails for bad offset"); + + current = [NSTimeZone timeZoneWithAbbreviation: @"MST"]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]], + "+timeZoneWithAbbreviation works"); + + current = [NSTimeZone timeZoneWithName: @"GB"]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]], + "+timeZoneWithName works"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSTimeZone/use.m b/Tests/base/NSTimeZone/use.m new file mode 100644 index 000000000..7a94c945d --- /dev/null +++ b/Tests/base/NSTimeZone/use.m @@ -0,0 +1,99 @@ +#import "ObjectTesting.h" +#import + +#if defined(GS_USE_ICU) +#define NSLOCALE_SUPPORTED GS_USE_ICU +#else +#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */ +#endif + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSLocale *locale; + NSString *str; + NSDate *date; + id current; + id localh = [NSTimeZone defaultTimeZone]; + int offset = [localh secondsFromGMT]; + + current = [NSTimeZone timeZoneForSecondsFromGMT: 900]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]] + && [current secondsFromGMT] == 900, + "+timeZoneForSecondsFromGMT works"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: -45]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]] + && [current secondsFromGMT] == -60, + "+timeZoneForSecondsFromGMT rounds to minute"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: 7260]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]] + && [[current name] isEqual: @"GMT+0201"], + "+timeZoneForSecondsFromGMT has correct name"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: -3600]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]] + && [[current abbreviation] isEqual: @"GMT-0100"], + "+timeZoneForSecondsFromGMT has correct abbreviation"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: -3600]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]] + && [current isDaylightSavingTime] == NO, + "+timeZoneForSecondsFromGMT has DST NO"); + + current = [NSTimeZone timeZoneForSecondsFromGMT: offset]; + [NSTimeZone setDefaultTimeZone: current]; + current = [NSTimeZone localTimeZone]; + PASS(current != nil && [current isKindOfClass: [NSTimeZone class]] + && [current secondsFromGMT] == offset + && [current isDaylightSavingTime] == NO, + "can set default time zone"); + + START_SET("NSLocale") + if (!NSLOCALE_SUPPORTED) + SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built") + + current = [NSTimeZone timeZoneWithName: @"America/Sao_Paulo"]; + locale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_GB"]; + PASS_EQUAL( + [current localizedName: NSTimeZoneNameStyleStandard locale: locale], + @"Brasilia Time", + "Correctly localizes standard time zone name") + + /* The next few depend on ICU issues + */ + testHopeful = YES; + PASS_EQUAL( + [current localizedName: NSTimeZoneNameStyleShortStandard locale: locale], + @"GMT-03:00", + "Correctly localizes short time zone name") + PASS_EQUAL( + [current localizedName: NSTimeZoneNameStyleDaylightSaving locale: locale], + @"Brasilia Summer Time", + "Correctly localizes DST time zone name") + PASS_EQUAL( + [current localizedName: NSTimeZoneNameStyleShortDaylightSaving + locale: locale], + @"GMT-02:00", + "Correctly localizes short DST time zone name") + testHopeful = NO; + + RELEASE(locale); + + date = [NSDate dateWithTimeIntervalSince1970: 1.0]; + PASS ([current daylightSavingTimeOffsetForDate: date] == 0.0, + "Returns correct Daylight Saving offset.") + date = [NSDate dateWithTimeIntervalSince1970: 1297308214.0]; + PASS ([current daylightSavingTimeOffsetForDate: date] == 3600.0, + "Returns correct Daylight Saving offset.") + date = [NSDate date]; + PASS ([current daylightSavingTimeOffset] + == [current daylightSavingTimeOffsetForDate: date], + "Returns correct Daylight Saving offset.") + + END_SET("NSLocale") + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSURL/GNUmakefile.preamble b/Tests/base/NSURL/GNUmakefile.preamble new file mode 100644 index 000000000..21e23af95 --- /dev/null +++ b/Tests/base/NSURL/GNUmakefile.preamble @@ -0,0 +1,8 @@ + +SUBPROJECTS = Helpers + +include $(GNUSTEP_MAKEFILES)/aggregate.make + +after-clean:: + rm -f SimpleResponse.dat KAResponse.dat + diff --git a/Tests/base/NSURL/Helpers/GNUmakefile b/Tests/base/NSURL/Helpers/GNUmakefile new file mode 100644 index 000000000..3e77a0b44 --- /dev/null +++ b/Tests/base/NSURL/Helpers/GNUmakefile @@ -0,0 +1,18 @@ + +include $(GNUSTEP_MAKEFILES)/common.make + +TOOL_NAME = capture respond keepalive + +capture_OBJC_FILES = capture.m +capture_NEEDS_GUI = NO + +respond_OBJC_FILES = respond.m +respond_NEEDS_GUI = NO + +keepalive_OBJC_FILES = keepalive.m +keepalive_NEEDS_GUI = NO + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/tool.make +-include GNUmakefile.postamble + diff --git a/Tests/base/NSURL/Helpers/capture.m b/Tests/base/NSURL/Helpers/capture.m new file mode 100644 index 000000000..e4f5ca23b --- /dev/null +++ b/Tests/base/NSURL/Helpers/capture.m @@ -0,0 +1,191 @@ +#if GNUSTEP +#include + +@interface TestClass : NSObject +{ + NSOutputStream *op; + NSInputStream *ip; + NSMutableData *capture; + unsigned written; + BOOL readable; + BOOL writable; +} +- (int) runTest; +@end + +@implementation TestClass + +- (void) dealloc +{ + RELEASE(capture); + RELEASE(op); + RELEASE(ip); + [super dealloc]; +} + +- (id) init +{ + capture = [NSMutableData new]; + + return self; +} + +- (int) runTest +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + NSHost *host = [NSHost hostWithName: @"localhost"]; + NSStream *serverStream; + NSString *file; + int port = [[defs stringForKey: @"Port"] intValue]; + + if (port == 0) port = 54321; + + file = [defs stringForKey: @"FileName"]; + if (file == nil) file = @"Capture.dat"; + + serverStream = [GSServerStream serverStreamToAddr: [host address] port: port]; + if (serverStream == nil) + { + NSLog(@"Failed to create server stream"); + return 1; + } + [serverStream setDelegate: self]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [serverStream open]; + + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 30]]; + + if ([capture writeToFile: file atomically: YES] == NO) + { + NSLog(@"Unable to write captured data to '%@'", file); + return 1; + } + + return 0; +} + +- (void) stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + NSString *resp = @"HTTP/1.0 204 Empty success response\r\n\r\n"; + +// NSLog(@"Event %p %d", theStream, streamEvent); + + switch (streamEvent) + { + case NSStreamEventHasBytesAvailable: + { + if (ip == nil) + { + [(GSServerStream*)theStream acceptWithInputStream: &ip + outputStream: &op]; + if (ip) // it is ok to accept nothing + { + RETAIN(ip); + RETAIN(op); + [ip scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [op scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [ip setDelegate: self]; + [op setDelegate: self]; + [ip open]; + [op open]; + [theStream close]; + [theStream removeFromRunLoop: rl + forMode: NSDefaultRunLoopMode]; + } + } + if (theStream == ip) + { + readable = YES; + while (readable == YES) + { + unsigned char buffer[BUFSIZ]; + int readSize; + + readSize = [ip read: buffer maxLength: sizeof(buffer)]; + if (readSize <= 0) + { + readable = NO; + } + else + { + [capture appendBytes: buffer length: readSize]; + } + } + } + break; + } + case NSStreamEventHasSpaceAvailable: + { + NSData *data; + + NSAssert(theStream == op, @"Wrong stream for writing"); + writable = YES; + data = [resp dataUsingEncoding: NSASCIIStringEncoding]; + while (writable == YES && written < [data length]) + { + int result = [op write: [data bytes] + written + maxLength: [data length] - written]; + + if (result <= 0) + { + writable = NO; + } + else + { + written += result; + } + } + if (written == [data length]) + { + [op close]; + [op removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + } + break; + } + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + NSLog(@"Server close %p", theStream); + break; + } + + case NSStreamEventErrorOccurred: + { + int code = [[theStream streamError] code]; + + [theStream close]; + [theStream removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + NSAssert1(1, @"Error! code is %d", code); + break; + } + + default: + break; + } +} + +@end + +int +main(int argc, char **argv) +{ + int result; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + result = [[[[TestClass alloc] init] autorelease] runTest]; + + RELEASE(arp); + return result; +} + +#else + +int main() +{ + return 0; +} + +#endif diff --git a/Tests/base/NSURL/Helpers/keepalive.m b/Tests/base/NSURL/Helpers/keepalive.m new file mode 100644 index 000000000..1d667b543 --- /dev/null +++ b/Tests/base/NSURL/Helpers/keepalive.m @@ -0,0 +1,247 @@ +#if GNUSTEP +#include + +@interface TestClass : NSObject +{ + NSData *bodyData; + unsigned accum; + unsigned count; + unsigned closeFrequency; + NSArray *headers; + NSInputStream *inStream; + NSOutputStream *outStream; +} +- (int) runTest; +@end + +@implementation TestClass + +- (void)dealloc +{ + [headers release]; + [bodyData release]; + [inStream release]; + [outStream release]; + [super dealloc]; +} + +- (id) init +{ + return self; +} + +- (int)runTest +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + NSString *file, + *lengthHeader; + NSHost *host = [NSHost hostWithAddress: @"127.0.0.1"]; + NSStream *serverStream; + int port = [[defs stringForKey: @"Port"] intValue]; + int lifetime = [[defs stringForKey: @"Lifetime"] intValue]; + + if (0 == port) port = 4322; + if (0 == lifetime) lifetime = 30; + + accum = 0; + + closeFrequency = [[defs stringForKey: @"CloseFreq"] intValue]; + count = [[defs stringForKey: @"Count"] intValue]; + if (0 >= count) count=1; + + file = [defs stringForKey: @"FileName"]; + if (nil == file) file = @"ResponseBody.dat"; + bodyData = [[NSData alloc] initWithContentsOfFile: file]; + if (nil == bodyData) + { + NSLog(@"Unable to load data from '%@'",file); + return 1; + } + + lengthHeader = [NSString stringWithFormat: @"Content-Length: %d\r\n", + [bodyData length]]; + headers = [[NSArray alloc] initWithObjects: @"HTTP/1.1 200 OK\r\n", + @"Content-type: text/plain\r\n", + lengthHeader, + nil]; + serverStream = [GSServerStream serverStreamToAddr: [host address] port: port]; + if (nil == serverStream) + { + NSLog(@"Could not create server stream"); + return 1; + } + [serverStream setDelegate: self]; + [serverStream scheduleInRunLoop: runLoop forMode: NSDefaultRunLoopMode]; + [serverStream open]; + + // only run for a fixed time anyway + [runLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: lifetime]]; + + return 0; +} + +// delegate method for NSStream +- (void) stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + + switch (streamEvent) + { + case NSStreamEventHasBytesAvailable: + { + if (theStream != inStream) + { + if (inStream != nil) + { + [inStream close]; + [inStream removeFromRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + inStream = nil; + } + if (outStream != nil) + { + [outStream close]; + [outStream removeFromRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + outStream = nil; + } + if (accum == count) + { + [theStream close]; + [theStream removeFromRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + break; + } + [(GSServerStream*)theStream acceptWithInputStream: &inStream + outputStream: &outStream]; + if (inStream) + { + RETAIN(inStream); + RETAIN(outStream); + [inStream scheduleInRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + [inStream setDelegate: self]; + [inStream open]; + } + else + { + NSLog(@"Accept returned nothing"); + } + } + else + { + unsigned char buffer[BUFSIZ]; + int readSize; + readSize = [inStream read: buffer maxLength: BUFSIZ]; + // make outStream available for writing + [outStream scheduleInRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + [outStream setDelegate: self]; + [outStream open]; + } + break; + } + + case NSStreamEventHasSpaceAvailable: + { + NSAssert(theStream == outStream, @"Wrong stream for writing"); + NSMutableData *payload = [[[NSMutableData alloc] init] autorelease]; + NSMutableArray *headerArray = [[headers mutableCopy] autorelease]; + NSEnumerator *headerEnumeration; + id header; + BOOL closeConnection = NO; + int written; + + accum++; + if ((0 != closeFrequency) && (0 == accum % closeFrequency)) + { + closeConnection = YES; + [headerArray addObject: @"Connection: close\r\n"]; + } + + headerEnumeration = [headerArray objectEnumerator]; + + while ((header = [headerEnumeration nextObject])) + [payload appendData: [header dataUsingEncoding: NSASCIIStringEncoding]]; + [payload appendData: [@"\n" dataUsingEncoding: NSASCIIStringEncoding]]; + [payload appendData: bodyData]; + + // provide the reply + written = [outStream write: [payload bytes] maxLength: [payload length]]; + if (written <=0) + { + // something seriously wrong.... + closeConnection = YES; + NSLog(@"Unable to write the payload!"); + } + + // remove from runloop, so we have to wait for another request + [outStream removeFromRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + + if (closeConnection) + { + [outStream close]; + outStream = nil; + + if (nil != inStream) + { + [inStream close]; + [inStream removeFromRunLoop: runLoop + forMode: NSDefaultRunLoopMode]; + inStream = nil; + } + } + break; + } + + case NSStreamEventEndEncountered: + { + NSAssert(inStream == theStream || outStream == theStream, + NSInternalInconsistencyException); + [theStream close]; + [theStream removeFromRunLoop: runLoop forMode: NSDefaultRunLoopMode]; + if (theStream == inStream) inStream = nil; + if (theStream == outStream) outStream = nil; + break; + } + + case NSStreamEventErrorOccurred: + { + int code = [[theStream streamError] code]; + NSLog(@"Received error %d on stream %p", code, theStream); + [theStream close]; + [theStream removeFromRunLoop: runLoop forMode: NSDefaultRunLoopMode]; + if (theStream == inStream) inStream = nil; + if (theStream == outStream) outStream = nil; + break; + } + + case NSStreamEventOpenCompleted: + break; + default: + NSLog(@"Unknown event %d on stream %p", streamEvent, theStream); + break; + } +} + +@end + +int main(int argc, char **argv) +{ + int result; + NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; + + result = [[[[TestClass alloc] init] autorelease] runTest]; + + [arp release]; + return result; +} +#else +int main() +{ + return 0; +} +#endif + diff --git a/Tests/base/NSURL/Helpers/respond.m b/Tests/base/NSURL/Helpers/respond.m new file mode 100644 index 000000000..1bd3dfdaa --- /dev/null +++ b/Tests/base/NSURL/Helpers/respond.m @@ -0,0 +1,278 @@ +#if GNUSTEP +#include + +@interface TestClass : NSObject +{ + NSOutputStream *op; + NSInputStream *ip; + NSData *content; + unsigned written; + BOOL readable; + BOOL writable; + unsigned writeLen; + unsigned count; + double pause; +} +- (int) runTest; +@end + +@implementation TestClass + +- (void) dealloc +{ + RELEASE(content); + RELEASE(op); + RELEASE(ip); + [super dealloc]; +} + +- (id) init +{ + return self; +} + +- (int) runTest +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + NSHost *host = [NSHost hostWithName: @"localhost"]; + NSStream *serverStream; + NSString *file; + int port = [[defs stringForKey: @"Port"] intValue]; + + if (port == 0) port = 54321; + + count = [[defs stringForKey: @"Count"] intValue]; + if (count <= 0) count = 1; + + pause = [defs floatForKey: @"Pause"]; + + file = [defs stringForKey: @"FileName"]; + if (file == nil) file = @"Respond.dat"; + content = [[NSData alloc] initWithContentsOfFile: file]; + if (content == nil) + { + NSLog(@"Unable to load data from '%@'", file); + return 1; + } + + if ([defs boolForKey: @"Shrink"] == YES) + { + writeLen = [content length]; + } + else + { + writeLen = 0; + } + + serverStream = [GSServerStream serverStreamToAddr: [host address] port: port]; + if (serverStream == nil) + { + NSLog(@"Failed to create server stream"); + return 1; + } + [serverStream setDelegate: self]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [serverStream open]; + + /* Run for up to 5 minutes to allow slow/large tests to complete. + */ + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 300]]; + + return 0; +} + +- (void) stream: (NSStream *)theStream handleEvent: (NSStreamEvent)streamEvent +{ + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + +NSLog(@"Server %p %d", theStream, streamEvent); + switch (streamEvent) + { + case NSStreamEventHasBytesAvailable: + { + if (theStream != ip) + { + if (ip != nil) + { + [ip close]; + [ip removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + ip = nil; + } + if (op != nil) + { + [op close]; + [op removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + op = nil; + } + [(GSServerStream*)theStream acceptWithInputStream: &ip + outputStream: &op]; + if (ip) // it is ok to accept nothing + { + written = 0; // Nothing written yet on this connection. + RETAIN(ip); + RETAIN(op); + [ip scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [op scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [ip setDelegate: self]; + [op setDelegate: self]; + [ip open]; + [op open]; + NSLog(@"Accept %d", count); + if (count > 0) + { + count--; + } + if (count == 0) + { + /* + * Handled enough requests ... close down + */ + [theStream close]; + [theStream removeFromRunLoop: rl + forMode: NSDefaultRunLoopMode]; + } + if (writeLen > 0 && [[NSUserDefaults standardUserDefaults] + boolForKey: @"Shrink"] == YES) + { + /* Want to write in slightly smaller chunks for each + * connection so that the remote end can check that + * it handles different chunk sizes properly. + */ + writeLen--; + } + } + else + { + NSLog(@"Accept returned nothing"); + } + } + else if (theStream == ip) + { + readable = YES; + while (readable == YES) + { + unsigned char buffer[BUFSIZ]; + int readSize; + + readSize = [ip read: buffer maxLength: sizeof(buffer)]; + if (readSize <= 0) + { + readable = NO; + } + } + } + break; + } + case NSStreamEventHasSpaceAvailable: + { + NSAssert(theStream == op, @"Wrong stream for writing"); + writable = YES; + while (writable == YES && written < [content length]) + { + int length = [content length] - written; + + /* If we have a write length limit set, don't try to write + * more than that in one chunk. + */ + if (writeLen > 0 && length > writeLen) + { + length = writeLen; + } + + /* We now pause for the time (in sec) specified. Even if + * the time is zero or less we still have a small pause, to try to + * coerce the OS into separating the write events. + */ + if (pause <= 0) + { + [NSThread sleepUntilDate: + [NSDate dateWithTimeIntervalSinceNow: 0.00001]]; + } + else + { + [NSThread sleepUntilDate: + [NSDate dateWithTimeIntervalSinceNow: pause]]; + } + + length = [op write: [content bytes] + written maxLength: length]; + if (length <= 0) + { + writable = NO; + } + else + { + written += length; + } + } + if (written == [content length]) + { + [op close]; + [op removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + op = nil; + if (ip != nil) + { + [ip close]; + [ip removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + ip = nil; + NSLog(@"Done reading %d", count+1); + } + NSLog(@"Done writing %d", count+1); + } + break; + } + case NSStreamEventEndEncountered: + { + NSAssert(ip == theStream || op == theStream, + NSInternalInconsistencyException); + [theStream close]; + [theStream removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + if (theStream == ip) ip = nil; + if (theStream == op) op = nil; + NSLog(@"Server close %p", theStream); + break; + } + + case NSStreamEventErrorOccurred: + { + int code = [[theStream streamError] code]; + + NSLog(@"Error on %p code is %d", theStream, code); + [theStream close]; + [theStream removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + if (theStream == ip) ip = nil; + if (theStream == op) op = nil; + break; + } + + case NSStreamEventOpenCompleted: + break; + + default: + NSLog(@"Unexpected event %d on %p", streamEvent, theStream); + break; + } +} + +@end + +int +main(int argc, char **argv) +{ + int result; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + result = [[[[TestClass alloc] init] autorelease] runTest]; + + RELEASE(arp); + return result; +} + +#else + +int main() +{ + return 0; +} + +#endif diff --git a/Tests/base/NSURL/TestInfo b/Tests/base/NSURL/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSURL/basic.m b/Tests/base/NSURL/basic.m new file mode 100644 index 000000000..5355b5cdb --- /dev/null +++ b/Tests/base/NSURL/basic.m @@ -0,0 +1,271 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +#if GNUSTEP +extern const char *GSPathHandling(const char *); +#endif + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSURL *url; + NSURL *rel; + NSData *data; + NSString *str; + NSNumber *num; + unsigned i; + unichar u = 163; + unichar buf[256]; + + TEST_FOR_CLASS(@"NSURL", [NSURL alloc], + "NSURL +alloc returns an NSURL"); + + TEST_FOR_CLASS(@"NSURL", [NSURL fileURLWithPath: @"."], + "NSURL +fileURLWithPath: returns an NSURL"); + + TEST_FOR_CLASS(@"NSURL", [NSURL URLWithString: @"http://www.w3.org/"], + "NSURL +URLWithString: returns an NSURL"); + + str = [NSString stringWithCharacters: &u length: 1]; + url = [NSURL fileURLWithPath: str]; + str = [[[NSFileManager defaultManager] currentDirectoryPath] + stringByAppendingPathComponent: str]; + PASS([[url path] isEqual: str], "Can put a pound sign in a file URL"); + + str = [url scheme]; + PASS([str isEqual: @"file"], "Scheme of file URL is file"); + + url = [NSURL URLWithString: @"http://www.w3.org/"]; + data = [url resourceDataUsingCache: NO]; + PASS(data != nil, + "Can load a page from www.w3.org"); + num = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; + PASS([num isKindOfClass: [NSNumber class]] && [num intValue] == 200, + "Status of load is 200 for www.w3.org"); + + url = [NSURL URLWithString:@"this isn't a URL"]; + PASS(url == nil, "URL with 'this isn't a URL' returns nil"); + + url = [NSURL URLWithString: @"http://www.w3.org/silly-file-name"]; + data = [url resourceDataUsingCache: NO]; + num = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; + PASS([num isKindOfClass: [NSNumber class]] && [num intValue] == 404, + "Status of load is 404 for www.w3.org/silly-file-name"); + + str = [url scheme]; + PASS([str isEqual: @"http"], + "Scheme of http://www.w3.org/silly-file-name is http"); + str = [url host]; + PASS([str isEqual: @"www.w3.org"], + "Host of http://www.w3.org/silly-file-name is www.w3.org"); + str = [url path]; + PASS([str isEqual: @"/silly-file-name"], + "Path of http://www.w3.org/silly-file-name is /silly-file-name"); + PASS([[url resourceSpecifier] isEqual: @"//www.w3.org/silly-file-name"], + "resourceSpecifier of http://www.w3.org/silly-file-name is //www.w3.org/silly-file-name"); + + + url = [NSURL URLWithString: @"http://www.w3.org/silly-file-path/"]; + str = [url path]; + PASS([str isEqual: @"/silly-file-path"], + "Path of http://www.w3.org/silly-file-path/ is /silly-file-path"); + PASS([[url resourceSpecifier] isEqual: @"//www.w3.org/silly-file-path/"], + "resourceSpecifier of http://www.w3.org/silly-file-path/ is //www.w3.org/silly-file-path/"); + + str = [url absoluteString]; + PASS([str isEqual: @"http://www.w3.org/silly-file-path/"], + "Abs of http://www.w3.org/silly-file-path/ is correct"); + +#if defined(__MINGW32__) + url = [NSURL fileURLWithPath: @"C:\\WINDOWS"]; + str = [url path]; + PASS_EQUAL(str, @"C:\\WINDOWS", + "Path of file URL C:\\WINDOWS is C:\\WINDOWS"); + PASS_EQUAL([url description], @"file://localhost/C:%5CWINDOWS/", + "File URL C:\\WINDOWS is file://localhost/C:%%5CWINDOWS/"); + PASS_EQUAL([url resourceSpecifier], @"//localhost/C:%5CWINDOWS/", + "resourceSpecifier of C:\\WINDOWS is //localhost/C:%%5CWINDOWS/"); +#else + url = [NSURL fileURLWithPath: @"/usr"]; + str = [url path]; + PASS_EQUAL(str, @"/usr", "Path of file URL /usr is /usr"); + PASS_EQUAL([url description], @"file://localhost/usr/", + "File URL /usr is file://localhost/usr/"); + PASS_EQUAL([url resourceSpecifier], @"//localhost/usr/", + "resourceSpecifier of /usr is //localhost/usr/"); +#endif + + url = [NSURL URLWithString: @"file:///usr"]; + PASS_EQUAL([url resourceSpecifier], @"/usr", + "resourceSpecifier of file:///usr is /usr"); + + url = [NSURL URLWithString: @"http://here.and.there/testing/one.html"]; + rel = [NSURL URLWithString: @"aaa/bbb/ccc/" relativeToURL: url]; + PASS_EQUAL([rel absoluteString], + @"http://here.and.there/testing/aaa/bbb/ccc/", + "Simple relative URL absoluteString works"); + PASS_EQUAL([rel path], @"/testing/aaa/bbb/ccc", + "Simple relative URL path works"); +#if GNUSTEP + PASS_EQUAL([rel fullPath], @"/testing/aaa/bbb/ccc/", + "Simple relative URL fullPath works"); +#endif + + url = [NSURL URLWithString: @"http://here.and.there/testing/one.html"]; + rel = [NSURL URLWithString: @"/aaa/bbb/ccc/" relativeToURL: url]; + PASS([[rel absoluteString] + isEqual: @"http://here.and.there/aaa/bbb/ccc/"], + "Root relative URL absoluteString works"); + PASS([[rel path] + isEqual: @"/aaa/bbb/ccc"], + "Root relative URL path works"); +#if GNUSTEP + PASS([[rel fullPath] + isEqual: @"/aaa/bbb/ccc/"], + "Root relative URL fullPath works"); +#endif + + url = [NSURL URLWithString: @"/aaa/bbb/ccc/"]; + PASS([[url absoluteString] isEqual: @"/aaa/bbb/ccc/"], + "absolute root URL absoluteString works"); + PASS([[url path] isEqual: @"/aaa/bbb/ccc"], + "absolute root URL path works"); +#if GNUSTEP + PASS([[url fullPath] isEqual: @"/aaa/bbb/ccc/"], + "absolute root URL fullPath works"); +#endif + + url = [NSURL URLWithString: @"aaa/bbb/ccc/"]; + PASS([[url absoluteString] isEqual: @"aaa/bbb/ccc/"], + "absolute URL absoluteString works"); + PASS([[url path] isEqual: @"aaa/bbb/ccc"], + "absolute URL path works"); +#if GNUSTEP + PASS([[url fullPath] isEqual: @"aaa/bbb/ccc/"], + "absolute URL fullPath works"); +#endif + + url = [NSURL URLWithString: @"http://127.0.0.1/"]; + PASS([[url absoluteString] isEqual: @"http://127.0.0.1/"], + "absolute http URL absoluteString works"); + PASS([[url path] isEqual: @"/"], + "absolute http URL path works"); +#if GNUSTEP + PASS([[url fullPath] isEqual: @"/"], + "absolute http URL fullPath works"); +#endif + + url = [NSURL URLWithString: @"http://127.0.0.1/ hello"]; + PASS(url == nil, "space is illegal"); + + url = [NSURL URLWithString: @""]; + PASS([[url absoluteString] isEqual: @""], + "empty string gives empty URL"); + PASS([url path] == nil, + "empty string gives nil path"); + PASS([url scheme] == nil, + "empty string gives nil scheme"); + + url = [NSURL URLWithString: @"aaa%20ccc/"]; + PASS([[url absoluteString] isEqual: @"aaa%20ccc/"], + "absolute URL absoluteString works with encoded space"); + PASS([[url path] isEqual: @"aaa ccc"], + "absolute URL path decodes space"); + + url = [NSURL URLWithString: @"/?aaa%20ccc"]; + PASS([[url query] isEqual: @"aaa%20ccc"], + "escapes are not decoded in query"); + + url = [NSURL URLWithString: @"/#aaa%20ccc"]; + PASS([[url fragment] isEqual: @"aaa%20ccc"], + "escapes are not decoded in fragment"); + + url = [NSURL URLWithString: @"/tmp/xxx"]; + PASS([[url path] isEqual: @"/tmp/xxx"] && [url scheme] == nil, + "a simple path becomes a simple URL"); + + url = [NSURL URLWithString: @"filename"]; + PASS([[url path] isEqual: @"filename"] && [url scheme] == nil, + "a simple file name becomes a simple URL"); + + url = [NSURL URLWithString: @"file://localhost/System/Library/" + @"Documentation/Developer/Gui/Reference/index.html"]; + + str = @"NSApplication.html"; + rel = [NSURL URLWithString: str relativeToURL: url]; +//NSLog(@"with link %@, obtained URL: %@ String: %@", str, rel, [rel absoluteString]); + PASS([[rel absoluteString] isEqual: @"file://localhost/System/Library/Documentation/Developer/Gui/Reference/NSApplication.html"], "Adding a relative file URL works"); + str = @"NSApplication.html#class$NSApplication"; + rel = [NSURL URLWithString: str relativeToURL: url]; +//NSLog(@"with link %@, obtained URL: %@ String: %@", str, rel, [rel absoluteString]); + PASS([[rel absoluteString] isEqual: @"file://localhost/System/Library/Documentation/Developer/Gui/Reference/NSApplication.html#class$NSApplication"], "Adding relative file URL with fragment works"); + +#if defined(__MINGW32__) +GSPathHandling("unix"); +#endif + + buf[0] = '/'; + for (i = 1; i < 256; i++) + { + buf[i] = i; + } + str = [NSString stringWithCharacters: buf length: 256]; + url = [NSURL fileURLWithPath: str]; + NSLog(@"path quoting %@", [url absoluteString]); + PASS_EQUAL([url absoluteString], + @"file://localhost/%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22%23$%25&'()*+,-./0123456789:%3B%3C=%3E%3F@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F%C2%80%C2%81%C2%82%C2%83%C2%84%C2%85%C2%86%C2%87%C2%88%C2%89%C2%8A%C2%8B%C2%8C%C2%8D%C2%8E%C2%8F%C2%90%C2%91%C2%92%C2%93%C2%94%C2%95%C2%96%C2%97%C2%98%C2%99%C2%9A%C2%9B%C2%9C%C2%9D%C2%9E%C2%9F%C2%A0%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD%C2%AE%C2%AF%C2%B0%C2%B1%C2%B2%C2%B3%C2%B4%C2%B5%C2%B6%C2%B7%C2%B8%C2%B9%C2%BA%C2%BB%C2%BC%C2%BD%C2%BE%C2%BF%C3%80%C3%81%C3%82%C3%83%C3%84%C3%85%C3%86%C3%87%C3%88%C3%89%C3%8A%C3%8B%C3%8C%C3%8D%C3%8E%C3%8F%C3%90%C3%91%C3%92%C3%93%C3%94%C3%95%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%9B%C3%9C%C3%9D%C3%9E%C3%9F%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%A8%C3%A9%C3%AA%C3%AB%C3%AC%C3%AD%C3%AE%C3%AF%C3%B0%C3%B1%C3%B2%C3%B3%C3%B4%C3%B5%C3%B6%C3%B7%C3%B8%C3%B9%C3%BA%C3%BB%C3%BC%C3%BD%C3%BE%C3%BF", "path quoting"); + + /* Test +fileURLWithPath: for messy/complex path + */ + url = [NSURL fileURLWithPath: @"/this#is a Path with % + = & < > ?"]; + PASS_EQUAL([url path], @"/this#is a Path with % + = & < > ?", + "complex -path"); + PASS_EQUAL([url fragment], nil, "complex -fragment"); + PASS_EQUAL([url parameterString], nil, "complex -parameterString"); + PASS_EQUAL([url query], nil, "complex -query"); + PASS_EQUAL([url absoluteString], @"file://localhost/this%23is%20a%20Path%20with%20%25%20+%20=%20&%20%3C%20%3E%20%3F", "complex -absoluteString"); + PASS_EQUAL([url relativeString], @"file://localhost/this%23is%20a%20Path%20with%20%25%20+%20=%20&%20%3C%20%3E%20%3F", "complex -relativeString"); + PASS_EQUAL([url description], @"file://localhost/this%23is%20a%20Path%20with%20%25%20+%20=%20&%20%3C%20%3E%20%3F", "complex -description"); + +#if defined(__MINGW32__) +GSPathHandling("right"); +#endif + + /* Test +URLWithString: for file URL with a messy/complex path + */ + url = [NSURL URLWithString: @"file:///pathtofile;parameters?query#anchor"]; + PASS(nil == [url host], "host"); + PASS(nil == [url user], "user"); + PASS(nil == [url password], "password"); + PASS([@"/pathtofile;parameters?query#anchor" + isEqual: [url resourceSpecifier]], "resourceSpecifier"); + PASS([@"/pathtofile" isEqual: [url path]], "path"); + PASS([@"query" isEqual: [url query]], "query"); + PASS([@"parameters" isEqual: [url parameterString]], "parameterString"); + PASS([@"anchor" isEqual: [url fragment]], "fragment"); + PASS([@"file:///pathtofile;parameters?query#anchor" + isEqual: [url absoluteString]], "absoluteString"); + PASS([@"/pathtofile" isEqual: [url relativePath]], "relativePath"); + PASS([@"file:///pathtofile;parameters?query#anchor" + isEqual: [url description]], "description"); + + url = [NSURL URLWithString: @"file:///pathtofile; parameters? query #anchor"]; // can't initialize with spaces (must be %20) + PASS(nil == url, "url with spaces"); + url = [NSURL URLWithString: @"file:///pathtofile;%20parameters?%20query%20#anchor"]; + PASS(nil != url, "url without spaces"); + + str = [[NSFileManager defaultManager] currentDirectoryPath]; + str = [str stringByAppendingPathComponent: @"basic.m"]; + url = [NSURL fileURLWithPath: str]; + PASS([url resourceDataUsingCache: NO] != nil, "can load file URL"); + str = [str stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; + str = [NSString stringWithFormat: @"file://localhost/%@#anchor", str]; + url = [NSURL URLWithString: str]; + PASS([url resourceDataUsingCache: NO] != nil, + "can load file URL with anchor"); + + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSURL/test00.m b/Tests/base/NSURL/test00.m new file mode 100644 index 000000000..27997fb03 --- /dev/null +++ b/Tests/base/NSURL/test00.m @@ -0,0 +1,136 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + + +int main() +{ +#if GNUSTEP + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + unsigned i, j; + NSURL *url; + NSURL *u; + NSData *data; + NSMutableData *resp; + NSData *cont; + NSString *str; + NSMutableString *m; + NSTask *t; + NSString *helpers; + NSString *capture; + NSString *respond; + + helpers = [[NSFileManager defaultManager] currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + capture = [helpers stringByAppendingPathComponent: @"capture"]; + respond = [helpers stringByAppendingPathComponent: @"respond"]; + + url = [NSURL URLWithString: @"http://localhost:54321/"]; + + /* Ask the 'respond' helper to send back a response containing + * 'hello' and to shrink the write buffer size it uses on each + * request. We do as many requests as the total response size + * so that on the last one, the 'respond' program writes data + * a byte at a time. + * This tests that the URL loading code can handle a request + * that arrives fragmented rather than in a single read. + */ + m = [NSMutableString stringWithCapacity: 2048]; + for (i = 0; i < 128; i++) + { + [m appendFormat: @"Hello %d\r\n", i]; + } + cont = [m dataUsingEncoding: NSASCIIStringEncoding]; + resp = AUTORELEASE([[@"HTTP/1.0 200\r\n\r\n" + dataUsingEncoding: NSASCIIStringEncoding] mutableCopy]); + [resp appendData: cont]; + [resp writeToFile: @"SimpleResponse.dat" atomically: YES]; + + str = [NSString stringWithFormat: @"%u", [resp length]]; + t = [NSTask launchedTaskWithLaunchPath: respond + arguments: [NSArray arrayWithObjects: + @"-FileName", @"SimpleResponse.dat", + @"-Shrink", @"YES", + @"-Count", str, + nil]]; + if (t != nil) + { + // Pause to allow server subtask to set up. + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; + i = [resp length]; + while (i-- > 0) + { + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + char buf[128]; + + /* Just to test caching of url handles, we use eighteen + * different URLs (we know the cache size is 16) to ensure + * that loads work when handles are flushed from the cache. + */ + u = [NSURL URLWithString: [NSString stringWithFormat: + @"http://localhost:54321/%d", i % 18]]; + // Talk to server. + data = [u resourceDataUsingCache: NO]; + // Get status code + str = [u propertyForKey: NSHTTPPropertyStatusCodeKey]; + sprintf(buf, "respond test %d OK", i); + PASS([data isEqual: cont], "%s", buf) + [pool release]; + } + // Wait for server termination + [t terminate]; + [t waitUntilExit]; + } + + /* Now build a response which pretends to be an HTTP1.1 server and should + * support connection keepalive ... so we can test that the keeplive code + * correctly handles the case where the remote end drops the connection. + */ + cont = [@"hello" dataUsingEncoding: NSASCIIStringEncoding]; + resp = AUTORELEASE([[@"HTTP/1.1 200\r\nContent-Length: 5\r\n\r\n" + dataUsingEncoding: NSASCIIStringEncoding] mutableCopy]); + [resp appendData: cont]; + [resp writeToFile: @"SimpleResponse.dat" atomically: YES]; + + str = [NSString stringWithFormat: @"%u", [resp length]]; + + for (j = 0; j < 13 ; j += 4) + { + NSString *delay = [NSString stringWithFormat: @"%u", j]; + + t = [NSTask launchedTaskWithLaunchPath: respond + arguments: [NSArray arrayWithObjects: + @"-FileName", @"SimpleResponse.dat", + @"-Count", @"2", @"-Pause", delay, + nil]]; + if (t != nil) + { + // Pause to allow server subtask to set up. + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]]; + for (i = 0; i < 2; i++) + { + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + char buf[128]; + + // Talk to server. + data = [url resourceDataUsingCache: NO]; + // Get status code + str = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; + sprintf(buf, "respond with keepalive %d (pause %d) OK", i, j); + PASS([data isEqual: cont], "%s", buf) + [pool release]; + /* Allow remote end time to close socket. + */ + [NSThread sleepUntilDate: + [NSDate dateWithTimeIntervalSinceNow: 0.1]]; + } + /* Kill helper task and wait for it to finish */ + [t terminate]; + [t waitUntilExit]; + } + } + [arp release]; arp = nil; +#endif + return 0; +} diff --git a/Tests/base/NSURL/test01.m b/Tests/base/NSURL/test01.m new file mode 100644 index 000000000..7b1a85a3e --- /dev/null +++ b/Tests/base/NSURL/test01.m @@ -0,0 +1,65 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + + +int main() +{ +#if GNUSTEP + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + unsigned i; + NSURL *url; + NSData *data; + NSData *resp; + NSString *str; + NSMutableString *m; + NSTask *t; + NSString *helpers; + NSString *keepalive; + + helpers = [[NSFileManager defaultManager] currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + keepalive = [helpers stringByAppendingPathComponent: @"keepalive"]; + + url = [NSURL URLWithString: @"http://localhost:4322/"]; + + m = [NSMutableString stringWithCapacity: 2048]; + for (i = 0; i < 128; i++) + { + [m appendFormat: @"Hello %d\r\n", i]; + } + resp = [m dataUsingEncoding: NSASCIIStringEncoding]; + [resp writeToFile: @"KAResponse.dat" atomically: YES]; + + t = [NSTask launchedTaskWithLaunchPath: keepalive + arguments: [NSArray arrayWithObjects: + @"-FileName", @"KAResponse.dat", + @"-CloseFreq", @"3", + @"-Count", @"10", + nil]]; + if (t != nil) + { + // Pause to allow server subtask to set up. + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; + + for (i = 0; i < 10; i++) + { + /*we just get the response every time. It should be the + *same every time, even though the headers change and + *sometimes the connection gets dropped + */ + char buf[BUFSIZ]; + data = [url resourceDataUsingCache: NO]; + str = [url propertyForKey: NSHTTPPropertyStatusCodeKey]; + sprintf(buf, "keep-alive test %d OK",i); + PASS([data isEqual:resp], "%s", buf) + } + [t terminate]; + [t waitUntilExit]; + } + + [arp release]; arp = nil; +#endif + return 0; +} diff --git a/Tests/base/NSURLConnection/TestInfo b/Tests/base/NSURLConnection/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSURLConnection/basic.m b/Tests/base/NSURLConnection/basic.m new file mode 100644 index 000000000..aea78b2e4 --- /dev/null +++ b/Tests/base/NSURLConnection/basic.m @@ -0,0 +1,50 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableURLRequest *mutable; + NSURLConnection *connection; + NSURLResponse *response; + NSError *error; + NSData *data; + NSURL *httpURL; + NSString *path; + + httpURL = [NSURL URLWithString: @"http://www.gnustep.org"]; + + TEST_FOR_CLASS(@"NSURLConnection", [NSURLConnection alloc], + "NSURLConnection +alloc returns an NSURLConnection"); + + mutable = [NSMutableURLRequest requestWithURL: httpURL]; + PASS([NSURLConnection canHandleRequest: mutable], + "NSURLConnection can handle an valid HTTP request (GET)"); + [mutable setHTTPMethod: @"WRONGMETHOD"]; + PASS([NSURLConnection canHandleRequest: mutable], + "NSURLConnection can handle an invalid HTTP request (WRONGMETHOD)"); + + [mutable setHTTPMethod: @"GET"]; + connection = [NSURLConnection connectionWithRequest: mutable delegate: nil]; + PASS(connection != nil, + "NSURLConnection +connectionWithRequest: delegate: with nil as delegate returns a instance"); + + data = [NSURLConnection sendSynchronousRequest: mutable + returningResponse: &response + error: &error]; + PASS(data != nil && [data length] > 0, + "NSURLConnection synchronously load data from an http URL"); + + path = [[NSFileManager defaultManager] currentDirectoryPath]; + path = [path stringByAppendingPathComponent: @"basic.m"]; + [mutable setURL: [NSURL fileURLWithPath: path]]; + data = [NSURLConnection sendSynchronousRequest: mutable + returningResponse: &response + error: &error]; + PASS(data != nil && [data length] > 0, + "NSURLConnection synchronously load data from a local file"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSURLHandle/GNUmakefile.preamble b/Tests/base/NSURLHandle/GNUmakefile.preamble new file mode 100644 index 000000000..cc5508093 --- /dev/null +++ b/Tests/base/NSURLHandle/GNUmakefile.preamble @@ -0,0 +1,5 @@ + +SUBPROJECTS = Helpers + +include $(GNUSTEP_MAKEFILES)/aggregate.make + diff --git a/Tests/base/NSURLHandle/Helpers/GNUmakefile b/Tests/base/NSURLHandle/Helpers/GNUmakefile new file mode 100644 index 000000000..02297adf5 --- /dev/null +++ b/Tests/base/NSURLHandle/Helpers/GNUmakefile @@ -0,0 +1,12 @@ + +include $(GNUSTEP_MAKEFILES)/common.make + +TOOL_NAME = StatusServer + +StatusServer_OBJC_FILES = StatusServer.m +StatusServer_NEEDS_GUI = NO + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/tool.make +-include GNUmakefile.postamble + diff --git a/Tests/base/NSURLHandle/Helpers/StatusServer.m b/Tests/base/NSURLHandle/Helpers/StatusServer.m new file mode 100644 index 000000000..c16bf1431 --- /dev/null +++ b/Tests/base/NSURLHandle/Helpers/StatusServer.m @@ -0,0 +1,374 @@ +#import + +#if GNUSTEP + +#define PORT_LISTEN 54321 +#define LOCATION200 @"http://localhost:54321/200" + +@interface StatusServer : NSObject +{ + NSInputStream *ip; + NSOutputStream *op; + NSDictionary *responses; + NSDictionary *headers; + NSDictionary *commonHeaders; + NSString *body; + NSMutableData *request; +} + +- (int) runTest; + +@end + +@implementation StatusServer + +- (id)init +{ + if ((self = [super init])) + { + body = @"Hello\r\n"; + unsigned bodyLength = [body length]; + NSString *bl = [[NSNumber numberWithInt: bodyLength] + stringValue]; + NSString *date = [[NSCalendarDate date] description]; + // set up the dictionaries of responses and headers + + commonHeaders = [NSDictionary dictionaryWithObjectsAndKeys: + @"close", @"Connection", + @"GNUstep test harness", @"Server", + @"text/plain", @"Content-Type", + date, @"Date", + nil]; + [commonHeaders retain]; + + responses = [NSDictionary dictionaryWithObjectsAndKeys: + @"HTTP/1.1 200 OK", @"200", + @"HTTP/1.1 201 Created", @"201", + @"HTTP/1.1 204 No Content", @"204", + @"HTTP/1.1 301 Moved Permanently", @"301", + @"HTTP/1.1 302 Found", @"302", + @"HTTP/1.1 303 See Other", @"303", + @"HTTP/1.1 307 Temporary Redirect", @"307", + @"HTTP/1.1 400 Bad Request", @"400", + @"HTTP/1.1 401 Unauthorized", @"401", + @"HTTP/1.1 403 Forbidden", @"403", + @"HTTP/1.1 404 Not Found", @"404", + @"HTTP/1.1 416 Requested Range Not Satisfiable", + @"416", + @"HTTP/1.1 500 Internal Server Error", @"500", + @"HTTP/1.1 501 Not Implemented", @"501", + nil]; + [responses retain]; + + NSDictionary *header200 = [NSDictionary dictionaryWithObjectsAndKeys: + bl, @"Content-Length", + nil]; + //we can use this Location: header in header201 for the 30x, too + NSDictionary *header201 = [NSDictionary dictionaryWithObjectsAndKeys: + LOCATION200, @"Location", + nil]; + NSDictionary *header401 = [NSDictionary dictionaryWithObjectsAndKeys: + @"Basic realm=\"GNUstep\"", + @"WWW-Authenticate", + nil]; + + headers = [NSDictionary dictionaryWithObjectsAndKeys: + header200, @"200", + header201, @"201", + header201, @"301", + header201, @"302", + header201, @"303", + header201, @"307", + header401, @"401", + nil]; + [headers retain]; + + ip = nil; + op = nil; + request = nil; + } + return self; +} + +- (void)dealloc +{ + [headers release]; + [commonHeaders release]; + [responses release]; + if (nil != ip) + { + [ip release]; + } + if (nil != op) + { + [op release]; + } + if (nil != request) + { + [request release]; + } + + [super dealloc]; +} + +- (int)runTest +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + NSHost *host = [NSHost hostWithName: @"localhost"]; + NSStream *serverStream; + unsigned port = [[defs stringForKey: @"Port"] intValue]; + + if (0 == port) port = PORT_LISTEN; + + serverStream = [GSServerStream serverStreamToAddr: [host address] + port: port]; + + if (nil == serverStream) + { + NSLog(@"Failed to create server stream"); + return 1; + } + + [serverStream setDelegate: self]; + [serverStream scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [serverStream open]; + + // run for one minute, then quit + [rl runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 60]]; + return 0; +} + +- (void) stream: (NSStream *)theStream handleEvent: (NSStreamEvent) streamEvent +{ + NSRunLoop *rl = [NSRunLoop currentRunLoop]; + + switch (streamEvent) + { + case NSStreamEventHasBytesAvailable: + { + if (theStream != ip) + { + if (ip != nil) + { + [ip close]; + [ip removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + ip = nil; + } + if (op != nil) + { + [op close]; + [op removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + op = nil; + } + [(GSServerStream *)theStream acceptWithInputStream: &ip + outputStream: &op]; + + if (ip) + { + RETAIN(ip); + RETAIN(op); + [ip scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [ip setDelegate: self]; + [op setDelegate: self]; + [ip open]; + } + else + { + NSLog(@"Received nothing from accept"); + } + } + else if (theStream == ip) + { + uint8_t buf[1024]; + unsigned len; + BOOL done = NO; + + if (nil != request) + { + [request release]; + } + request = [[NSMutableData alloc] initWithCapacity: sizeof(buf)]; + len = [ip read: buf maxLength: sizeof(buf)]; + if (len > 0) + { + const char *bytes; + + [request appendBytes: buf length: len]; + len = [request length]; + bytes = (const char*)[request bytes]; + if (len > 3 && memcmp(bytes+len-4, "\r\n\r\n", 4) == 0) + { + done = YES; + } + } + else + { + done = YES; // EOF or error + } + if (done == YES) + { + [op open]; + [op scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode]; + [ip close]; + [ip removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + ip = nil; + } + } + break; + } + + case NSStreamEventHasSpaceAvailable: + { + NSString *wholeReq, *req, *retCode, *hdr; + NSMutableData *response; + NSArray *components; + NSDictionary *specificHeaders; + NSEnumerator *en; + + int statusCode; + + NSAssert(op == theStream, NSInternalInconsistencyException); + if (nil == request) + { + NSLog(@"Attempt to send response without a request"); + return; + } + wholeReq = [[[NSString alloc] initWithData: request + encoding: NSASCIIStringEncoding] + autorelease]; + response = [[[NSMutableData alloc] init] autorelease]; + components = [wholeReq componentsSeparatedByString: @"\r\n"]; + // the actual request is the first line + req = [components objectAtIndex: 0]; + + if ([req rangeOfString: @"GET"].location == NSNotFound + && [req rangeOfString: @"HEAD"].location == NSNotFound) + { + retCode = @"501"; // HTTP 501: Not Implemented + } + else + { + retCode = [[req componentsSeparatedByString: @" "] + objectAtIndex: 1]; + // trim the leading slash + retCode = [[retCode pathComponents] objectAtIndex: 1]; + } + if ([responses objectForKey: retCode] == nil) + { + retCode = @"404"; // HTTP 404: Not Found + } + // build the response + [response appendBytes: [[responses objectForKey: retCode] cString] + length: [[responses objectForKey: retCode] length]]; + [response appendBytes: "\r\n" length: 2]; + + en = [commonHeaders keyEnumerator]; + while ((hdr = [en nextObject]) != nil) + { + [response appendBytes: [hdr cString] length: [hdr length]]; + [response appendBytes: ": " length: 2]; + hdr = [commonHeaders objectForKey: hdr]; + [response appendBytes: [hdr cString] length: [hdr length]]; + [response appendBytes: "\r\n" length: 2]; + } + + specificHeaders = [headers objectForKey: retCode]; + if (specificHeaders != nil) + { + en = [specificHeaders keyEnumerator]; + while ((hdr = [en nextObject]) != nil) + { + [response appendBytes: [hdr cString] length: [hdr length]]; + [response appendBytes: ": " length: 2]; + hdr = [specificHeaders objectForKey: hdr]; + [response appendBytes: [hdr cString] length: [hdr length]]; + [response appendBytes: "\r\n" length: 2]; + } + } + [response appendBytes: "\r\n" length: 2]; + //do we need to add the body part? + + if([req rangeOfString: @"HEAD"].location == NSNotFound) + { + statusCode = [retCode intValue]; + + switch (statusCode) + { + case 200: + case 400: + case 401: + case 403: + case 404: + case 500: + case 501: + [response appendBytes: [body cString] length: [body length]]; + break; + default: + break; + } + } + // send this response and close the stream + [op write: [response bytes] maxLength: [response length]]; + [op close]; + [op removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + op = nil; + break; + } + + case NSStreamEventEndEncountered: + { + [theStream close]; + [theStream removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + if (theStream == ip) ip = nil; + if (theStream == op) op = nil; + break; + } + + case NSStreamEventErrorOccurred: + { + int code = [[theStream streamError] code]; + + NSLog(@"Error %d on stream %p", code, theStream); + [theStream close]; + [theStream removeFromRunLoop: rl forMode: NSDefaultRunLoopMode]; + if (theStream == ip) ip = nil; + if (theStream == op) op = nil; + break; + } + + case NSStreamEventOpenCompleted: + break; + + default: + NSLog (@"Event %d on stream %p unknown", streamEvent, theStream); + break; + } +} + +@end + +int main (int argc, char **argv) +{ + int result; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + result = [[[[StatusServer alloc] init] autorelease] runTest]; + + [arp release]; arp = nil; + return result; +} + +#else + +int main (int argc, char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + NSLog(@"StatesServer not implemented on non-GNUstep systems"); + + [arp release]; arp = nil; + return 0; +} + +#endif diff --git a/Tests/base/NSURLHandle/TestInfo b/Tests/base/NSURLHandle/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSURLHandle/basic.m b/Tests/base/NSURLHandle/basic.m new file mode 100644 index 000000000..2fd8d1574 --- /dev/null +++ b/Tests/base/NSURLHandle/basic.m @@ -0,0 +1,49 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +@interface DummyHandle : NSURLHandle +@end +@implementation DummyHandle +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + Class cls; + NSURL *httpURL, *foobarURL; + id handle1, handle2; + + + httpURL = [NSURL URLWithString: @"http://www.gnustep.org"]; + foobarURL = [NSURL URLWithString: @"foobar://localhost/madeupscheme"]; + + TEST_FOR_CLASS(@"NSURLHandle", [NSURLHandle alloc], + "NSURLHandle +alloc returns an NSURLHandle"); + + PASS_EXCEPTION([DummyHandle cachedHandleForURL: httpURL];, + NSInvalidArgumentException, + "NSURLHandle subclass must implement +cachedHandleForURL:"); + + cls = [NSURLHandle URLHandleClassForURL: httpURL]; + + PASS([cls canInitWithURL: httpURL] == YES, + "Appropriate subclass found for +URLHandleClassForURL:"); + handle1 = [[cls alloc] initWithURL: httpURL cached: YES]; + handle2 = [NSURLHandle cachedHandleForURL: httpURL]; + + PASS(handle2 != nil, "Available handle returned from cache"); + + [handle1 autorelease]; + [cls autorelease]; + +#if !defined(GNUSTEP_BASE_LIBRARY) + PASS(NO, "URLHandleClassForURL: seems to hang on MacOS-X when given an unknown URL scheme ... you may want to check to see if it has been fixed"); +#else + cls = [NSURLHandle URLHandleClassForURL: foobarURL]; + PASS(cls == Nil, "Nil class returned for unknown URL scheme"); +#endif + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSURLHandle/test00.m b/Tests/base/NSURLHandle/test00.m new file mode 100644 index 000000000..9ffa5b66e --- /dev/null +++ b/Tests/base/NSURLHandle/test00.m @@ -0,0 +1,138 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +/* this test collection examines the behaviour of the + * NSURLHandleClient protocol. + * Graham J Lee + */ + +typedef enum _URLHandleClientStatus { + URLHandleClientNormal = 0, + URLHandleClientDataDidBecomeAvailable, + URLHandleClientDidFailLoadingWithReason, + URLHandleClientDidBeginLoading, + URLHandleClientDidCancelLoading, + URLHandleClientDidFinishLoading } URLHandleClientStatus; + +@interface TestObject : NSObject +{ + @protected + URLHandleClientStatus _status; + NSData *_receivedData; +} +- (int) runTest; + +- (URLHandleClientStatus) status; +- (void) setStatus: (URLHandleClientStatus)newStatus; + +- (void) URLHandle: (NSURLHandle *)sender +resourceDataDidBecomeAvailable: (NSData *)newBytes; +- (void) URLHandle: (NSURLHandle *)sender +resourceDidFailLoadingWithReason: (NSString *)reason; +- (void) URLHandleResourceDidBeginLoading: (NSURLHandle *)sender; +- (void) URLHandleResourceDidCancelLoading: (NSURLHandle *)sender; +- (void) URLHandleResourceDidFinishLoading: (NSURLHandle *)sender; +@end + +@implementation TestObject + +- (id) init +{ + if ((self = [super init])) + { + _status = URLHandleClientNormal; + _receivedData = nil; + } + return self; +} + +- (void) dealloc +{ + if (_receivedData) + { + [_receivedData release]; + } + [super dealloc]; +} + +- (URLHandleClientStatus) status { return _status; } +- (void) setStatus: (URLHandleClientStatus)newStatus { _status = newStatus; } + +- (void) URLHandle: (NSURLHandle *)sender +resourceDataDidBecomeAvailable: (NSData *)newBytes +{ + [self setStatus: URLHandleClientDataDidBecomeAvailable]; + if (_receivedData) + { + [_receivedData release]; + } + _receivedData = newBytes; +} + +- (void) URLHandle: (NSURLHandle *)sender +resourceDidFailLoadingWithReason: (NSString *)reason +{ + [self setStatus: URLHandleClientDidFailLoadingWithReason]; + NSLog(@"Load failed: further tests may fail. Reason: %@", reason); +} + +- (void) URLHandleResourceDidBeginLoading: (NSURLHandle *)sender +{ + [self setStatus: URLHandleClientDidBeginLoading]; +} + +- (void) URLHandleResourceDidCancelLoading: (NSURLHandle *)sender +{ + [self setStatus: URLHandleClientDidCancelLoading]; +} + +- (void) URLHandleResourceDidFinishLoading: (NSURLHandle *)sender +{ + [self setStatus: URLHandleClientDidFinishLoading]; +} + +- (int)runTest +{ + id handle; + NSURL *url; + Class cls; + + url = [NSURL URLWithString: @"http://www.gnustep.org/"]; + cls = [NSURLHandle URLHandleClassForURL: url]; + handle = [[cls alloc] initWithURL: url cached: NO]; + + [handle addClient: self]; + [self setStatus: URLHandleClientNormal]; + + [handle beginLoadInBackground]; + [handle cancelLoadInBackground]; + PASS([self status] == URLHandleClientDidCancelLoading, + "URLHandleResourceDidCancelLoading called"); + [handle release]; + + handle = [[cls alloc] initWithURL: url cached: NO]; + [handle addClient: self]; + /* Don't get client messages in the foreground, so load in + * background and wait a bit + */ + [handle loadInBackground]; + PASS([self status] == URLHandleClientDidBeginLoading, + "URLHandleResourceDidBeginLoading called"); + + [handle release]; + return 0; +} + +@end + +int main(int argc, char **argv) +{ + int status; + + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + status = [[[[TestObject alloc] init] autorelease] runTest]; + [arp release]; arp = nil; + + return status; +} diff --git a/Tests/base/NSURLHandle/test01.m b/Tests/base/NSURLHandle/test01.m new file mode 100644 index 000000000..a94aeef8c --- /dev/null +++ b/Tests/base/NSURLHandle/test01.m @@ -0,0 +1,67 @@ +#include +#include "Testing.h" +#include "ObjectTesting.h" + +/* This test collection examines the responses when a variety of HTTP +* status codes are returned by the server. Relies on the +* StatusServer helper tool. +* +* Graham J Lee < leeg@thaesofereode.info > +*/ + +int main(int argc, char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new] ; + + NSString *helpers; + NSString *statusServer; + NSURL *url; + NSURLHandle *handle; + NSTask *t; + Class cls; + NSData *resp; + NSData *rxd; + + url = [NSURL URLWithString: @"http://localhost:54321/200"]; + cls = [NSURLHandle URLHandleClassForURL: url]; + resp = [NSData dataWithBytes: "Hello\r\n" length: 7]; + + helpers = [[NSFileManager defaultManager] currentDirectoryPath]; + helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; + helpers = [helpers stringByAppendingPathComponent: @"obj"]; + statusServer = [helpers stringByAppendingPathComponent: @"StatusServer"]; + + t = [NSTask launchedTaskWithLaunchPath: statusServer arguments: nil]; + + if (t != nil) + { + // pause, so that the server is set up + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.5]]; + // try some different requests + handle = [[[cls alloc] initWithURL: url cached: NO] autorelease]; + rxd = [handle loadInForeground]; + PASS([rxd isEqual: resp], + "Got the correct data from a 200 - status load") ; + PASS([handle status] == NSURLHandleLoadSucceeded, + "200 - status: Handle load succeeded") ; + + url = [NSURL URLWithString: @"http://localhost:54321/401"]; + handle = [[[cls alloc] initWithURL: url cached: NO] autorelease]; + rxd = [handle loadInForeground]; + PASS([handle status] == NSURLHandleNotLoaded, + "401 - status: Handle load not loaded (unanswered auth challenge)"); + + url = [NSURL URLWithString: @"http://localhost:54321/404"]; + handle = [[[cls alloc] initWithURL: url cached: NO] autorelease]; + rxd = [handle loadInForeground]; + PASS([handle status] == NSURLHandleNotLoaded, + "404 - status: Handle load not loaded (resource not found)"); + [t terminate]; + [t waitUntilExit]; + } + + [arp release]; arp = nil ; + + return 0; +} + diff --git a/Tests/base/NSURLProtocol/TestInfo b/Tests/base/NSURLProtocol/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSURLProtocol/basic.m b/Tests/base/NSURLProtocol/basic.m new file mode 100644 index 000000000..5ebd6f6c4 --- /dev/null +++ b/Tests/base/NSURLProtocol/basic.m @@ -0,0 +1,35 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableURLRequest *mutable, *copy; + NSURLRequest *canon; + NSURL *httpURL; + + httpURL = [NSURL URLWithString: @"http://www.gnustep.org"]; + + TEST_FOR_CLASS(@"NSURLProtocol", [NSURLProtocol alloc], + "NSURLProtocol +alloc returns an NSURLProtocol"); + + mutable = [[NSMutableURLRequest requestWithURL: httpURL] retain]; + PASS_EXCEPTION([NSURLProtocol canInitWithRequest: mutable], nil, + "NSURLProtocol +canInitWithRequest throws an exeception (subclasses should be used)"); + + canon = [NSURLProtocol canonicalRequestForRequest: mutable]; + TEST_FOR_CLASS(@"NSURLRequest", canon, + "NSURLProtocol +canonicalRequestForRequest: returns an NSURLProtocol"); + + copy = [mutable copy]; + PASS([NSURLProtocol requestIsCacheEquivalent: mutable toRequest: copy], + "NSURLProtocol +requestIsCacheEquivalent:toRequest returns YES with a request and its copy"); + [copy setHTTPMethod: @"POST"]; + PASS([NSURLProtocol requestIsCacheEquivalent: mutable toRequest: copy] == NO, + "NSURLProtocol +requestIsCacheEquivalent:toRequest returns NO after a method change"); + [copy release]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSURLRequest/TestInfo b/Tests/base/NSURLRequest/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSURLRequest/basic.m b/Tests/base/NSURLRequest/basic.m new file mode 100644 index 000000000..f536d6a6e --- /dev/null +++ b/Tests/base/NSURLRequest/basic.m @@ -0,0 +1,50 @@ +#import +#import "Testing.h" +#import "ObjectTesting.h" + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSURLRequest *request; + NSMutableURLRequest *mutable; + NSURL *httpURL, *foobarURL; + + httpURL = [NSURL URLWithString: @"http://www.gnustep.org"]; + foobarURL = [NSURL URLWithString: @"foobar://localhost/madeupscheme"]; + + TEST_FOR_CLASS(@"NSURLRequest", [NSURLRequest alloc], + "NSURLRequest +alloc returns an NSURLRequest"); + + request = [NSURLRequest requestWithURL: httpURL]; + PASS(request != nil, + "NSURLRequest +requestWithURL returns a request from a valid URL"); + PASS_EQUAL([[request URL] absoluteString], [httpURL absoluteString], + "Request URL is equal to the URL used for creation"); + PASS_EQUAL([request HTTPMethod], @"GET", + "Request is initialized with a GET method"); + + request = [NSURLRequest requestWithURL: foobarURL]; + PASS(request != nil, + "NSURLRequest +requestWithURL returns a request from an invalid URL (unknown scheme)"); + + mutable = [request mutableCopy]; + PASS(mutable != nil && [mutable isKindOfClass:[NSMutableURLRequest class]], + "NSURLRequest -mutableCopy returns a mutable request"); + [mutable setHTTPMethod: @"POST"]; + PASS_EQUAL([mutable HTTPMethod], @"POST", + "Can setHTTPMethod of a mutable request (POST)"); + [mutable setHTTPMethod: @"NONHTTPMETHOD"]; + PASS_EQUAL([mutable HTTPMethod], @"NONHTTPMETHOD", + "Can setHTTPMethod of a mutable request (non existant NONHTTPMETHOD)"); + + [mutable addValue: @"value1" forHTTPHeaderField: @"gnustep"]; + PASS_EQUAL([mutable valueForHTTPHeaderField: @"gnustep"], @"value1", + "Can set and get a value for an HTTP header field"); + [mutable addValue: @"value2" forHTTPHeaderField: @"gnustep"]; + PASS_EQUAL([mutable valueForHTTPHeaderField: @"gnustep"], (@"value1,value2"), + "Handle multiple values for an HTTP header field"); + [mutable release]; + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSUndoManager/NSUndoManager_basic.m b/Tests/base/NSUndoManager/NSUndoManager_basic.m new file mode 100644 index 000000000..fb7ceb035 --- /dev/null +++ b/Tests/base/NSUndoManager/NSUndoManager_basic.m @@ -0,0 +1,320 @@ +#import "Testing.h" +#import "ObjectTesting.h" +#import +#import +#import +#import + +static NSUndoManager *um; +BOOL sane; +BOOL isUndoing; +BOOL isRedoing; + +static void checkSanity() +{ + sane = ([um isUndoing] == isUndoing && [um isRedoing] == isRedoing); + if (sane == NO) + { + fprintf(stderr, "FAIL: basic sanity tests\n"); + } +} +@interface Foo : NSObject +{ + NSString *_foo; + int _number; +} +@end + +@implementation Foo +- (id) init +{ + self = [super init]; + um = [NSUndoManager new]; + return self; +} + +- (void) setFooReg:(id)newFoo +{ +NSLog(@"setFooReg: %@", newFoo); + checkSanity(); + [um registerUndoWithTarget:self selector:@selector(setFooReg:) object:_foo]; + ASSIGN(_foo,newFoo); +} + +- (void) setFooPrep:(id)newFoo +{ + checkSanity(); + [[um prepareWithInvocationTarget:self] setFooPrep:_foo]; + ASSIGN(_foo,newFoo); +} +- (id) fooUndo +{ + isUndoing = YES; + isRedoing = NO; + [um undo]; + return _foo; +} + +- (id) fooRedo +{ + isUndoing = NO; + isRedoing = YES; + [um redo]; + return _foo; +} + +- (NSString *)foo +{ + return _foo; +} + +- (int) numUndo +{ + isUndoing = YES; + isRedoing = NO; + [um undo]; + return _number; +} + +- (int) numRedo +{ + isUndoing = NO; + isRedoing = YES; + [um redo]; + return _number; +} + +- (void) setNumber:(int)newNum +{ + checkSanity(); + [[um prepareWithInvocationTarget:self] setNumber:_number]; + _number = newNum; +} + +- (int) number +{ + return _number; +} +@end + +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + id obj = [Foo new]; + id one, two, three, four, five, six, seven, eight; + id bar; + int rc; + + one = @"one"; + two = @"two"; + three = @"three"; + four = @"four"; + five = @"five"; + six = @"six"; + seven = @"seven"; + eight = @"eight"; + + PASS([um levelsOfUndo] == 0, "initial levels of undo is zero"); + PASS([um groupingLevel] == 0, "initial grouping level is zero"); + PASS([um isUndoRegistrationEnabled] == YES, "undo registration is enabled"); + PASS([um groupsByEvent] == YES, " groups by event enabled"); + PASS([um isUndoing] == NO, "undoing not in progress"); + PASS([um isRedoing] == NO, "redoing not in progress"); + [um setGroupsByEvent: NO]; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooReg:one]; + [um endUndoGrouping]; + + PASS(([obj fooUndo] == nil && sane), + "registerWithUndoTarget:selector:object single level undo"); + PASS(([obj fooRedo] == one && sane), + "registerWithUndoTarget:selector:object single level redo"); + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooReg:two]; + [um endUndoGrouping]; + PASS([obj foo] == two && sane, "set two"); + + [um beginUndoGrouping]; + [obj setFooReg:three]; + [um endUndoGrouping]; + PASS([obj foo] == three && sane, "set three"); + + PASS(([obj fooUndo] == two && sane + && [obj fooUndo] == one && sane + && [obj fooUndo] == nil && sane), + "registerWithUndoTarget:selector:object multi level undo"); + + PASS(([obj fooRedo] == one && sane + && [obj fooRedo] == two && sane + && [obj fooRedo] == three && sane), + "registerWithUndoTarget:selector:object multi level redo"); + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooPrep:four]; + [um endUndoGrouping]; + + [um beginUndoGrouping]; + [obj setFooPrep:five]; + [um endUndoGrouping]; + + PASS(([obj fooUndo] == four && sane), + "prepareWithInvocationTarget single level undo"); + PASS(([obj fooRedo] == five && sane), + "prepareWithInvocationTarget single level redo"); + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooPrep:six]; + [um endUndoGrouping]; + + PASS(([obj fooUndo] == five && sane + && [obj fooUndo] == four && sane), + "prepareWithInvocationTarget multi level undo"); + PASS(([obj fooRedo] == five && sane + && [obj fooRedo] == six && sane), + "prepareWithInvocationTarget multi level redo"); + + PASS(([obj fooUndo] == five && sane + && [obj fooUndo] == four && sane + && [obj fooUndo] == three && sane + && [obj fooUndo] == two && sane + && [obj fooUndo] == one && sane + && [obj fooUndo] == nil && sane), + "mixing prepare... and register... in undo stack"); + + PASS(([obj fooRedo] == one && sane + && [obj fooRedo] == two && sane + && [obj fooRedo] == three && sane + && [obj fooRedo] == four && sane + && [obj fooRedo] == five && sane + && [obj fooRedo] == six && sane), + "mixing prepare... and register... in redo stack"); + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setNumber:1]; + [um endUndoGrouping]; + + PASS(([obj numUndo] == 0), "single level undo with int argument"); + PASS(([obj numRedo] == 1), "single level redo with int argument"); + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setNumber:2]; + [um endUndoGrouping]; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setNumber:3]; + [um endUndoGrouping]; + + PASS(([obj numUndo] == 2 && sane + && [obj numUndo] == 1 && sane + && [obj numUndo] == 0 && sane), + "multi level undo with int argument"); + PASS(([obj numRedo] == 1 && sane + && [obj numRedo] == 2 && sane + && [obj numRedo] == 3 && sane), + "multi level redo with int argument"); + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setNumber:7]; + [obj setFooPrep:seven]; + [um endUndoGrouping]; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setNumber:8]; + [obj setFooReg:eight]; + [um endUndoGrouping]; + + isRedoing = NO; + isUndoing = YES; + [um undo]; + PASS(([obj number] == 7 && sane && [obj foo] == seven && sane), + "undo grouping works with undo"); + + isUndoing = NO; + isRedoing = YES; + [um redo]; + PASS(([obj number] == 8 && sane && [obj foo] == eight && sane), + "undo grouping works with redo"); + DESTROY(um); + um = [[NSUndoManager alloc] init]; + [um setGroupsByEvent: NO]; + [um setLevelsOfUndo: 2]; + PASS(([um levelsOfUndo] == 2), "setLevelsOfUndo: is sane."); + + one = @"one"; + two = @"two"; + three = @"three"; + four = @"four"; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooPrep:one]; + [um endUndoGrouping]; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooPrep:two]; + [um endUndoGrouping]; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooPrep:three]; + [um endUndoGrouping]; + + [um beginUndoGrouping]; + isUndoing = NO; + isRedoing = NO; + [obj setFooPrep:four]; + [um endUndoGrouping]; + + PASS(([obj fooUndo] == three && sane + && [obj fooUndo] == two && sane + && [obj fooUndo] == two && sane), + "levels of undo really works with undo."); + + PASS(([obj fooRedo] == three && sane + && [obj fooRedo] == four && sane + && [obj fooRedo] == four && sane), + "levels of undo really works with redo."); + + bar = [[NSObject alloc] init]; + rc = [bar retainCount]; + + PASS_EXCEPTION([um registerUndoWithTarget:obj selector:@selector(setFooReg:) object:nil], nil, "can't register undo outside any group"); + + [um beginUndoGrouping]; + [um registerUndoWithTarget:obj selector:@selector(setFooReg:) object:bar]; + [um endUndoGrouping]; + PASS(([bar retainCount] == (rc + 1)),"registerUndoWithTarget:selector:object: retains its argument object"); + isRedoing = NO; + isUndoing = YES; + + [um undo]; /* setFooReg: should cause a retain. */ + [pool release]; + pool = [NSAutoreleasePool new]; + PASS((rc+1== [bar retainCount]),"-undo causes NSUndoManager to release its argument object"); + [pool release]; pool = nil; + return 0; +} diff --git a/Tests/base/NSUndoManager/NSUndoManager_notifications.m b/Tests/base/NSUndoManager/NSUndoManager_notifications.m new file mode 100644 index 000000000..0aafbb665 --- /dev/null +++ b/Tests/base/NSUndoManager/NSUndoManager_notifications.m @@ -0,0 +1,200 @@ +#import "Testing.h" +#import +#import +#import +#import + +static NSUndoManager *um; + +unsigned openGroupCount; +unsigned groupingLevels[32] = {0}; +unsigned checkPointCounter = 0; + +BOOL shouldBeUndoing; +BOOL shouldBeRedoing; + +BOOL checkPoint; +BOOL openUndoGroup; +BOOL willdidUndo; +BOOL willdidRedo; +BOOL closeUndoGroup; + +BOOL gotCheckPoint; +BOOL gotOpenUndoGroup; +BOOL gotDidUndo; +BOOL gotWillUndo; +BOOL gotDidRedo; +BOOL gotWillRedo; +BOOL gotCloseUndoGroup; + +@interface Foo : NSObject +{ + NSString *_foo; + int _number; +} +@end + +@implementation Foo +- (id) init +{ + NSNotificationCenter *nc; + self = [super init]; + um = [NSUndoManager new]; + nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self selector:@selector(checkPoint:) + name:NSUndoManagerCheckpointNotification object:um]; + [nc addObserver:self selector:@selector(openUndoGroup:) + name:NSUndoManagerDidOpenUndoGroupNotification object:um]; + [nc addObserver:self selector:@selector(didUndo:) + name:NSUndoManagerDidUndoChangeNotification object:um]; + [nc addObserver:self selector:@selector(willUndo:) + name:NSUndoManagerWillUndoChangeNotification object:um]; + [nc addObserver:self selector:@selector(didRedo:) + name:NSUndoManagerDidRedoChangeNotification object:um]; + [nc addObserver:self selector:@selector(willRedo:) + name:NSUndoManagerWillRedoChangeNotification object:um]; + [nc addObserver:self selector:@selector(closeUndoGroup:) + name:NSUndoManagerWillCloseUndoGroupNotification object:um]; + + return self; +} +- (void) checkPoint:(NSNotification *)notif +{ +NSLog(@"%@ %d", notif, [um groupingLevel]); + if (checkPointCounter +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSArray *testObj = [NSUserDefaults new]; + + test_NSObject(@"NSUserDefaults", [NSArray arrayWithObject:testObj]); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSUserDefaults/general.m b/Tests/base/NSUserDefaults/general.m new file mode 100644 index 000000000..04b5d1b1a --- /dev/null +++ b/Tests/base/NSUserDefaults/general.m @@ -0,0 +1,58 @@ +#import +#import +#import +#import "ObjectTesting.h" + +@interface Observer : NSObject +{ + unsigned count; +} +- (NSString*) count; +- (void) notified: (NSNotification*)n; +@end + +@implementation Observer +- (NSString*) count +{ + return [NSString stringWithFormat: @"%u", count]; +} +- (void) notified: (NSNotification*)n +{ + count++; +} +@end + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + Observer *obs = [[Observer new] autorelease]; + NSUserDefaults *defs; + + defs = [NSUserDefaults standardUserDefaults]; + PASS(defs != nil && [defs isKindOfClass: [NSUserDefaults class]], + "NSUserDefaults understands +standardUserDefaults"); + + [[NSNotificationCenter defaultCenter] addObserver: obs + selector: @selector(notified:) + name: NSUserDefaultsDidChangeNotification + object: nil]; + + [defs setBool: YES forKey: @"Test Suite Bool"]; + PASS([defs boolForKey: @"Test Suite Bool"], + "NSUserDefaults can set/get a BOOL"); + + PASS_EQUAL([obs count], @"1", "setting a boolean causes notification"); + + [defs setInteger: 34 forKey: @"Test Suite Int"]; + PASS([defs integerForKey: @"Test Suite Int"] == 34, + "NSUserDefaults can set/get an int"); + + PASS_EQUAL([obs count], @"2", "setting an integer causes notification"); + + [defs setObject: @"SetString" forKey: @"Test Suite Str"]; + PASS([[defs stringForKey: @"Test Suite Str"] isEqual: @"SetString"], + "NSUserDefaults can set/get a string"); + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/NSXMLParser/ParseData/internal-document.result b/Tests/base/NSXMLParser/ParseData/internal-document.result new file mode 100644 index 000000000..5732d280a --- /dev/null +++ b/Tests/base/NSXMLParser/ParseData/internal-document.result @@ -0,0 +1,84 @@ +parserDidStartDocument: +parser:foundElementDeclarationWithName:model: cTree +parser:foundAttributeDeclarationWithName:forElement:type:defaultValue: version cTree 1.0 +parser:foundElementDeclarationWithName:model: function +parser:foundAttributeDeclarationWithName:forElement:type:defaultValue: name function (null) +parser:foundAttributeDeclarationWithName:forElement:type:defaultValue: srcLoc function (null) +parser:foundElementDeclarationWithName:model: argument +parser:foundElementDeclarationWithName:model: result +parser:didStartElement:namespaceURI:qualifiedName:attributes: cTree cTree { + version = "1.0"; +} +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: function function { + name = ".main.dbl"; + srcLoc = "line 1.32"; +} +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: argument argument { +} +parser:foundCharacters: .main.sqr +parser:didEndElement:namespaceURI:qualifiedName: argument argument +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: argument argument { +} +parser:foundCharacters: 3 +parser:didEndElement:namespaceURI:qualifiedName: argument argument +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: result result { +} +parser:foundCharacters: 12 +parser:didEndElement:namespaceURI:qualifiedName: result result +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: function function { + name = ".main.sqr"; + srcLoc = "line 1.17"; +} +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: argument argument { +} +parser:foundCharacters: 3 +parser:didEndElement:namespaceURI:qualifiedName: argument argument +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: result result { +} +parser:foundCharacters: 6 +parser:didEndElement:namespaceURI:qualifiedName: result result +parser:foundCharacters: + +parser:didEndElement:namespaceURI:qualifiedName: function function +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: function function { + name = ".main.sqr"; + srcLoc = "line 1.17"; +} +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: argument argument { +} +parser:foundCharacters: 6 +parser:didEndElement:namespaceURI:qualifiedName: argument argument +parser:foundCharacters: + +parser:didStartElement:namespaceURI:qualifiedName:attributes: result result { +} +parser:foundCharacters: 12 +parser:didEndElement:namespaceURI:qualifiedName: result result +parser:foundCharacters: + +parser:didEndElement:namespaceURI:qualifiedName: function function +parser:foundCharacters: + +parser:didEndElement:namespaceURI:qualifiedName: function function +parser:foundCharacters: + +parser:didEndElement:namespaceURI:qualifiedName: cTree cTree +parserDidEndDocument: diff --git a/Tests/base/NSXMLParser/ParseData/internal-document.xml b/Tests/base/NSXMLParser/ParseData/internal-document.xml new file mode 100644 index 000000000..46a9713d4 --- /dev/null +++ b/Tests/base/NSXMLParser/ParseData/internal-document.xml @@ -0,0 +1,24 @@ + + + + + + + +]> + + +.main.sqr +3 +12 + +3 +6 + + +6 +12 + + + diff --git a/Tests/base/NSXMLParser/TestInfo b/Tests/base/NSXMLParser/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/NSXMLParser/basic.m b/Tests/base/NSXMLParser/basic.m new file mode 100644 index 000000000..4ba1969dd --- /dev/null +++ b/Tests/base/NSXMLParser/basic.m @@ -0,0 +1,20 @@ +#import "ObjectTesting.h" +#import +#import +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSXMLParser *parser; + + parser = [NSXMLParser new]; + test_alloc(@"NSXMLParser"); + test_NSObject(@"NSXMLParser", [NSArray arrayWithObject: parser]); + [arp release]; arp = nil; + +/* Don't release the parser ... it appears that on OSX there is a bug in + * NSXMLParser such that deallocation crashes if the -self method has been + * called on it (which is something the NSObject test does). + [parser release]; + */ + return 0; +} diff --git a/Tests/base/NSXMLParser/parse.m b/Tests/base/NSXMLParser/parse.m new file mode 100644 index 000000000..b5b56ace4 --- /dev/null +++ b/Tests/base/NSXMLParser/parse.m @@ -0,0 +1,321 @@ +#import "ObjectTesting.h" +#import +#import +#import +#import +#include + +@interface Handler : NSObject +{ + NSMutableString *s; +} + +- (void)parserDidStartDocument: (NSXMLParser *)parser; +- (void)parserDidEndDocument: (NSXMLParser *)parser; +- (void)parser: (NSXMLParser *)parser foundNotationDeclarationWithName: (NSString *)name publicID: (NSString *)publicID systemID: (NSString *)systemID; +- (void)parser: (NSXMLParser *)parser foundUnparsedEntityDeclarationWithName: (NSString *)name publicID: (NSString *)publicID systemID: (NSString *)systemID notationName: (NSString *)notationName; +- (void)parser: (NSXMLParser *)parser foundAttributeDeclarationWithName: (NSString *)attributeName forElement: (NSString *)elementName type: (NSString *)type defaultValue: (NSString *)defaultValue; +- (void)parser: (NSXMLParser *)parser foundElementDeclarationWithName: (NSString *)elementName model: (NSString *)model; + +- (void)parser: (NSXMLParser *)parser foundInternalEntityDeclarationWithName: (NSString *)name value: (NSString *)value; + +- (void)parser: (NSXMLParser *)parser foundExternalEntityDeclarationWithName: (NSString *)name publicID: (NSString *)publicID systemID: (NSString *)systemID; + +- (void)parser: (NSXMLParser *)parser didStartElement: (NSString *)elementName namespaceURI: (NSString *)namespaceURI qualifiedName: (NSString *)qName attributes: (NSDictionary *)attributeDict; +- (void)parser: (NSXMLParser *)parser didEndElement: (NSString *)elementName namespaceURI: (NSString *)namespaceURI qualifiedName: (NSString *)qName; +- (void)parser: (NSXMLParser *)parser didStartMappingPrefix: (NSString *)prefix toURI: (NSString *)namespaceURI; +- (void)parser: (NSXMLParser *)parser didEndMappingPrefix: (NSString *)prefix; +- (void)parser: (NSXMLParser *)parser foundCharacters: (NSString *)string; +- (void)parser: (NSXMLParser *)parser foundIgnorableWhitespace: (NSString *)whitespaceString; +- (void)parser: (NSXMLParser *)parser foundProcessingInstructionWithTarget: (NSString *)target data: (NSString *)data; +- (void)parser: (NSXMLParser *)parser foundComment: (NSString *)comment; +- (void)parser: (NSXMLParser *)parser foundCDATA: (NSData *)CDATABlock; +- (NSData *)parser: (NSXMLParser *)parser resolveExternalEntityName: (NSString *)name systemID: (NSString *)systemID; +- (void)parser: (NSXMLParser *)parser parseErrorOccurred: (NSError *)parseError; +- (void)parser: (NSXMLParser *)parser validationErrorOccurred: (NSError *)validationError; +@end + +@implementation Handler + +- (void) dealloc +{ + [s release]; + [super dealloc]; +} + +- (NSString*) description +{ + return s; +} + +- (id) init +{ + s = [NSMutableString new]; + return self; +} + +- (void) parserDidStartDocument: (NSXMLParser *)parser +{ + [s appendFormat: @"%@\n", NSStringFromSelector(_cmd)]; +} + +- (void) parserDidEndDocument: (NSXMLParser *)parser +{ + [s appendFormat: @"%@\n", NSStringFromSelector(_cmd)]; +} + +- (void) parser: (NSXMLParser *)parser + foundNotationDeclarationWithName: (NSString *)name + publicID: (NSString *)publicID + systemID: (NSString *)systemID +{ + [s appendFormat: @"%@ %@ %@ %@\n", NSStringFromSelector(_cmd), name, + publicID, systemID]; +} + +- (void) parser: (NSXMLParser *)parser + foundUnparsedEntityDeclarationWithName: (NSString *)name + publicID: (NSString *)publicID + systemID: (NSString *)systemID + notationName: (NSString *)notationName +{ + [s appendFormat: @"%@ %@ %@ %@ %@\n", NSStringFromSelector(_cmd), name, + publicID, systemID, notationName]; +} + +- (void) parser: (NSXMLParser *)parser + foundAttributeDeclarationWithName: (NSString *)attributeName + forElement: (NSString *)elementName + type: (NSString *)type + defaultValue: (NSString *)defaultValue +{ + [s appendFormat: @"%@ %@ %@ %@ %@\n", NSStringFromSelector(_cmd), + attributeName, elementName, type, defaultValue]; +} + +- (void) parser: (NSXMLParser *)parser + foundElementDeclarationWithName: (NSString *)elementName + model: (NSString *)model +{ + [s appendFormat: @"%@ %@ %@\n", NSStringFromSelector(_cmd), + elementName, model]; +} + + +- (void) parser: (NSXMLParser *)parser + foundInternalEntityDeclarationWithName: (NSString *)name + value: (NSString *)value +{ + [s appendFormat: @"%@ %@ %@\n", NSStringFromSelector(_cmd), + name, value]; +} + + +- (void) parser: (NSXMLParser *)parser + foundExternalEntityDeclarationWithName: (NSString *)name + publicID: (NSString *)publicID + systemID: (NSString *)systemID +{ + [s appendFormat: @"%@ %@ %@ %@\n", NSStringFromSelector(_cmd), + name, publicID, systemID]; +} + + +- (void) parser: (NSXMLParser *)parser + didStartElement: (NSString *)elementName + namespaceURI: (NSString *)namespaceURI + qualifiedName: (NSString *)qName + attributes: (NSDictionary *)attributeDict +{ + static NSDictionary *locale = nil; + NSString *d; + + if (nil == locale) + { + locale = [[[NSUserDefaults standardUserDefaults] + dictionaryRepresentation] retain]; + } + d = [attributeDict descriptionWithLocale: locale]; + [s appendFormat: @"%@ %@ %@ %@ %@\n", NSStringFromSelector(_cmd), + elementName, namespaceURI, qName, d]; +} + +- (void) parser: (NSXMLParser *)parser + didEndElement: (NSString *)elementName + namespaceURI: (NSString *)namespaceURI + qualifiedName: (NSString *)qName +{ + [s appendFormat: @"%@ %@ %@ %@\n", NSStringFromSelector(_cmd), + elementName, namespaceURI, qName]; +} + +- (void) parser: (NSXMLParser *)parser + didStartMappingPrefix: (NSString *)prefix + toURI: (NSString *)namespaceURI +{ + [s appendFormat: @"%@ %@ %@\n", NSStringFromSelector(_cmd), + prefix, namespaceURI]; +} + +- (void) parser: (NSXMLParser *)parser + didEndMappingPrefix: (NSString *)prefix +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + prefix]; +} + +- (void) parser: (NSXMLParser *)parser + foundCharacters: (NSString *)string +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + string]; +} + +- (void) parser: (NSXMLParser *)parser + foundIgnorableWhitespace: (NSString *)whitespaceString +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + whitespaceString]; +} + +- (void) parser: (NSXMLParser *)parser + foundProcessingInstructionWithTarget: (NSString *)target + data: (NSString *)data +{ + [s appendFormat: @"%@ %@ %@\n", NSStringFromSelector(_cmd), + target, data]; +} + +- (void) parser: (NSXMLParser *)parser + foundComment: (NSString *)comment +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + comment]; +} + +- (void) parser: (NSXMLParser *)parser + foundCDATA: (NSData *)CDATABlock +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + CDATABlock]; +} + +- (NSData *) parser: (NSXMLParser *)parser + resolveExternalEntityName: (NSString *)name + systemID: (NSString *)systemID +{ + [s appendFormat: @"%@ %@ %@\n", NSStringFromSelector(_cmd), + name, systemID]; + return nil; +} + +- (void) parser: (NSXMLParser *)parser + parseErrorOccurred: (NSError *)parseError +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + parseError]; +} + +- (void) parser: (NSXMLParser *)parser + validationErrorOccurred: (NSError *)validationError +{ + [s appendFormat: @"%@ %@\n", NSStringFromSelector(_cmd), + validationError]; +} + +- (void) reset +{ + [s setString: @""]; +} + +@end + +/* Use these booleans to control parsing behavior. + */ +static BOOL setShouldProcessNamespaces = YES; +static BOOL setShouldReportNamespacePrefixes = YES; +static BOOL setShouldResolveExternalEntities = NO; + +static BOOL +testParse(NSData *xml, NSString *expect) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + Handler *handler; + NSXMLParser *parser; + + parser = [[NSXMLParser alloc] initWithData: xml]; + + [parser setShouldProcessNamespaces: setShouldProcessNamespaces]; + [parser setShouldReportNamespacePrefixes: setShouldReportNamespacePrefixes]; + [parser setShouldResolveExternalEntities: setShouldResolveExternalEntities]; + + handler = [[Handler new] autorelease]; + [parser setDelegate: handler]; + if (NO == [parser parse]) + { + NSLog(@"Parsing failed: %@", [parser parserError]); + [arp release]; + return NO; + } + else + { + if (NO == [[handler description] isEqual: expect]) + { + NSLog(@"######## Expected:\n%@\n######## Parsed:\n%@\n########\n", + expect, [handler description]); + [arp release]; + return NO; + } + } + [arp release]; + return YES; +} + +static BOOL +testParseCString(const char *xmlBytes, NSString *expect) +{ + NSData *xml; + + xml = [NSData dataWithBytes: xmlBytes length: strlen(xmlBytes)]; + return testParse(xml, expect); +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSFileManager *mgr = [NSFileManager defaultManager]; + NSDirectoryEnumerator *dir; + NSString *xmlName; + const char *x1 = ""; + const char *x1e = ""; + NSString *e1 = +@"parserDidStartDocument:\nparser:didStartElement:namespaceURI:qualifiedName:attributes: test test {\n x = 1;\n}\nparser:didEndElement:namespaceURI:qualifiedName: test test\nparserDidEndDocument:\n"; + + PASS((testParseCString(x1, e1)), "simple document 1") + PASS((testParseCString(x1e, e1)), "simple document 1 without header") + + /* Now perform any tests using .xml and .result pairs of files in + * the ParseData subdirectory. + */ + dir = [mgr enumeratorAtPath: @"ParseData"]; + while ((xmlName = [dir nextObject]) != nil) + { + if ([[xmlName pathExtension] isEqualToString: @"xml"]) + { + NSString *str; + NSString *xmlPath; + NSData *xmlData; + NSString *result; + + xmlPath = [@"ParseData" stringByAppendingPathComponent: xmlName]; + str = [xmlPath stringByDeletingPathExtension]; + str = [str stringByAppendingPathExtension: @"result"]; + xmlData = [NSData dataWithContentsOfFile: xmlPath]; + result = [NSString stringWithContentsOfFile: str]; + PASS((testParse(xmlData, result)), "%s", [xmlName UTF8String]) + } + } + + [arp release]; arp = nil; + return 0; +} diff --git a/Tests/base/PropertyLists/TestInfo b/Tests/base/PropertyLists/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/PropertyLists/non_ascii.m b/Tests/base/PropertyLists/non_ascii.m new file mode 100644 index 000000000..80f940c9b --- /dev/null +++ b/Tests/base/PropertyLists/non_ascii.m @@ -0,0 +1,31 @@ +/* +copyright 2004 Alexander Malmberg +*/ + +#import +#import + +#import "Testing.h" + +int main(int argc, char **argv) +{ + id plist; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf8.plist"] propertyList]; + PASS(plist!=nil, "utf8 plist works"); + + plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf16.plist"] propertyList]; + PASS(plist!=nil, "utf16 plist works"); + + plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf8.strings"] propertyListFromStringsFileFormat]; + PASS(plist!=nil, "utf8 strings file works"); + + plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf16.strings"] propertyListFromStringsFileFormat]; + PASS(plist!=nil, "utf16 strings file works"); + + [arp release]; arp = nil; + + return 0; +} + diff --git a/Tests/base/PropertyLists/non_ascii_utf16.plist b/Tests/base/PropertyLists/non_ascii_utf16.plist new file mode 100644 index 000000000..e6f2fb179 Binary files /dev/null and b/Tests/base/PropertyLists/non_ascii_utf16.plist differ diff --git a/Tests/base/PropertyLists/non_ascii_utf16.strings b/Tests/base/PropertyLists/non_ascii_utf16.strings new file mode 100644 index 000000000..6c37c7431 Binary files /dev/null and b/Tests/base/PropertyLists/non_ascii_utf16.strings differ diff --git a/Tests/base/PropertyLists/non_ascii_utf8.plist b/Tests/base/PropertyLists/non_ascii_utf8.plist new file mode 100644 index 000000000..f263f2bf8 --- /dev/null +++ b/Tests/base/PropertyLists/non_ascii_utf8.plist @@ -0,0 +1,6 @@ +/* Comment åäö. */ +{ +ascii = ascii; +"NÃ¥gotMindreAscii" = foo; +"Quoted non-ascii åäö" = "åäö"; +} diff --git a/Tests/base/PropertyLists/non_ascii_utf8.strings b/Tests/base/PropertyLists/non_ascii_utf8.strings new file mode 100644 index 000000000..8ddec1b25 --- /dev/null +++ b/Tests/base/PropertyLists/non_ascii_utf8.strings @@ -0,0 +1,5 @@ +/* Comment åäö. */ + +ascii = ascii; +"NÃ¥gotMindreAscii" = foo; +"Quoted non-ascii åäö" = "åäö"; diff --git a/Tests/base/PropertyLists/test00.m b/Tests/base/PropertyLists/test00.m new file mode 100644 index 000000000..4e98aab13 --- /dev/null +++ b/Tests/base/PropertyLists/test00.m @@ -0,0 +1,100 @@ +#import "Testing.h" +#import +#import +#import +#import +#import + +static BOOL +test_parse(NSString *string, id result) +{ + return [[string propertyList] isEqual: result]; +} + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS(test_parse(@"ariosto",@"ariosto"), + "We can parse a string"); + + PASS(test_parse(@"\"ariosto\"",@"ariosto"), + "We can parse a quoted string"); + + PASS(test_parse(@"\"ari\\033osto\"",@"ari\033osto"), + "We can parse a quoted string with octal escape"); + + PASS(test_parse(@"(ariosto)", + [NSArray arrayWithObject: @"ariosto"]), + "We can parse a simple array with a single object"); + + PASS(test_parse(@"(\"ariosto\")", + [NSArray arrayWithObject: @"ariosto"]), + "We can parse a simple array with a single object between \"s"); + + PASS(test_parse(@"(ariosto, boccaccio)", + [NSArray arrayWithObjects: @"ariosto", @"boccaccio", nil]), + "We can parse a simple array with two objects"); + + PASS(test_parse(@"(ariosto, boccaccio, \"leopardi\")", + [NSArray arrayWithObjects: + @"ariosto", @"boccaccio", @"leopardi", nil]), + "We can parse a simple array with three objects, with \"s"); + + PASS(test_parse(@"(ariosto /* I like this one */, boccaccio)", + [NSArray arrayWithObjects: @"ariosto", @"boccaccio", nil]), + "We can parse a simple array with two objects and a C comment"); + + PASS(test_parse(@"(ariosto, // I like this one\n boccaccio)", + [NSArray arrayWithObjects: @"ariosto", @"boccaccio", nil]), + "We can parse a simple array with two objects and a C++ comment"); + + PASS(test_parse(@"{}", [NSDictionary dictionary]), + "We can parse an empty dictionary"); + + PASS(test_parse(@"{author = ariosto; title = \"orlando furioso\"; }", + [NSDictionary dictionaryWithObjectsAndKeys: + @"ariosto", @"author", + @"orlando furioso", @"title", nil]), + "We can parse a simple dictionary with a two key value pairs"); + + PASS(test_parse(@"{/* -*-c-*- */ author = ariosto; title = \"orlando furioso\"; }", + [NSDictionary dictionaryWithObjectsAndKeys: + @"ariosto", @"author", + @"orlando furioso", @"title", nil]), + "We can parse a simple dictionary with a two key value pairs and a C comment"); + + PASS(test_parse(@"{// -*-c-*-\n author = ariosto; title = \"orlando furioso\";}", + [NSDictionary dictionaryWithObjectsAndKeys: + @"ariosto", @"author", + @"orlando furioso", @"title", nil]), + "We can parse a simple dictionary with a two key value pairs and a C++ comment"); + + PASS(test_parse(@"((ariosto))", + [NSArray arrayWithObject: + [NSArray arrayWithObject: @"ariosto"]]), + "We can parse an array containing a single array"); + + PASS(test_parse(@"({author = ariosto;})", + [NSArray arrayWithObject: + [NSDictionary dictionaryWithObject: @"ariosto" + forKey: @"author"]]), + "We can parse an array containing a single dictionary"); + + PASS(test_parse(@"((farinata), dante)", + [NSArray arrayWithObjects: + [NSArray arrayWithObject: @"farinata"], + @"dante", nil]), + "We can parse an array containing an array and a string"); + + PASS(test_parse(@"((farinata), {author = ariosto;})", + [NSArray arrayWithObjects: + [NSArray arrayWithObject: @"farinata"], + [NSDictionary dictionaryWithObject: @"ariosto" + forKey: @"author"],nil]), + "We can parse an array containing an array and a dictionary"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/PropertyLists/test01.m b/Tests/base/PropertyLists/test01.m new file mode 100644 index 000000000..783b5f24b --- /dev/null +++ b/Tests/base/PropertyLists/test01.m @@ -0,0 +1,322 @@ +#import "Testing.h" +#import +#import +#import +#import +#import +#import +#import +#import + +static BOOL +test_parse_unparse(id object) +{ + return [[[object description] propertyList] isEqual: object]; +} + +static BOOL +test_parse_unparse_xml(id object) +{ + NSPropertyListFormat format; + NSData *d; + id u; + + d = [NSPropertyListSerialization dataFromPropertyList: object + format: NSPropertyListXMLFormat_v1_0 errorDescription: 0]; + u = [NSPropertyListSerialization propertyListFromData: d + mutabilityOption: NSPropertyListImmutable + format: &format + errorDescription: 0]; + return [u isEqual: object]; +} + +static BOOL +test_parse_unparse_openstep(id object) +{ + NSPropertyListFormat format; + NSData *d; + id u; + + d = [NSPropertyListSerialization dataFromPropertyList: object + format: NSPropertyListOpenStepFormat errorDescription: 0]; + u = [NSPropertyListSerialization propertyListFromData: d + mutabilityOption: NSPropertyListImmutable + format: &format + errorDescription: 0]; + return [u isEqual: object]; +} + +static BOOL +test_parse_unparse_binary(id object) +{ + NSPropertyListFormat format; + NSData *d; + id u; + + d = [NSPropertyListSerialization dataFromPropertyList: object + format: NSPropertyListBinaryFormat_v1_0 errorDescription: 0]; + u = [NSPropertyListSerialization propertyListFromData: d + mutabilityOption: NSPropertyListImmutable + format: &format + errorDescription: 0]; + return [u isEqual: object]; +} + +#if defined(GNUSTEP_BASE_LIBRARY) +static BOOL +test_parse_unparse_binary_old(id object) +{ + NSPropertyListFormat format; + NSData *d; + id u; + + d = [NSPropertyListSerialization dataFromPropertyList: object + format: NSPropertyListGNUstepBinaryFormat errorDescription: 0]; + u = [NSPropertyListSerialization propertyListFromData: d + mutabilityOption: NSPropertyListImmutable + format: &format + errorDescription: 0]; + return [u isEqual: object]; +} +#endif + +int main() +{ + BOOL (*func)(id); + int i; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + for (i = 0; i < 5; i++) + { + switch (i) + { + case 0: + func = test_parse_unparse; + NSLog(@"test descriptions"); + break; + case 1: + func = test_parse_unparse_xml; + NSLog(@"test XML"); + break; + case 2: + func = test_parse_unparse_binary; + NSLog(@"test binary"); + break; + case 3: + func = test_parse_unparse_openstep; + NSLog(@"test OpenStep"); + break; + case 5: +#if defined(GNUSTEP_BASE_LIBRARY) + func = test_parse_unparse_binary_old; + NSLog(@"test GNUStep old binary"); +#else + func = 0; +#endif + break; + } + + if (func == 0) continue; + + PASS(func(@"ariosto"), + "We can generate a property list from a string"); + + PASS(func([NSArray array]), + "We can generate a property list from an empty array"); + + PASS(func([NSArray arrayWithObject: @"Palinuro"]), + "We can generate a property list from an array with a single object"); + + PASS(func([NSArray arrayWithObjects: + @"Palinuro", @"Enea", nil]), + "We can generate a property list from an array with two objects"); + + PASS(func([NSArray arrayWithObjects: + @"Palinuro", @"Enea", + @"Eurialo e Niso", nil]), + "We can generate a property list from " + "an array with three objects and \"s"); + + PASS(func([NSDictionary dictionary]), + "We can generate a property list from an empty dictionary"); + + PASS(func([NSDictionary dictionaryWithObject: @"Virgilio" + forKey: @"Autore"]), + "We can generate a property list from a " + "dictionary with a single key/value pair"); + + PASS(func([NSDictionary dictionaryWithObjectsAndKeys: + @"Virgilio", @"Autore", + @"Eneide", @"Titolo", nil]), + "We can generate a property list from a " + "dictionary with two key/value pairs"); + + PASS(func([NSDictionary dictionaryWithObjectsAndKeys: + @"Virgilio", @"Autore", + [NSArray arrayWithObject: @"Molte"], + @"Opere", nil]), + "We can generate a property list from a " + "dictionary with an array inside"); + + { + id object = [NSMutableDictionary dictionary]; + id objectA = [NSArray arrayWithObject: @"Ciao,"]; + id objectB = [NSArray arrayWithObject: objectA]; + id objectC = [NSDictionary dictionary]; + id objectD = [NSArray arrayWithObject: + [NSArray arrayWithObject: + [NSDictionary dictionaryWithObject: + [NSArray arrayWithObject: @"Ciao,"] + forKey: @"Ciao,"]]]; + [object setObject: objectA forKey: @"Utinam"]; + [object setObject: objectB forKey: @"bbb"]; + [object setObject: objectC forKey: @"ccc"]; + [object setObject: objectD forKey: @"Auri;"]; + PASS(func(object), + "We can generate a medium-size property list (1)"); + } + { + id object; + id objectA; + id objectA_A; + id objectA_B; + id objectB; + id objectB_A; + id objectB_A_A; + id objectB_A_B; + id objectB_B; + + /* objectA */ + objectA_A = [NSMutableDictionary dictionary]; + [objectA_A setObject: @"1 2 3 4 5 6 7 8 9 0" forKey: @"numeri"]; + [objectA_A setObject: @"A B C D E F G H I J" forKey: @"lettere"]; + + objectA_B = [NSMutableDictionary dictionary]; + [objectA_B setObject: @"3.1415296" forKey: @"PI greco"]; + [objectA_B setObject: @"0" forKey: @"zero"]; + [objectA_B setObject: @"1" forKey: @"uno"]; + + objectA = [NSMutableDictionary dictionary]; + [objectA setObject: objectA_A forKey: @"Informazioni Utili"]; + [objectA setObject: objectA_B forKey: @"Costanti Numeriche"]; + + /* objectB */ + objectB_A = [NSMutableDictionary dictionary]; + + objectB_A_A = [NSMutableArray array]; + [objectB_A_A addObject: @"1"]; + [objectB_A_A addObject: @"2"]; + [objectB_A_A addObject: @"3"]; + [objectB_A_A addObject: @"4"]; + [objectB_A_A addObject: @"5"]; + [objectB_A_A addObject: @"6"]; + [objectB_A_A addObject: @"7"]; + [objectB_A_A addObject: @"8"]; + [objectB_A_A addObject: @"9"]; + [objectB_A_A addObject: @"0"]; + if (func == test_parse_unparse_binary + || func == test_parse_unparse_xml) + { + [objectB_A_A addObject: [NSNumber numberWithInteger: 1]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 2]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 3]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 4]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 5]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 6]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 7]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 8]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 9]]; + [objectB_A_A addObject: [NSNumber numberWithInteger: 0]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 1]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 2]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 3]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 4]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 5]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 6]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 7]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 8]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 9]]; + [objectB_A_A addObject: [NSNumber numberWithShort: 0]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 1]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 2]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 3]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 4]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 5]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 6]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 7]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 8]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 9]]; + [objectB_A_A addObject: [NSNumber numberWithFloat: 0]]; + } + [objectB_A setObject: objectB_A_A forKey: @"numeri"]; + + objectB_A_B = [NSMutableArray array]; + [objectB_A_B addObject: @"A"]; + [objectB_A_B addObject: @"B"]; + [objectB_A_B addObject: @"C"]; + [objectB_A_B addObject: @"D"]; + [objectB_A_B addObject: @"E"]; + [objectB_A_B addObject: @"F"]; + [objectB_A_B addObject: @"G"]; + [objectB_A_B addObject: @"H"]; + [objectB_A_B addObject: @"I"]; + [objectB_A_B addObject: @"J"]; + [objectB_A setObject: objectB_A_B forKey: @"letterine"]; + + objectB_B = [NSMutableDictionary dictionary]; + [objectB_B setObject: @"3.1415296" forKey: @"PI greca"]; + [objectB_B setObject: @"0" forKey: @"el zero"]; + [objectB_B setObject: @"1" forKey: @"el uno"]; + + objectB = [NSMutableDictionary dictionary]; + [objectB setObject: objectB_A forKey: @"Informazioni Utili"]; + [objectB setObject: objectB_B forKey: @"Costanti Numeriche"]; + + /* object */ + object = [NSMutableDictionary dictionary]; + [object setObject: objectA forKey: @"Un dizionario"]; + [object setObject: objectB forKey: @"Un altro dizionario"]; + + PASS(func(object), + "We can generate a medium-size property list (2)"); + } + + PASS(func([NSData data]), + "We can generate a property list from an empty data"); + + PASS(func([@"Questo e` un test" dataUsingEncoding: 1]), + "We can generate a property list from very simple data"); + + PASS(func([[[NSProcessInfo processInfo] + globallyUniqueString] dataUsingEncoding: 7]), + "We can generate a property list from very simple data (2)"); + + PASS(func([NSMutableArray arrayWithObject: + [@"*()3\"#@Q``''" dataUsingEncoding: 1]]), + "We can generate a property list from an " + "array containing very simple data"); + + { + id object = [NSMutableArray array]; + + [object addObject: [@"*()3\"#@Q``''" dataUsingEncoding: 1]]; + [object addObject: @"nicola \" , ; <"]; + [object addObject: @""]; + [object addObject: @"nicola@"]; + [object addObject: @"nicola "]; + [object addObject: @"nicola="]; + [object addObject: [NSArray arrayWithObject: @"="]]; + [object addObject: [NSDictionary dictionary]]; + + PASS(func(object), + "We can generate a property list from an array containing various things"); + } + } + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/PropertyLists/xml.m b/Tests/base/PropertyLists/xml.m new file mode 100644 index 000000000..21018a62d --- /dev/null +++ b/Tests/base/PropertyLists/xml.m @@ -0,0 +1,358 @@ +/* Contributed by Michael Werle + */ +#import +#import "Testing.h" + +#define kTestCaseCount (6) + +typedef struct +{ + const char *plist; + size_t plistLength; + const char *text; + size_t textLength; +} TestCase; + + +static const TestCase sTestCases[kTestCaseCount]; + +static BOOL RunTestCase(const TestCase *testCase, unsigned idx); + + +int main (int argc, const char * argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + unsigned i; + + for (i = 0; i < kTestCaseCount; i++) + { + PASS((RunTestCase(&sTestCases[i], i + 1)), + "xml propertylist parse test %d", i) + } + + [pool release]; + return 0; +} + + +static BOOL +RunTestCase(const TestCase *testCase, unsigned idx) +{ + NSData *data = nil; + NSString *errorDesc = nil; + id plist = nil; + NSString *plistValue = nil; + NSString *expectedValue = nil; + + NS_DURING + { + data = [NSData dataWithBytes: testCase->plist + length: testCase->plistLength]; + if (data == nil) + { + NSLog(@"Test case %u FAILED: could not construct plist data.", idx); + return NO; + } + + plist = [NSPropertyListSerialization propertyListFromData: data + mutabilityOption: NSPropertyListImmutable + format: NULL + errorDescription: &errorDesc]; + + if (plist == nil) + { + NSLog(@"Test case %u FAILED: could not parse property list." + @" Error string: %@", idx, errorDesc); + return NO; + } + + if (![plist isKindOfClass: [NSArray class]] || [plist count] != 1) + { + NSLog(@"Test case %u FAILED: plist content is not array with " + @"one member.", idx); + return NO; + } + + plistValue = [plist objectAtIndex: 0]; + if (![plistValue isKindOfClass: [NSString class]]) + { + NSLog(@"Test case %u FAILED: plist content is not an " + @"array with one string.", idx); + return NO; + } + + data = [NSData dataWithBytes: testCase->text + length: testCase->textLength]; + if (data == nil) + { + NSLog(@"Test case %u FAILED: could not construct string data.", idx); + return NO; + } + + expectedValue = [[NSString alloc] initWithData: data + encoding: NSUTF8StringEncoding]; + [expectedValue autorelease]; + if (expectedValue == nil) + { + NSLog(@"Test case %u FAILED: could not construct string from data " + @"(must be UTF-8).", idx); + return NO; + } + + if ([plistValue compare: expectedValue options: 0] != NSOrderedSame) + { + NSLog(@"Test case %u FAILED: read string is wrong (expected \"%@\", " + @"got \"%@\").", idx, expectedValue, plistValue); + return NO; + } + } + NS_HANDLER + { + NSLog(@"Test case %u FAILED: exception thrown - %@ : %@", idx, + [localException name], [localException reason]); + return NO; + } + NS_ENDHANDLER + return YES; +} + + +/* Test data follows. Data entries are UTF-8 strings, expressed as byte + arrays to minimize risk of encoding problems. +*/ + +// Cyrillic string. +static const char sTestPlist1[] = +{ + 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20, + 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22, + 0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C, + 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73, + 0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F, + 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, + 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73, + 0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C, + 0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D, + 0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, + 0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0xD0, 0x93, 0xD0, 0xBE, 0xD0, 0xB2, 0xD0, + 0xBE, 0xD1, 0x80, 0xD0, 0xB8, 0xD1, 0x82, 0x20, 0xD1, 0x81, + 0xD1, 0x82, 0xD0, 0xB0, 0xD0, 0xBD, 0xD1, 0x86, 0xD0, 0xB8, + 0xD1, 0x8F, 0x20, 0x4C, 0x61, 0x65, 0x6E, 0x69, 0x6E, 0x2E, + 0x20, 0xD0, 0x9C, 0xD1, 0x8B, 0x20, 0xD0, 0xB7, 0xD0, 0xB0, + 0xD0, 0xB3, 0xD1, 0x80, 0xD1, 0x83, 0xD0, 0xB7, 0xD0, 0xB8, + 0xD0, 0xBB, 0xD0, 0xB8, 0x20, 0xD1, 0x81, 0xD1, 0x82, 0xD1, + 0x8B, 0xD0, 0xBA, 0xD0, 0xBE, 0xD0, 0xB2, 0xD0, 0xBE, 0xD1, + 0x87, 0xD0, 0xBD, 0xD1, 0x8B, 0xD0, 0xB5, 0x20, 0xD0, 0xB8, + 0xD0, 0xBD, 0xD1, 0x81, 0xD1, 0x82, 0xD1, 0x80, 0xD1, 0x83, + 0xD0, 0xBA, 0xD1, 0x86, 0xD0, 0xB8, 0xD0, 0xB8, 0x20, 0xD0, + 0xBD, 0xD0, 0xB0, 0x20, 0x3C, 0x2F, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, 0x72, 0x61, + 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x3E, 0x0A +}; +static const char sTestText1[] = +{ + 0xD0, 0x93, 0xD0, 0xBE, 0xD0, 0xB2, 0xD0, 0xBE, 0xD1, 0x80, + 0xD0, 0xB8, 0xD1, 0x82, 0x20, 0xD1, 0x81, 0xD1, 0x82, 0xD0, + 0xB0, 0xD0, 0xBD, 0xD1, 0x86, 0xD0, 0xB8, 0xD1, 0x8F, 0x20, + 0x4C, 0x61, 0x65, 0x6E, 0x69, 0x6E, 0x2E, 0x20, 0xD0, 0x9C, + 0xD1, 0x8B, 0x20, 0xD0, 0xB7, 0xD0, 0xB0, 0xD0, 0xB3, 0xD1, + 0x80, 0xD1, 0x83, 0xD0, 0xB7, 0xD0, 0xB8, 0xD0, 0xBB, 0xD0, + 0xB8, 0x20, 0xD1, 0x81, 0xD1, 0x82, 0xD1, 0x8B, 0xD0, 0xBA, + 0xD0, 0xBE, 0xD0, 0xB2, 0xD0, 0xBE, 0xD1, 0x87, 0xD0, 0xBD, + 0xD1, 0x8B, 0xD0, 0xB5, 0x20, 0xD0, 0xB8, 0xD0, 0xBD, 0xD1, + 0x81, 0xD1, 0x82, 0xD1, 0x80, 0xD1, 0x83, 0xD0, 0xBA, 0xD1, + 0x86, 0xD0, 0xB8, 0xD0, 0xB8, 0x20, 0xD0, 0xBD, 0xD0, 0xB0, + 0x20 +}; + + +// "A & B", using & +static const char sTestPlist2[] = +{ + 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20, + 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22, + 0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C, + 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73, + 0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F, + 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, + 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73, + 0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C, + 0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D, + 0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, + 0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0x41, 0x20, 0x26, 0x61, 0x6D, 0x70, 0x3B, + 0x20, 0x42, 0x3C, 0x2F, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, + 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3E, + 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, 0x73, 0x74, 0x3E, 0x0A +}; +static const char sTestText2[] = +{ + 0x41, 0x20, 0x26, 0x20, 0x42 +}; + + +// Euro symbol (U+20AC), literal +static const char sTestPlist3[] = +{ + 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20, + 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22, + 0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C, + 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73, + 0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F, + 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, + 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73, + 0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C, + 0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D, + 0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, + 0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0xE2, 0x82, 0xAC, 0x3C, 0x2F, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, + 0x73, 0x74, 0x3E, 0x0A +}; +static const char sTestText3[] = +{ + 0xE2, 0x82, 0xAC +}; + + +// Euro symbol (U+20AC), escaped as € +static const char sTestPlist4[] = +{ + 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20, + 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22, + 0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C, + 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73, + 0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F, + 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, + 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73, + 0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C, + 0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D, + 0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, + 0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0xE2, 0x82, 0xAC, 0x3C, 0x2F, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, + 0x73, 0x74, 0x3E, 0x0A +}; +static const char sTestText4[] = +{ + 0xE2, 0x82, 0xAC +}; + + +// Cruzeiro symbol (U+20A2), literal +static const char sTestPlist5[] = +{ + 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20, + 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22, + 0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C, + 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73, + 0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F, + 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, + 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73, + 0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C, + 0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D, + 0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, + 0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0xE2, 0x82, 0xA2, 0x3C, 0x2F, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, + 0x73, 0x74, 0x3E, 0x0A +}; +static const char sTestText5[] = +{ + 0xE2, 0x82, 0xA2 +}; + + +// "test " with trailing space +static const char sTestPlist6[] = +{ + 0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20, + 0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22, + 0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C, + 0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, + 0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73, + 0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F, + 0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A, + 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73, + 0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C, + 0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D, + 0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74, + 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, + 0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69, + 0x6E, 0x67, 0x3E, 0x74, 0x65, 0x73, 0x74, 0x20, 0x3C, 0x2F, + 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, + 0x61, 0x72, 0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, + 0x6C, 0x69, 0x73, 0x74, 0x3E, 0x0A +}; +static const char sTestText6[] = +{ + 0x74, 0x65, 0x73, 0x74, 0x20 +}; + + +static const TestCase sTestCases[kTestCaseCount] = +{ + { + sTestPlist1, sizeof sTestPlist1, + sTestText1, sizeof sTestText1 + }, + { + sTestPlist2, sizeof sTestPlist2, + sTestText2, sizeof sTestText2 + }, + { + sTestPlist3, sizeof sTestPlist3, + sTestText3, sizeof sTestText3 + }, + { + sTestPlist4, sizeof sTestPlist4, + sTestText4, sizeof sTestText4 + }, + { + sTestPlist5, sizeof sTestPlist5, + sTestText5, sizeof sTestText5 + }, + { + sTestPlist6, sizeof sTestPlist6, + sTestText6, sizeof sTestText6 + } +}; diff --git a/Tests/base/TestInfo b/Tests/base/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/Unicode/TestInfo b/Tests/base/Unicode/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/Unicode/test00.m b/Tests/base/Unicode/test00.m new file mode 100644 index 000000000..25869082a --- /dev/null +++ b/Tests/base/Unicode/test00.m @@ -0,0 +1,28 @@ +#import "Testing.h" +#import +#import +#import +#import + +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSString *bstr = @"\"Hello---@?pP-l\\U00a6&\\U00e4\\U00a6\""; + NSData *adat; + NSString *cstr; + + /* Prepare UTF-8 string from plist style c-string. */ + bstr = [bstr propertyList]; + adat = [bstr dataUsingEncoding: NSUTF8StringEncoding]; + + PASS((adat != nil && [adat isKindOfClass: [NSData class]]), + "We can convert from UTF8 Encoding"); + + cstr = [[NSString alloc] initWithData: adat encoding: NSUTF8StringEncoding]; + PASS((cstr != nil && [cstr isKindOfClass: [NSString class]]), + "We can convert to UTF8 Encoding"); + + [arp release]; arp = nil; + return 0; +} + diff --git a/Tests/base/coding/NSArray.1.data b/Tests/base/coding/NSArray.1.data new file mode 100644 index 000000000..1ab019d59 Binary files /dev/null and b/Tests/base/coding/NSArray.1.data differ diff --git a/Tests/base/coding/NSAttributedString.0.data b/Tests/base/coding/NSAttributedString.0.data new file mode 100644 index 000000000..d97e57dbf Binary files /dev/null and b/Tests/base/coding/NSAttributedString.0.data differ diff --git a/NSCharacterSets/newlineCharSet.dat b/Tests/base/coding/NSCharacterSet.0.data similarity index 96% rename from NSCharacterSets/newlineCharSet.dat rename to Tests/base/coding/NSCharacterSet.0.data index 4d4d311d3..f5ccea151 100644 Binary files a/NSCharacterSets/newlineCharSet.dat and b/Tests/base/coding/NSCharacterSet.0.data differ diff --git a/Tests/base/coding/NSData.0.data b/Tests/base/coding/NSData.0.data new file mode 100644 index 000000000..fe8b9f6b2 Binary files /dev/null and b/Tests/base/coding/NSData.0.data differ diff --git a/Tests/base/coding/NSDate.1.data b/Tests/base/coding/NSDate.1.data new file mode 100644 index 000000000..1ff70ae51 Binary files /dev/null and b/Tests/base/coding/NSDate.1.data differ diff --git a/Tests/base/coding/NSDateFormatter.0.data b/Tests/base/coding/NSDateFormatter.0.data new file mode 100644 index 000000000..e14ef22c8 Binary files /dev/null and b/Tests/base/coding/NSDateFormatter.0.data differ diff --git a/Tests/base/coding/NSDictionary.0.data b/Tests/base/coding/NSDictionary.0.data new file mode 100644 index 000000000..77dc12a87 Binary files /dev/null and b/Tests/base/coding/NSDictionary.0.data differ diff --git a/Tests/base/coding/NSException.0.data b/Tests/base/coding/NSException.0.data new file mode 100644 index 000000000..c1de7025c Binary files /dev/null and b/Tests/base/coding/NSException.0.data differ diff --git a/Tests/base/coding/NSMutableData.0.data b/Tests/base/coding/NSMutableData.0.data new file mode 100644 index 000000000..fe8b9f6b2 Binary files /dev/null and b/Tests/base/coding/NSMutableData.0.data differ diff --git a/Tests/base/coding/NSNotification.0.data b/Tests/base/coding/NSNotification.0.data new file mode 100644 index 000000000..78a9a4548 Binary files /dev/null and b/Tests/base/coding/NSNotification.0.data differ diff --git a/Tests/base/coding/NSNull.0.data b/Tests/base/coding/NSNull.0.data new file mode 100644 index 000000000..7c68c08be Binary files /dev/null and b/Tests/base/coding/NSNull.0.data differ diff --git a/Tests/base/coding/NSNumber.0.data b/Tests/base/coding/NSNumber.0.data new file mode 100644 index 000000000..98330cd7b Binary files /dev/null and b/Tests/base/coding/NSNumber.0.data differ diff --git a/Tests/base/coding/NSObject.0.data b/Tests/base/coding/NSObject.0.data new file mode 100644 index 000000000..3438e91fa Binary files /dev/null and b/Tests/base/coding/NSObject.0.data differ diff --git a/Tests/base/coding/NSSet.0.data b/Tests/base/coding/NSSet.0.data new file mode 100644 index 000000000..48b4bb325 Binary files /dev/null and b/Tests/base/coding/NSSet.0.data differ diff --git a/Tests/base/coding/NSString.1.data b/Tests/base/coding/NSString.1.data new file mode 100644 index 000000000..d0c0b1466 Binary files /dev/null and b/Tests/base/coding/NSString.1.data differ diff --git a/Tests/base/coding/NSTableView.3.data b/Tests/base/coding/NSTableView.3.data new file mode 100644 index 000000000..0b86af8e7 Binary files /dev/null and b/Tests/base/coding/NSTableView.3.data differ diff --git a/Tests/base/coding/NSURL.0.data b/Tests/base/coding/NSURL.0.data new file mode 100644 index 000000000..bc294d165 Binary files /dev/null and b/Tests/base/coding/NSURL.0.data differ diff --git a/Tests/base/coding/NSValue.3.data b/Tests/base/coding/NSValue.3.data new file mode 100644 index 000000000..7975537d1 Binary files /dev/null and b/Tests/base/coding/NSValue.3.data differ diff --git a/Tests/base/coding/TestInfo b/Tests/base/coding/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/coding/basictypes.m b/Tests/base/coding/basictypes.m new file mode 100644 index 000000000..3df826257 --- /dev/null +++ b/Tests/base/coding/basictypes.m @@ -0,0 +1,218 @@ +#include "Testing.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +@interface Model : NSObject +{ + int cint; + unsigned int cuint; + NSInteger nsint; + NSUInteger nsuint; +} +@end +@implementation Model +-(void)setValues +{ + cint = -1234567890; + cuint = 1234567890; + nsint = -1234567890; + nsuint = 1234567890; +} +- (BOOL)testCInt:(Model *)o +{ + return (cint == o->cint); +} +- (BOOL)testCUInt:(Model *)o +{ + return (cuint == o->cuint); +} +- (BOOL)testNSInteger:(Model *)o +{ + return (nsint == o->nsint); +} +- (BOOL)testNSUInteger:(Model *)o +{ + return (nsuint == o->nsuint); +} + +-(void)encodeWithCoder:(NSCoder *)coder +{ + [coder encodeValueOfObjCType:@encode(int) at:&cint]; + [coder encodeValueOfObjCType:@encode(unsigned int) at:&cuint]; + [coder encodeValueOfObjCType:@encode(NSInteger) at:&nsint]; + [coder encodeValueOfObjCType:@encode(NSUInteger) at:&nsuint]; +} +-(id)initWithCoder:(NSCoder *)coder +{ + /* encoded as int - decoded as NSInteger. */ + [coder decodeValueOfObjCType: @encode(NSInteger) at: &nsint]; + /* encoded as unsinged int - decoded as NSUInteger. */ + [coder decodeValueOfObjCType: @encode(NSUInteger) at: &nsuint]; + /* encoded as NSInteger - decoded as int. */ + [coder decodeValueOfObjCType: @encode(int) at: &cint]; + /* encoded as NSUInteger - decoded as unsigned int. */ + [coder decodeValueOfObjCType: @encode(unsigned int) at: &cuint]; + return self; +} +@end + + +static NSFileManager *fm; +NSString *str = @"Do not taunt happy fun ball"; +#define TEST_DECL(testType,testName) \ +void testWriteBasicType_##testName (char *typeName, testType *toEncode) \ +{ \ + NSData *data; \ + NSMutableData *mData; \ + NSString *fileName; \ + long typeSize = sizeof(testType); \ + fileName = [[NSString stringWithFormat:@"%s-%li.type",typeName,typeSize] retain]; \ + if (![fm isReadableFileAtPath:fileName]) \ + { \ + NSArchiver *arch; \ + mData = [[NSMutableData alloc] init]; \ + arch = [[NSArchiver alloc] initForWritingWithMutableData: mData]; \ + [arch encodeValueOfObjCType:@encode(testType) at:toEncode]; \ + [arch encodeObject:str]; \ + [mData writeToFile:fileName atomically:YES]; \ + data = [NSData dataWithContentsOfFile:fileName]; \ + PASS([data isEqual:mData], \ + "can write %s of size %li", typeName, typeSize); \ + [fileName release]; \ + [mData release]; \ + [arch release]; \ + } \ +} \ +void testReadBasicType_##testName (char *pre, testType *expect, testType *toDecode) \ +{ \ + NSData *data; \ + NSUnarchiver *unArch; \ + NSString *str2; \ + NSArray *encodedFiles; \ + NSString *prefix = [[NSString stringWithCString:pre] retain]; \ + unsigned int i, c; \ + encodedFiles = [[NSBundle bundleWithPath: [fm currentDirectoryPath]] \ + pathsForResourcesOfType:@"type" inDirectory:nil]; \ + for (i = 0, c = [encodedFiles count]; i < c; i++) \ + { \ + NSString *fileName = [encodedFiles objectAtIndex:i]; \ + if ([[fileName lastPathComponent] hasPrefix:prefix]) \ + { \ + data = [NSData dataWithContentsOfFile:fileName]; \ + unArch = [[NSUnarchiver alloc] initForReadingWithData:data]; \ + NS_DURING \ + [unArch decodeValueOfObjCType:@encode(testType) at:toDecode]; \ + NS_HANDLER \ + NSLog(@"%@ %@", [localException name], [localException reason]); \ + PASS(0, "can unarchive %s from %s", pre, [fileName cString]); \ + NS_ENDHANDLER \ + str2 = [unArch decodeObject]; \ + PASS((VAL_TEST(*expect,*toDecode) && [str isEqual:str2]), \ + "can unarchive %s from %s", pre, [fileName cString]); \ + } \ + } \ +} + +#define VAL_TEST(testX,testY) testX == testY +TEST_DECL(int, int); +TEST_DECL(unsigned int, uint); +TEST_DECL(long, long); +TEST_DECL(unsigned long, ulong); +TEST_DECL(long long, llong); +TEST_DECL(unsigned long long, ullong); +TEST_DECL(signed char, schar); +TEST_DECL(unsigned char, uchar); +TEST_DECL(short, short); +TEST_DECL(unsigned short, ushort); +#undef VAL_TEST +#define VAL_TEST(testx, testy) EQ(testx,testy) +TEST_DECL(float, float); +TEST_DECL(double, double); + +int main() +{ + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + id obj1, obj2; + NSData *data; + int i = 2147483647; + int i2; + unsigned int ui = 4294967295U; + unsigned int ui2; + long l = 2147483647L; + long l2; + long long ll = 9223372036854775807LL; + long long ll2; + unsigned long long ull = 18446744073709551615ULL; + unsigned long long ull2; + unsigned long ul = 4294967295UL; + unsigned long ul2; + signed char c = 127; + signed char c2; + unsigned char uc = 255; + unsigned char uc2; + short s = 32767; + short s2; + unsigned short us = 65535; + unsigned short us2; + float f = 3.40282347e+38F; + float f2; + double d = 1.7976931348623157e+308; + double d2; + + fm = [NSFileManager defaultManager]; + + testWriteBasicType_int("int", &i); + testReadBasicType_int("int", &i, &i2); + + testWriteBasicType_uint("uint", &ui); + testReadBasicType_uint("uint", &ui, &ui2); + + testWriteBasicType_long("long", &l); + testReadBasicType_long("long", &l, &l2); + + testWriteBasicType_ulong("ulong", &ul); + testReadBasicType_ulong("ulong", &ul, &ul2); + + testWriteBasicType_llong("llong", &ll); + testReadBasicType_llong("llong", &ll, &ll2); + + testWriteBasicType_ullong("ullong", &ull); + testReadBasicType_ullong("ullong", &ull, &ull2); + + testWriteBasicType_schar("schar", &c); + testReadBasicType_schar("schar", &c, &c2); + + testWriteBasicType_uchar("uchar", &uc); + testReadBasicType_uchar("uchar", &uc, &uc2); + + testWriteBasicType_short("short", &s); + testReadBasicType_short("short", &s, &s2); + + testWriteBasicType_float("float", &f); + testReadBasicType_float("float", &f, &f2); + + testWriteBasicType_double("double", &d); + testReadBasicType_double("double", &d, &d2); + + testWriteBasicType_ushort("ushort", &us); + testReadBasicType_ushort("ushort", &us, &us2); + + obj1 = [Model new]; + [obj1 setValues]; + data = [NSArchiver archivedDataWithRootObject: obj1]; + obj2 = [NSUnarchiver unarchiveObjectWithData: data]; + PASS([obj1 testCInt:obj2], "archiving as int - dearchiving as NSInteger"); + PASS([obj1 testCUInt:obj2], "archiving as unsigned int - dearchiving as NSUInteger"); + PASS([obj1 testNSInteger:obj2], "archiving as NSInteger - dearchiving as int"); + PASS([obj1 testNSUInteger:obj2], "archiving as NSUInteger - dearchiving as unsigned int"); + + [pool release]; pool = nil; + return 0; +} diff --git a/Tests/base/coding/decoding.m b/Tests/base/coding/decoding.m new file mode 100644 index 000000000..092cd98b6 --- /dev/null +++ b/Tests/base/coding/decoding.m @@ -0,0 +1,264 @@ +/* +copyright 2004 Alexander Malmberg +*/ + +#include "Testing.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +@interface NSObject (Equality) +- (BOOL) testEquality: (id)other; +@end + +@interface NSObject (DecodingTests) ++ (NSObject*) createTestInstance; ++ (BOOL) verifyTestInstance: (NSObject *)instance + ofVersion: (int)version; +- (BOOL) testEquality; +@end + +@implementation NSObject (DecodingTests) ++ (NSObject *) createTestInstance +{ + if (self == [NSException class]) + { + return [[NSException alloc] initWithName: @"Test" + reason: @"Testing" + userInfo: nil]; + } + else + { + return [[self alloc] init]; + } +} + ++ (BOOL) verifyTestInstance: (NSObject *)instance + ofVersion: (int)version +{ + id o; + + if (instance == nil) return NO; + o = [self createTestInstance]; + if (YES == [o respondsToSelector: @selector(testEquality:)]) + return [o testEquality: instance]; + if (NO == [instance testEquality]) return YES; + return [o isEqual: instance]; +} + +- (BOOL) testEquality +{ + static IMP impNSObject = 0; + /* By default, assume that every class that overrides NSObject's + isEqual: implementation can compare archived instances. + subclasses for which this doesn't hold can simply override this + method in a category and return a constant YES/NO. */ + + if (!impNSObject) + { + impNSObject = [NSObject instanceMethodForSelector:@selector(isEqual:)]; + } + return [self methodForSelector:@selector(isEqual:)] == impNSObject + ? NO : YES; +} +@end + +@implementation NSCharacterSet (DecodingTests) ++ (NSObject *) createTestInstance +{ + return [[self characterSetWithCharactersInString: @"qwertzuiop"] retain]; +} +@end + +@implementation NSValue (DecodingTests) ++ (NSObject *) createTestInstance +{ + return [[self valueWithSize: NSMakeSize(1.1, 1.2)] retain]; +} +- (BOOL) testEquality: (id)other +{ + if (strcmp([self objCType], @encode(NSSize)) == 0) + { + NSSize mSize = [self sizeValue]; + NSSize oSize = [other sizeValue]; + + if (EQ(mSize.height, oSize.height) && EQ(mSize.width, oSize.width)) + return YES; + return NO; + } + return [self isEqual: other]; +} +@end + +@implementation NSNumber (DecodingTests) ++ (NSObject *) createTestInstance +{ + return [[self numberWithInt: 1] retain]; +} +@end + +@implementation NSData (DecodingTests) ++ (NSObject *) createTestInstance +{ + NSString *source = @"We need constant data"; + NSData *data = [source dataUsingEncoding: NSUnicodeStringEncoding]; + + if (NSHostByteOrder() == NS_BigEndian) + { + NSMutableData *m = [data mutableCopy]; + uint8_t *p = (uint8_t*)[m mutableBytes]; + uint8_t *e = p + [m length]; + + while (p < e) + { + uint8_t tmp = p[0]; + + p[0] = p[1]; + p[1] = tmp; + p += 2; + } + return m; + } + else + { + return [data retain]; + } +} +@end + +@implementation NSDate (DecodingTests) ++ (NSObject *) createTestInstance +{ + return [[NSDate dateWithTimeIntervalSince1970: 4294967296.0] retain]; +} +@end + +@implementation NSURL (DecodingTests) ++ (NSObject *) createTestInstance +{ + return [[self alloc] initWithString: @"http://www.gnustep.org/"]; +} +@end + + +/* +If set, we write out new .data files for the current versions for classes +that don't have them. +*/ +BOOL update; + +void test(Class class) +{ + NS_DURING + { + /* + In order to catch decoders that don't consume all the data that they + should, we decode/encode an array that includes the object and a string. + We verify that the string was correctly decoded, although any errors will + likely be caught by crashes in the unarchiver. + */ + NSString *sentinel = @"quux!"; + + int v = [class version]; + NSObject *instance; + NSArray *decodedInstance; + NSData *d; + NSString *filename; + + instance = [class createTestInstance]; + + d = [NSArchiver archivedDataWithRootObject: + [NSArray arrayWithObjects: instance, sentinel, nil]]; + decodedInstance = [NSUnarchiver unarchiveObjectWithData: d]; + + NSCAssert([sentinel isEqual: [decodedInstance objectAtIndex: 1]], + NSInternalInconsistencyException); + + PASS([class verifyTestInstance: [decodedInstance objectAtIndex: 0] + ofVersion: v], "decoding current version of class %s", POBJECT(class)); + + for (; v >= 0; v--) + { + filename = [NSString stringWithFormat: @"%@.%i.data", class, v]; + d = [NSData dataWithContentsOfFile: filename]; + if (!d) + { + if (v == [class version]) + { + if (!update) + PASS(0, "%s has reference data for the current version", + POBJECT(class)) + else + [NSArchiver archiveRootObject: + [NSArray arrayWithObjects: instance, sentinel, nil] + toFile: filename]; + } + continue; + } + + decodedInstance = [NSUnarchiver unarchiveObjectWithData: d]; + NSCAssert([sentinel isEqual: [decodedInstance objectAtIndex: 1]], + NSInternalInconsistencyException); + PASS([class verifyTestInstance: [decodedInstance objectAtIndex: 0] + ofVersion: v], "decoding version %i of class %s", + v, POBJECT(class)); + } + } + NS_HANDLER + { + PASS(0, "decoding class %s: %s", + POBJECT(class), POBJECT(localException)); + } + NS_ENDHANDLER +} + +int main(int argc, char **argv) +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + update = argc == 2 && !strcmp(argv[1], "--update"); + +#define T(c) test([c class]); + T(NSArray) + T(NSAttributedString) + T(NSCharacterSet) + T(NSData) + T(NSMutableData) + T(NSDate) + T(NSDateFormatter) + T(NSDictionary) + T(NSException) + T(NSNotification) + T(NSNull) + T(NSObject) + T(NSSet) + T(NSString) + T(NSURL) + T(NSValue) + T(NSNumber) + + [arp release]; arp = nil; + + return 0; +} + diff --git a/Tests/base/coding/double-8.type b/Tests/base/coding/double-8.type new file mode 100644 index 000000000..9623fc75c Binary files /dev/null and b/Tests/base/coding/double-8.type differ diff --git a/Tests/base/coding/float-4.type b/Tests/base/coding/float-4.type new file mode 100644 index 000000000..418e1f8af Binary files /dev/null and b/Tests/base/coding/float-4.type differ diff --git a/Tests/base/coding/int-4.type b/Tests/base/coding/int-4.type new file mode 100644 index 000000000..d5e553094 Binary files /dev/null and b/Tests/base/coding/int-4.type differ diff --git a/Tests/base/coding/llong-8.type b/Tests/base/coding/llong-8.type new file mode 100644 index 000000000..d29b0874b Binary files /dev/null and b/Tests/base/coding/llong-8.type differ diff --git a/Tests/base/coding/long-4.type b/Tests/base/coding/long-4.type new file mode 100644 index 000000000..74997a342 Binary files /dev/null and b/Tests/base/coding/long-4.type differ diff --git a/Tests/base/coding/schar-1.type b/Tests/base/coding/schar-1.type new file mode 100644 index 000000000..06767dff0 Binary files /dev/null and b/Tests/base/coding/schar-1.type differ diff --git a/Tests/base/coding/short-2.type b/Tests/base/coding/short-2.type new file mode 100644 index 000000000..43dd823f3 Binary files /dev/null and b/Tests/base/coding/short-2.type differ diff --git a/Tests/base/coding/uchar-1.type b/Tests/base/coding/uchar-1.type new file mode 100644 index 000000000..8d55b81df Binary files /dev/null and b/Tests/base/coding/uchar-1.type differ diff --git a/Tests/base/coding/uint-4.type b/Tests/base/coding/uint-4.type new file mode 100644 index 000000000..e52883098 Binary files /dev/null and b/Tests/base/coding/uint-4.type differ diff --git a/Tests/base/coding/ullong-8.type b/Tests/base/coding/ullong-8.type new file mode 100644 index 000000000..88c25ff93 Binary files /dev/null and b/Tests/base/coding/ullong-8.type differ diff --git a/Tests/base/coding/ulong-4.type b/Tests/base/coding/ulong-4.type new file mode 100644 index 000000000..a54ee85a4 Binary files /dev/null and b/Tests/base/coding/ulong-4.type differ diff --git a/Tests/base/coding/ushort-2.type b/Tests/base/coding/ushort-2.type new file mode 100644 index 000000000..cf67a193f Binary files /dev/null and b/Tests/base/coding/ushort-2.type differ diff --git a/Tests/base/headers/GSLock.m b/Tests/base/headers/GSLock.m new file mode 100644 index 000000000..a9a516bb8 --- /dev/null +++ b/Tests/base/headers/GSLock.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of GNUstepBase/GSLock.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/GSMime.m b/Tests/base/headers/GSMime.m new file mode 100644 index 000000000..b1ee92279 --- /dev/null +++ b/Tests/base/headers/GSMime.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of GNUstepBase/GSMime.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/GSObjCRuntime.m b/Tests/base/headers/GSObjCRuntime.m new file mode 100644 index 000000000..19f2c7225 --- /dev/null +++ b/Tests/base/headers/GSObjCRuntime.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of GNUstepBase/GSObjCRuntime.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/GSXML.m b/Tests/base/headers/GSXML.m new file mode 100644 index 000000000..43593b10e --- /dev/null +++ b/Tests/base/headers/GSXML.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of GNUstepBase/GSXML.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSArchiver.m b/Tests/base/headers/NSArchiver.m new file mode 100644 index 000000000..2db65d1e8 --- /dev/null +++ b/Tests/base/headers/NSArchiver.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSArchiver.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSArray.m b/Tests/base/headers/NSArray.m new file mode 100644 index 000000000..7f3b7c67f --- /dev/null +++ b/Tests/base/headers/NSArray.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSArray.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSAttributedString.m b/Tests/base/headers/NSAttributedString.m new file mode 100644 index 000000000..7768d8712 --- /dev/null +++ b/Tests/base/headers/NSAttributedString.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSAttributedString.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSAutoreleasePool.m b/Tests/base/headers/NSAutoreleasePool.m new file mode 100644 index 000000000..5b5b415fd --- /dev/null +++ b/Tests/base/headers/NSAutoreleasePool.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSAutoreleasePool.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSBundle.m b/Tests/base/headers/NSBundle.m new file mode 100644 index 000000000..5975ede55 --- /dev/null +++ b/Tests/base/headers/NSBundle.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSBundle.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSByteOrder.m b/Tests/base/headers/NSByteOrder.m new file mode 100644 index 000000000..d5df85c25 --- /dev/null +++ b/Tests/base/headers/NSByteOrder.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSByteOrder.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSCalendarDate.m b/Tests/base/headers/NSCalendarDate.m new file mode 100644 index 000000000..3486a975f --- /dev/null +++ b/Tests/base/headers/NSCalendarDate.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSCalendarDate.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSCharacterSet.m b/Tests/base/headers/NSCharacterSet.m new file mode 100644 index 000000000..a58d571e5 --- /dev/null +++ b/Tests/base/headers/NSCharacterSet.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSCharacterSet.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSClassDescription.m b/Tests/base/headers/NSClassDescription.m new file mode 100644 index 000000000..91c8018c1 --- /dev/null +++ b/Tests/base/headers/NSClassDescription.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSClassDescription.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSCoder.m b/Tests/base/headers/NSCoder.m new file mode 100644 index 000000000..8e02622f8 --- /dev/null +++ b/Tests/base/headers/NSCoder.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSCoder.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSComparisonPredicate.m b/Tests/base/headers/NSComparisonPredicate.m new file mode 100644 index 000000000..7ab1b1add --- /dev/null +++ b/Tests/base/headers/NSComparisonPredicate.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSComparisonPredicate.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSCompoundPredicate.m b/Tests/base/headers/NSCompoundPredicate.m new file mode 100644 index 000000000..4f796ce4e --- /dev/null +++ b/Tests/base/headers/NSCompoundPredicate.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSCompoundPredicate.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSConnection.m b/Tests/base/headers/NSConnection.m new file mode 100644 index 000000000..2c45faf52 --- /dev/null +++ b/Tests/base/headers/NSConnection.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSConnection.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSData.m b/Tests/base/headers/NSData.m new file mode 100644 index 000000000..2316fbf5e --- /dev/null +++ b/Tests/base/headers/NSData.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSData.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDate.m b/Tests/base/headers/NSDate.m new file mode 100644 index 000000000..ee28b2cc9 --- /dev/null +++ b/Tests/base/headers/NSDate.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDate.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDateFormatter.m b/Tests/base/headers/NSDateFormatter.m new file mode 100644 index 000000000..48e1218b7 --- /dev/null +++ b/Tests/base/headers/NSDateFormatter.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDateFormatter.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDebug.m b/Tests/base/headers/NSDebug.m new file mode 100644 index 000000000..8f53fe3d9 --- /dev/null +++ b/Tests/base/headers/NSDebug.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDebug.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDecimal.m b/Tests/base/headers/NSDecimal.m new file mode 100644 index 000000000..05e777a0a --- /dev/null +++ b/Tests/base/headers/NSDecimal.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDecimal.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDecimalNumber.m b/Tests/base/headers/NSDecimalNumber.m new file mode 100644 index 000000000..d31f056df --- /dev/null +++ b/Tests/base/headers/NSDecimalNumber.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDecimalNumber.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDictionary.m b/Tests/base/headers/NSDictionary.m new file mode 100644 index 000000000..b9b842919 --- /dev/null +++ b/Tests/base/headers/NSDictionary.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDictionary.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDistantObject.m b/Tests/base/headers/NSDistantObject.m new file mode 100644 index 000000000..3707c5f6f --- /dev/null +++ b/Tests/base/headers/NSDistantObject.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDistantObject.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDistributedLock.m b/Tests/base/headers/NSDistributedLock.m new file mode 100644 index 000000000..ba6e72b32 --- /dev/null +++ b/Tests/base/headers/NSDistributedLock.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDistributedLock.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSDistributedNotificationCenter.m b/Tests/base/headers/NSDistributedNotificationCenter.m new file mode 100644 index 000000000..13d94ff20 --- /dev/null +++ b/Tests/base/headers/NSDistributedNotificationCenter.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSDistributedNotificationCenter.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSEnumerator.m b/Tests/base/headers/NSEnumerator.m new file mode 100644 index 000000000..16fb41d86 --- /dev/null +++ b/Tests/base/headers/NSEnumerator.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSEnumerator.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSError.m b/Tests/base/headers/NSError.m new file mode 100644 index 000000000..ff3dd12de --- /dev/null +++ b/Tests/base/headers/NSError.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSError.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSException.m b/Tests/base/headers/NSException.m new file mode 100644 index 000000000..fc2bec447 --- /dev/null +++ b/Tests/base/headers/NSException.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSException.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSExpression.m b/Tests/base/headers/NSExpression.m new file mode 100644 index 000000000..8228cacdb --- /dev/null +++ b/Tests/base/headers/NSExpression.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSExpression.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSFileHandle.m b/Tests/base/headers/NSFileHandle.m new file mode 100644 index 000000000..caffdd826 --- /dev/null +++ b/Tests/base/headers/NSFileHandle.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSFileHandle.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSFileManager.m b/Tests/base/headers/NSFileManager.m new file mode 100644 index 000000000..1cb533532 --- /dev/null +++ b/Tests/base/headers/NSFileManager.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSFileManager.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSFormatter.m b/Tests/base/headers/NSFormatter.m new file mode 100644 index 000000000..3d0d7ef69 --- /dev/null +++ b/Tests/base/headers/NSFormatter.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSFormatter.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSGeometry.m b/Tests/base/headers/NSGeometry.m new file mode 100644 index 000000000..ef2ca4e7c --- /dev/null +++ b/Tests/base/headers/NSGeometry.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSGeometry.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSHTTPCookie.m b/Tests/base/headers/NSHTTPCookie.m new file mode 100644 index 000000000..ad8c78b08 --- /dev/null +++ b/Tests/base/headers/NSHTTPCookie.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSHTTPCookie.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSHTTPCookieStorage.m b/Tests/base/headers/NSHTTPCookieStorage.m new file mode 100644 index 000000000..12f51ff4a --- /dev/null +++ b/Tests/base/headers/NSHTTPCookieStorage.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSHTTPCookieStorage.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSHashTable.m b/Tests/base/headers/NSHashTable.m new file mode 100644 index 000000000..0a5dd3b07 --- /dev/null +++ b/Tests/base/headers/NSHashTable.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSHashTable.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSHost.m b/Tests/base/headers/NSHost.m new file mode 100644 index 000000000..98e9fa87d --- /dev/null +++ b/Tests/base/headers/NSHost.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSHost.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSIndexPath.m b/Tests/base/headers/NSIndexPath.m new file mode 100644 index 000000000..7dda5ac35 --- /dev/null +++ b/Tests/base/headers/NSIndexPath.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSIndexPath.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSIndexSet.m b/Tests/base/headers/NSIndexSet.m new file mode 100644 index 000000000..437e12459 --- /dev/null +++ b/Tests/base/headers/NSIndexSet.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSIndexSet.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSInvocation.m b/Tests/base/headers/NSInvocation.m new file mode 100644 index 000000000..1f3566f09 --- /dev/null +++ b/Tests/base/headers/NSInvocation.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSInvocation.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSKeyValueCoding.m b/Tests/base/headers/NSKeyValueCoding.m new file mode 100644 index 000000000..8ff06a871 --- /dev/null +++ b/Tests/base/headers/NSKeyValueCoding.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSKeyValueCoding.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSKeyValueObserving.m b/Tests/base/headers/NSKeyValueObserving.m new file mode 100644 index 000000000..8c2d72459 --- /dev/null +++ b/Tests/base/headers/NSKeyValueObserving.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSKeyValueObserving.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSKeyedArchiver.m b/Tests/base/headers/NSKeyedArchiver.m new file mode 100644 index 000000000..df9e05e97 --- /dev/null +++ b/Tests/base/headers/NSKeyedArchiver.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSKeyedArchiver.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSLock.m b/Tests/base/headers/NSLock.m new file mode 100644 index 000000000..b8ffc9b57 --- /dev/null +++ b/Tests/base/headers/NSLock.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSLock.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSMapTable.m b/Tests/base/headers/NSMapTable.m new file mode 100644 index 000000000..5aff4c51e --- /dev/null +++ b/Tests/base/headers/NSMapTable.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSMapTable.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSMethodSignature.m b/Tests/base/headers/NSMethodSignature.m new file mode 100644 index 000000000..e074c7019 --- /dev/null +++ b/Tests/base/headers/NSMethodSignature.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSMethodSignature.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSNotification.m b/Tests/base/headers/NSNotification.m new file mode 100644 index 000000000..5556b24ef --- /dev/null +++ b/Tests/base/headers/NSNotification.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSNotification.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSNotificationQueue.m b/Tests/base/headers/NSNotificationQueue.m new file mode 100644 index 000000000..3cbdae658 --- /dev/null +++ b/Tests/base/headers/NSNotificationQueue.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSNotificationQueue.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSNull.m b/Tests/base/headers/NSNull.m new file mode 100644 index 000000000..4ed1aac40 --- /dev/null +++ b/Tests/base/headers/NSNull.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSNull.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSNumberFormatter.m b/Tests/base/headers/NSNumberFormatter.m new file mode 100644 index 000000000..610c7b131 --- /dev/null +++ b/Tests/base/headers/NSNumberFormatter.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSNumberFormatter.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSObjCRuntime.m b/Tests/base/headers/NSObjCRuntime.m new file mode 100644 index 000000000..495536a5c --- /dev/null +++ b/Tests/base/headers/NSObjCRuntime.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSObjCRuntime.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSObject.m b/Tests/base/headers/NSObject.m new file mode 100644 index 000000000..63f90bc9d --- /dev/null +++ b/Tests/base/headers/NSObject.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSObject.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPathUtilities.m b/Tests/base/headers/NSPathUtilities.m new file mode 100644 index 000000000..2e0462f5d --- /dev/null +++ b/Tests/base/headers/NSPathUtilities.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPathUtilities.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPort.m b/Tests/base/headers/NSPort.m new file mode 100644 index 000000000..12b559fa8 --- /dev/null +++ b/Tests/base/headers/NSPort.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPort.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPortCoder.m b/Tests/base/headers/NSPortCoder.m new file mode 100644 index 000000000..d2cba65b0 --- /dev/null +++ b/Tests/base/headers/NSPortCoder.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPortCoder.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPortMessage.m b/Tests/base/headers/NSPortMessage.m new file mode 100644 index 000000000..999e91836 --- /dev/null +++ b/Tests/base/headers/NSPortMessage.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPortMessage.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPortNameServer.m b/Tests/base/headers/NSPortNameServer.m new file mode 100644 index 000000000..c9a36e566 --- /dev/null +++ b/Tests/base/headers/NSPortNameServer.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPortNameServer.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPredicate.m b/Tests/base/headers/NSPredicate.m new file mode 100644 index 000000000..d934d20f3 --- /dev/null +++ b/Tests/base/headers/NSPredicate.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPredicate.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSProcessInfo.m b/Tests/base/headers/NSProcessInfo.m new file mode 100644 index 000000000..f96275627 --- /dev/null +++ b/Tests/base/headers/NSProcessInfo.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSProcessInfo.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSPropertyList.m b/Tests/base/headers/NSPropertyList.m new file mode 100644 index 000000000..4716f5394 --- /dev/null +++ b/Tests/base/headers/NSPropertyList.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSPropertyList.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSProtocolChecker.m b/Tests/base/headers/NSProtocolChecker.m new file mode 100644 index 000000000..6993b549e --- /dev/null +++ b/Tests/base/headers/NSProtocolChecker.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSProtocolChecker.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSProxy.m b/Tests/base/headers/NSProxy.m new file mode 100644 index 000000000..1397604ed --- /dev/null +++ b/Tests/base/headers/NSProxy.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSProxy.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSRange.m b/Tests/base/headers/NSRange.m new file mode 100644 index 000000000..6a432f9da --- /dev/null +++ b/Tests/base/headers/NSRange.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSRange.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSRunLoop.m b/Tests/base/headers/NSRunLoop.m new file mode 100644 index 000000000..b09c1ed71 --- /dev/null +++ b/Tests/base/headers/NSRunLoop.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSRunLoop.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSScanner.m b/Tests/base/headers/NSScanner.m new file mode 100644 index 000000000..45fd10c66 --- /dev/null +++ b/Tests/base/headers/NSScanner.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSScanner.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSSerialization.m b/Tests/base/headers/NSSerialization.m new file mode 100644 index 000000000..d178b0782 --- /dev/null +++ b/Tests/base/headers/NSSerialization.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSSerialization.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSSet.m b/Tests/base/headers/NSSet.m new file mode 100644 index 000000000..e5b188006 --- /dev/null +++ b/Tests/base/headers/NSSet.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSSet.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSSortDescriptor.m b/Tests/base/headers/NSSortDescriptor.m new file mode 100644 index 000000000..f265d84bf --- /dev/null +++ b/Tests/base/headers/NSSortDescriptor.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSSortDescriptor.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSStream.m b/Tests/base/headers/NSStream.m new file mode 100644 index 000000000..1e7df7e2f --- /dev/null +++ b/Tests/base/headers/NSStream.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSStream.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSString.m b/Tests/base/headers/NSString.m new file mode 100644 index 000000000..cfbdfba16 --- /dev/null +++ b/Tests/base/headers/NSString.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSString.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSTask.m b/Tests/base/headers/NSTask.m new file mode 100644 index 000000000..4804145c5 --- /dev/null +++ b/Tests/base/headers/NSTask.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSTask.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSThread.m b/Tests/base/headers/NSThread.m new file mode 100644 index 000000000..ce5a57c0b --- /dev/null +++ b/Tests/base/headers/NSThread.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSThread.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSTimeZone.m b/Tests/base/headers/NSTimeZone.m new file mode 100644 index 000000000..44fec8e0c --- /dev/null +++ b/Tests/base/headers/NSTimeZone.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSTimeZone.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSTimer.m b/Tests/base/headers/NSTimer.m new file mode 100644 index 000000000..6b16626e3 --- /dev/null +++ b/Tests/base/headers/NSTimer.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSTimer.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURL.m b/Tests/base/headers/NSURL.m new file mode 100644 index 000000000..8e1ac8556 --- /dev/null +++ b/Tests/base/headers/NSURL.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURL.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLAuthenticationChallenge.m b/Tests/base/headers/NSURLAuthenticationChallenge.m new file mode 100644 index 000000000..377c08145 --- /dev/null +++ b/Tests/base/headers/NSURLAuthenticationChallenge.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLAuthenticationChallenge.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLCache.m b/Tests/base/headers/NSURLCache.m new file mode 100644 index 000000000..b3ffc9017 --- /dev/null +++ b/Tests/base/headers/NSURLCache.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLCache.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLConnection.m b/Tests/base/headers/NSURLConnection.m new file mode 100644 index 000000000..a9a69790a --- /dev/null +++ b/Tests/base/headers/NSURLConnection.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLConnection.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLCredential.m b/Tests/base/headers/NSURLCredential.m new file mode 100644 index 000000000..f56d1d380 --- /dev/null +++ b/Tests/base/headers/NSURLCredential.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLCredential.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLCredentialStorage.m b/Tests/base/headers/NSURLCredentialStorage.m new file mode 100644 index 000000000..ffcca56c2 --- /dev/null +++ b/Tests/base/headers/NSURLCredentialStorage.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLCredentialStorage.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLDownload.m b/Tests/base/headers/NSURLDownload.m new file mode 100644 index 000000000..494165cc2 --- /dev/null +++ b/Tests/base/headers/NSURLDownload.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLDownload.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLError.m b/Tests/base/headers/NSURLError.m new file mode 100644 index 000000000..e3230e963 --- /dev/null +++ b/Tests/base/headers/NSURLError.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLError.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLHandle.m b/Tests/base/headers/NSURLHandle.m new file mode 100644 index 000000000..f1447ccdc --- /dev/null +++ b/Tests/base/headers/NSURLHandle.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLHandle.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLProtectionSpace.m b/Tests/base/headers/NSURLProtectionSpace.m new file mode 100644 index 000000000..354ae3510 --- /dev/null +++ b/Tests/base/headers/NSURLProtectionSpace.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLProtectionSpace.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLProtocol.m b/Tests/base/headers/NSURLProtocol.m new file mode 100644 index 000000000..c5654c9ab --- /dev/null +++ b/Tests/base/headers/NSURLProtocol.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLProtocol.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLRequest.m b/Tests/base/headers/NSURLRequest.m new file mode 100644 index 000000000..869ac7702 --- /dev/null +++ b/Tests/base/headers/NSURLRequest.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLRequest.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSURLResponse.m b/Tests/base/headers/NSURLResponse.m new file mode 100644 index 000000000..4b32aa8b5 --- /dev/null +++ b/Tests/base/headers/NSURLResponse.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSURLResponse.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSUndoManager.m b/Tests/base/headers/NSUndoManager.m new file mode 100644 index 000000000..0799ca1ee --- /dev/null +++ b/Tests/base/headers/NSUndoManager.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSUndoManager.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSUserDefaults.m b/Tests/base/headers/NSUserDefaults.m new file mode 100644 index 000000000..82d8dd8bc --- /dev/null +++ b/Tests/base/headers/NSUserDefaults.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSUserDefaults.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSValue.m b/Tests/base/headers/NSValue.m new file mode 100644 index 000000000..f08f01fd3 --- /dev/null +++ b/Tests/base/headers/NSValue.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSValue.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSXMLParser.m b/Tests/base/headers/NSXMLParser.m new file mode 100644 index 000000000..54719522d --- /dev/null +++ b/Tests/base/headers/NSXMLParser.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSXMLParser.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/NSZone.m b/Tests/base/headers/NSZone.m new file mode 100644 index 000000000..990c54fa1 --- /dev/null +++ b/Tests/base/headers/NSZone.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/NSZone.h works"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/ObjCXX.mm b/Tests/base/headers/ObjCXX.mm new file mode 100644 index 000000000..40a516901 --- /dev/null +++ b/Tests/base/headers/ObjCXX.mm @@ -0,0 +1,12 @@ +#include "Testing.h" +#include + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of Foundation/Foundation.h works in an Objective-C++ program"); + [arp release]; + return 0; +} diff --git a/Tests/base/headers/TestInfo b/Tests/base/headers/TestInfo new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/base/headers/Unicode.m b/Tests/base/headers/Unicode.m new file mode 100644 index 000000000..b5c43825b --- /dev/null +++ b/Tests/base/headers/Unicode.m @@ -0,0 +1,12 @@ +#include +#include "ObjectTesting.h" + +@class NSAutoreleasePool; +int main() +{ + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + + PASS (1, "include of GNUstepBase/Unicode.h works"); + [arp release]; + return 0; +} diff --git a/Tools/AGSHtml.h b/Tools/AGSHtml.h index e3c7f66c9..1e04a68bf 100644 --- a/Tools/AGSHtml.h +++ b/Tools/AGSHtml.h @@ -12,21 +12,17 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "Foundation/NSObject.h" -#import "AGSIndex.h" - -@class NSMutableString; -@class NSString; +#include "AGSIndex.h" @interface AGSHtml : NSObject { diff --git a/Tools/AGSHtml.m b/Tools/AGSHtml.m index 2df2edda2..58f0e8dab 100644 --- a/Tools/AGSHtml.m +++ b/Tools/AGSHtml.m @@ -10,26 +10,20 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSUserDefaults.h" -#import "AGSHtml.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSMutableString+GNUstepBase.h" +#include +#include "AGSHtml.h" +#include "GNUstepBase/GNUstep.h" +#include "GNUstepBase/GSCategories.h" /* * Define constants for use if we are built with apple Foundation @@ -1221,8 +1215,8 @@ static NSString *mainFont = nil; if (url == nil) { [buf appendString: @"
"]; - [buf appendString: [[[author attributes] - objectForKey: @"name"] stringByEscapingXML]]; + [buf appendString: [[author attributes] + objectForKey: @"name"]]; } else { @@ -1230,8 +1224,8 @@ static NSString *mainFont = nil; [buf appendString: [[url attributes] objectForKey: @"url"]]; [buf appendString: @"\">"]; - [buf appendString: [[[author attributes] - objectForKey: @"name"] stringByEscapingXML]]; + [buf appendString: [[author attributes] + objectForKey: @"name"]]; [buf appendString: @""]; } if (email != nil) @@ -1660,7 +1654,7 @@ static NSString *mainFont = nil; str = [prop objectForKey: @"override"]; if ([str isEqual: @"subclass"] == YES) { - [buf appendString: @"Subclasses must " + [buf appendString: @"Subclasses should " @"override this method.
\n"]; } else if ([str isEqual: @"dummy"] == YES) @@ -1670,7 +1664,7 @@ static NSString *mainFont = nil; } else if ([str isEqual: @"never"] == YES) { - [buf appendString: @"Subclasses must NOT " + [buf appendString: @"Subclasses should NOT " @"override this method.
\n"]; } @@ -2215,14 +2209,14 @@ static NSString *mainFont = nil; } [buf appendString: indent]; [buf appendString: @"
"]; - [buf appendString: [[dProp objectForKey: @"key"] stringByEscapingXML]]; + [buf appendString: [dProp objectForKey: @"key"]]; [buf appendString: @" =
\n"]; [buf appendString: indent]; [buf appendString: @"
\n"]; [self incIndent]; if (value != nil) { - [buf appendString: [value stringByEscapingXML]]; + [buf appendString: value]; } else { @@ -2511,7 +2505,7 @@ static NSString *mainFont = nil; } if ([gvrem length] > 0) { - [buf appendString: @" Likely to be changed/moved/removed at "]; + [buf appendString: @" deprecated for removal at "]; [buf appendString: gvrem]; } } @@ -2537,7 +2531,7 @@ static NSString *mainFont = nil; [buf appendString: @"
\n"]; if ([gvrem length] > 0) { - [buf appendString: @" Likely to be changed/moved/removed at "]; + [buf appendString: @" deprecated for removal at "]; [buf appendString: gvrem]; } [buf appendString:@"\n"]; diff --git a/Tools/AGSIndex.h b/Tools/AGSIndex.h index e139a6742..c36dc7099 100644 --- a/Tools/AGSIndex.h +++ b/Tools/AGSIndex.h @@ -12,23 +12,17 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "Foundation/NSObject.h" -#import "GNUstepBase/GSXML.h" - -@class NSDictionary; -@class NSMutableArray; -@class NSMutableDictionary; -@class NSString; +#include @interface AGSIndex : NSObject { diff --git a/Tools/AGSIndex.m b/Tools/AGSIndex.m index 767755a65..ac467ce30 100644 --- a/Tools/AGSIndex.m +++ b/Tools/AGSIndex.m @@ -10,24 +10,20 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSDictionary.h" -#import "AGSIndex.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSMutableString+GNUstepBase.h" +#include +#include "AGSIndex.h" +#include "GNUstepBase/GNUstep.h" +#include "GNUstepBase/GSCategories.h" static int XML_ELEMENT_NODE; static int XML_TEXT_NODE; @@ -631,10 +627,6 @@ setDirectory(NSMutableDictionary *dict, NSString *path) if ([type isEqualToString: @"method"] || [type isEqualToString: @"ivariable"]) { - if (category != nil) - { - u = classname; // Store category methods by classname. - } // type ... ref ... unit ... file } else @@ -766,7 +758,7 @@ setDirectory(NSMutableDictionary *dict, NSString *path) /* * If unit is a category, method was probably indexed under the class, - * so wirk with the class instead of the category. + * so work with the class instead of the category. */ if ([*u length] > 0 && [*u characterAtIndex: [*u length] - 1] == ')') { diff --git a/Tools/AGSOutput.h b/Tools/AGSOutput.h index cdb438e67..669075303 100644 --- a/Tools/AGSOutput.h +++ b/Tools/AGSOutput.h @@ -12,22 +12,17 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "Foundation/NSObject.h" - -@class NSArray; -@class NSCharacterSet; -@class NSDictionary; -@class NSMutableArray; +#include @interface AGSOutput : NSObject { diff --git a/Tools/AGSOutput.m b/Tools/AGSOutput.m index 6ad2428ab..5d0f8b903 100644 --- a/Tools/AGSOutput.m +++ b/Tools/AGSOutput.m @@ -10,30 +10,19 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSCharacterSet.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSUserDefaults.h" -#import "AGSOutput.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSMutableString+GNUstepBase.h" +#include "AGSOutput.h" +#include "GNUstepBase/GNUstep.h" +#include "GNUstepBase/GSCategories.h" @interface AGSOutput (Private) - (NSString*) mergeMarkup: (NSString*)markup @@ -58,7 +47,7 @@ static BOOL snuggleEnd(NSString *t) if (set == nil) { set = [NSCharacterSet characterSetWithCharactersInString: @"]}).,;"]; - IF_NO_GC([set retain];) + RETAIN(set); } return [set characterIsMember: [t characterAtIndex: 0]]; } @@ -70,7 +59,7 @@ static BOOL snuggleStart(NSString *t) if (set == nil) { set = [NSCharacterSet characterSetWithCharactersInString: @"[{("]; - IF_NO_GC([set retain];) + RETAIN(set); } return [set characterIsMember: [t characterAtIndex: [t length] - 1]]; } @@ -204,10 +193,12 @@ static BOOL snuggleStart(NSString *t) for (i = start; size < limit && i < end; i++) { NSString *t = [a objectAtIndex: i]; + BOOL forceNewline = [t hasPrefix: @"

"]; + BOOL elementEndReached = (nest == 0 && [t hasPrefix: @"\n"]; [str appendString: @"\n"]; + [str appendString: @"\"http://www.gnustep.org/gsdoc-1_0_3.xml\">\n"]; [str appendFormat: @""]; [str appendString: [a objectForKey: @"Name"]]; @@ -1079,7 +1070,7 @@ static BOOL snuggleStart(NSString *t) } while (r.length > 0); if (m != nil) { - IF_NO_GC([m autorelease];) + AUTORELEASE(m); } } @@ -1356,7 +1347,7 @@ static BOOL snuggleStart(NSString *t) CREATE_AUTORELEASE_POOL(arp); #endif unsigned l = [str length]; - NSRange r = NSMakeRange(0, l); + NSRange r = [str rangeOfString: @"... sequences and output them literally. * All other text has reformatting applied as necessary. */ - r = [str rangeOfString: @" 0) { NSString *tmp; @@ -2346,7 +2336,7 @@ static BOOL snuggleStart(NSString *t) [str appendString: @"\n"]; [str appendString: @"\n"]; + [str appendString: @"\"http://www.gnustep.org/gsdoc-1_0_3.xml\">\n"]; [str appendString: @" - -@class NSArray; -@class NSCharacterSet; -@class NSDictionary; -@class NSMutableArray; -@class NSMutableDictionary; -@class NSString; +#include @interface AGSParser : NSObject { @@ -66,13 +58,13 @@ BOOL verbose; BOOL warn; BOOL standards; - BOOL inUnclosedExample; NSDictionary *wordMap; NSString *declared; /** Where classes were declared. */ NSMutableArray *ifStack; /** Track preprocessor conditionals. */ NSString *comment; /** Documentation accumulator. */ NSMutableDictionary *info; /** All information parsed. */ + NSMutableDictionary *orderedSymbolDeclsByUnit; NSMutableArray *source; /** Names of source files. */ NSCharacterSet *identifier; /** Legit char in identifier */ NSCharacterSet *identStart; /** Legit initial char of identifier */ @@ -81,6 +73,7 @@ } - (NSMutableDictionary*) info; +- (NSDictionary *) orderedSymbolDeclarationsByUnit; - (id) init; /** Simple initialiser */ - (NSMutableArray*) outputs; - (unsigned) parseComment; diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index 20055ee4a..770219164 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -8,33 +8,19 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSCharacterSet.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSScanner.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSValue.h" -#import "AGSParser.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSMutableString+GNUstepBase.h" +#include "AGSParser.h" +#include "GNUstepBase/GNUstep.h" +#include "GNUstepBase/GSCategories.h" /** * The AGSParser class parses Objective-C header and source files @@ -356,148 +342,6 @@ return output; } -/* When the paragraph string contains a GSDoc block element which is not a text -element (in the GSDoc DTD sense), we return NO, otherwise we return YES. - -A GSDoc or HTML paragraph content is limited to text elements (see GSDoc DTD). -e.g. 'list' or 'example' cannot belong to a 'p' element. - -Any other non-block elements are considered valid. Whether or not they can be -embedded within a paragraph in the final output is the doc writer -responsability. - -For 'item' and 'answer' which can contain arbitrary block elements, explicit -'p' tags should be used, because we won't wrap 'patata' and 'patati' as two -paragraphs in the example below: - -patata - -patati - - -When starts a paragraph, \n\n sequence are allowed in the example. -In the example below, bla or bla\n wouldn't be handled -correctly unlike: -bla - - -patati - -patata - */ -- (BOOL) canWrapWithParagraphMarkup: (NSString *)para -{ - NSScanner *scanner = [NSScanner scannerWithString: para]; - NSSet *blockTags = [NSSet setWithObjects: @"list", @"enum", @"item", - @"deflist", @"term", @"qalist", @"question", @"answer", - @"p", @"example", @"embed", @"index", nil]; - NSMutableCharacterSet *skippedChars = - (id)[NSMutableCharacterSet punctuationCharacterSet]; - - if (inUnclosedExample) - { - /* We don't need to check block element presence within an example, - since an example content is limited to PCDATA. */ - [scanner scanUpToString: @"" intoString: NULL]; - if ([scanner scanString: @"" intoString: NULL]) - { - inUnclosedExample = NO; - } - return NO; - } - - /* Set up the scanner to treat opening and closing tags in the same way. - Punctuation character set includes '/' but not '<' and '>' */ - [skippedChars formUnionWithCharacterSet: [scanner charactersToBeSkipped]]; - [scanner setCharactersToBeSkipped: AUTORELEASE([skippedChars copy])]; - - while (![scanner isAtEnd]) - { - NSString *tag = @""; - BOOL foundBlockTag = NO; - - [scanner scanUpToString: @"<" intoString: NULL]; - if (![scanner scanString: @"<" intoString: NULL]) - return YES; - - [scanner scanUpToString: @">" intoString: &tag]; - foundBlockTag = [blockTags containsObject: tag]; - - if (foundBlockTag) - { - /* When the first block tag is and the example is unclosed in - the current paragraph, we stop to insert

tags in the next - paragraphs until we reach */ - if ([tag isEqualToString: @"example"]) - { - [scanner setCharactersToBeSkipped: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; - [scanner scanUpToString: @"" intoString: NULL]; - inUnclosedExample = ([scanner scanString: @"" intoString: NULL] == NO); - } - - return NO; - } - } - - return YES; -} - -// NOTE: We could be able to eliminate that if -parseComment processes the -// first comment tags before calling -generateParagraphMarkups: -- (BOOL) shouldInsertParagraphMarkupInFirstComment: (NSString *)aComment -{ - NSArray *firstCommentTags = [NSArray arrayWithObjects: @"", - @"<abstract>", @"<author>", @"<copy>", @"<version>", @"<date>", - @"Author:", @"By:", @"Copyright (C)", @"Revision:", @"Date:", nil]; - NSEnumerator *e = [firstCommentTags objectEnumerator]; - NSString *tag = nil; - - while ((tag = [e nextObject]) != nil) - { - if ([aComment rangeOfString: tag - options: NSCaseInsensitiveSearch].location != NSNotFound) - { - return NO; - } - } - - return YES; -} - -- (NSString *) generateParagraphMarkupForString: (NSString *)aComment -{ - NSMutableString *formattedComment = [NSMutableString stringWithCapacity: [aComment length] + 100]; - NSArray *paras = [aComment componentsSeparatedByString: @"\n\n"]; - NSEnumerator *e = [paras objectEnumerator]; - NSString *para = nil; - BOOL isFirstComment = (commentsRead == NO); - - if (isFirstComment - && ![self shouldInsertParagraphMarkupInFirstComment: aComment]) - { - return aComment; - } - - while ((para = [e nextObject]) != nil) - { - NSString *newPara = para; - /* -canWrapWithParagraph: can change its value */ - BOOL wasInUnclosedExample = inUnclosedExample; - - if ([self canWrapWithParagraphMarkup: para]) - { - newPara = [NSString stringWithFormat: @"<p>%@</p>", para]; - } - else if (wasInUnclosedExample) - { - newPara = [NSString stringWithFormat: @"\n\n%@", para]; - } - [formattedComment appendString: newPara]; - } - - return formattedComment; -} - /** * In spite of its trivial name, this is one of the key methods - * it parses and skips past comments, but it also recognizes special @@ -523,12 +367,6 @@ patata BOOL isDocumentation = NO; BOOL skippedFirstLine = NO; NSRange r; - BOOL ignore = NO; - - - /* Jump back here if we have ignored data up to a new comment. - */ -comment: pos += 2; /* Skip opening part */ @@ -662,46 +500,10 @@ comment: */ if (end > start) { - NSString *tmp; - NSRange r; - NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSString *tmp; tmp = [NSString stringWithCharacters: start length: end - start]; - - /* - * If the comment does not contain block markup already and we - * were asked to generate it, we insert <p> tags to get an - * explicit paragraph structure. - */ - if ([defs boolForKey: @"GenerateParagraphMarkup"]) - { - // FIXME: Should follow <ignore> processing and be called - // just before using -appendComment:to: - tmp = [self generateParagraphMarkupForString: tmp]; - } -recheck: - if (YES == ignore) - { - r = [tmp rangeOfString: @"</ignore>"]; - if (r.length > 0) - { - tmp = [tmp substringFromIndex: NSMaxRange(r)]; - ignore = NO; - } - } - if (NO == ignore) - { - r = [tmp rangeOfString: @"<ignore>"]; - if (r.length > 0) - { - [self appendComment: [tmp substringToIndex: r.location] - to: nil]; - tmp = [tmp substringFromIndex: NSMaxRange(r)]; - ignore = YES; - goto recheck; - } - [self appendComment: tmp to: nil]; - } + [self appendComment: tmp to: nil]; } /* @@ -1125,38 +927,6 @@ recheck: } commentsRead = YES; } - if (YES == ignore) - { - while (pos < length) - { - switch (buffer[pos]) - { - case '\'': - case '"': - [self skipLiteral]; - break; - - case '/': - if (pos + 1 < length) - { - if (buffer[pos + 1] == '/') - { - [self skipRemainderOfLine]; - } - else if (buffer[pos + 1] == '*') - { - goto comment; - } - } - pos++; - break; - - default: - pos++; - break; - } - } - } } return pos; } @@ -1285,7 +1055,7 @@ recheck: @"unsigned", @"volatile", nil]; - IF_NO_GC([qualifiers retain];) + RETAIN(qualifiers); keep = [NSSet setWithObjects: @"const", @"long", @@ -1294,7 +1064,7 @@ recheck: @"unsigned", @"volatile", nil]; - IF_NO_GC([keep retain];) + RETAIN(keep); } a = [NSMutableArray array]; @@ -1333,7 +1103,7 @@ recheck: pos++; [self skipSpaces]; } - IF_NO_GC(DESTROY(arp);) + DESTROY(arp); return nil; } @@ -1362,7 +1132,6 @@ recheck: || [s isEqualToString: @"union"] == YES || [s isEqualToString: @"enum"] == YES) { - BOOL isEnum = [s isEqualToString: @"enum"]; NSString *tmp = s; s = [self parseIdentifier]; @@ -1380,91 +1149,9 @@ recheck: */ [d setObject: s forKey: @"Name"]; } - /* We parse enum comment of the form: - <introComment> enum { field1, <comment1> field2 <comment2> } bla; */ - if (isEnum && [self parseSpace] < length && buffer[pos] == '{') + if ([self parseSpace] < length && buffer[pos] == '{') { - NSString *ident; - NSString *introComment; - NSMutableString *fieldComments = [NSMutableString string]; - BOOL foundFieldComment = NO; - - /* We want to be able to parse new comments while retaining the - originally parsed comment for the enum/union/struct. */ - introComment = [comment copy]; - DESTROY(comment); - - pos++; /* Skip '{' */ - - [fieldComments appendString: @"<deflist>"]; - - // TODO: We should put the parsed field into the doc index and - // let AGSOutput generate the deflist. - while (buffer[pos] != '}') - { - ident = [self parseIdentifier]; - /* Discard any comment parsed before the identifier */ - if (comment != nil) - { - [self log: @"Ignoring comment before first field %@ in %@", - comment, ident, s]; - DESTROY(comment); - } - - /* Skip the left-hand side such as ' = aValue' - - Four combinations can be parsed: - - fieldDecl, - - fieldDelc, <comment> - - fieldDecl } - - fieldDelc <comment> } */ - while (buffer[pos] != ',' && buffer[pos] != '}') - { - BOOL foundComment = (buffer[pos] == '/' && buffer[pos + 1] == '*'); - - if (foundComment) - break; - - pos++; - } - if (buffer[pos] == ',') - pos++; - - [self parseSpace]; /* Parse doc comment into 'comment' ivar */ - - [fieldComments appendString: @"<term><em>"]; - if (comment != nil) - foundFieldComment = YES; - - if (ident != nil) - { - [fieldComments appendString: ident]; - [fieldComments appendString: @"</em></term>"]; - [fieldComments appendString: @"<desc>"]; - // NOTE: We could add a 'Description forthcoming' if nil - if (comment != nil) - { - [fieldComments appendString: comment]; - } - [fieldComments appendString: @"</desc>\n"]; - } - DESTROY(comment); - } - - [fieldComments appendString: @"</deflist>"]; - - /* Restore the comment as initially parsed before -parseDeclaration - was called and add the comments parsed per field into a deflist. */ - ASSIGN(comment, introComment); - if (foundFieldComment) - { - NSString *enumComment = - [comment stringByAppendingFormat: @"\n\n%@", fieldComments]; - - ASSIGN(comment, enumComment); - } - - pos++; /* Skip '}' */ + [self skipBlock]; } [a addObject: s]; s = nil; @@ -2886,7 +2573,7 @@ fail: itemName = nil; RELEASE(arp); - IF_NO_GC([method autorelease];) + AUTORELEASE(method); return method; fail: @@ -3564,7 +3251,7 @@ fail: unitName = nil; DESTROY(comment); RELEASE(arp); - IF_NO_GC([dict autorelease];) + AUTORELEASE(dict); return dict; fail: @@ -4011,8 +3698,8 @@ fail: pos = 0; lines = [[NSArray alloc] initWithArray: a]; RELEASE(arp); - IF_NO_GC([lines autorelease];) - IF_NO_GC([data autorelease];) + AUTORELEASE(lines); + AUTORELEASE(data); } /** diff --git a/Tools/DocMakefile b/Tools/DocMakefile index 71f50dde0..8cf143174 100644 --- a/Tools/DocMakefile +++ b/Tools/DocMakefile @@ -66,13 +66,26 @@ BaseTools_AGSDOC_FLAGS = \ -HeaderDirectory ../Tools \ -Standards YES \ -WordMap '{\ - FOUNDATION_EXPORT=extern;FOUNDATION_STATIC_INLINE="";\ + FOUNDATION_EXPORT=extern;\ + FOUNDATION_STATIC_INLINE="";\ + GS_ATTRIB_DEPRECATED="";\ + GS_DECLARE="";\ + GS_EXPORT=extern;\ + GS_GEOM_ATTR="";\ + GS_GEOM_SCOPE=extern;\ + GS_NORETURN_METHOD="";\ + GS_RANGE_ATTR="";\ + GS_RANGE_SCOPE=extern;\ GS_STATIC_INLINE="";\ - GS_GEOM_SCOPE=extern;GS_GEOM_ATTR="";\ - GS_EXPORT=extern;GS_DECLARE="";\ - GS_RANGE_SCOPE=extern;GS_RANGE_ATTR="";\ - GS_ZONE_SCOPE=extern;GS_ZONE_ATTR="";\ + GS_UNUSED_IVAR="";\ + GS_ZONE_ATTR="";\ + GS_ZONE_SCOPE=extern;\ INLINE=inline;\ + NS_CONSUMED="";\ + NS_CONSUMES_SELF="";\ + NS_RETURNS_NOT_RETAINED="";\ + NS_RETURNS_RETAINED="";\ + WINAPI="";\ }' -Up BaseTools # Use local version of autogsdoc in case it is not installed diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index 5c22ba946..23ff6b12a 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -23,31 +23,21 @@ ifeq ($(GNUSTEP_MAKEFILES),) GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) - ifeq ($(GNUSTEP_MAKEFILES),) - $(warning ) - $(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!) - $(warning Perhaps gnustep-make is not properly installed,) - $(warning so gnustep-config is not in your PATH.) - $(warning ) - $(warning Your PATH is currently $(PATH)) - $(warning ) - endif endif ifeq ($(GNUSTEP_MAKEFILES),) $(error You need to set GNUSTEP_MAKEFILES before compiling!) endif -PACKAGE_NAME = gnustep-base +# Install into the system root by default +GNUSTEP_INSTALLATION_DOMAIN = SYSTEM + GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make include $(GNUSTEP_MAKEFILES)/common.make --include ../Version --include ../config.mak - -ADDITIONAL_CPPFLAGS = -DGNUSTEP_BASE_INTERNAL=1 - +include ../Version +include ../config.mak # DTDs to install dtddir = $(GNUSTEP_LIBRARY)/DTDs @@ -72,7 +62,7 @@ ifeq ($(add),yes) TOOL_NAME = autogsdoc cvtenc plmerge sfparse xmlparse else TOOL_NAME = autogsdoc cvtenc gdnc gspath defaults pl plmerge \ - plparse sfparse pldes plget plser pl2link xmlparse HTMLLinker + plparse sfparse pldes plget plser pl2link xmlparse CTOOL_NAME = gdomap SUBPROJECTS = make_strings @@ -100,7 +90,6 @@ sfparse_OBJC_FILES = sfparse.m pl2link_OBJC_FILES = pl2link.m locale_alias_OBJC_FILES = locale_alias.m xmlparse_OBJC_FILES = xmlparse.m -HTMLLinker_OBJC_FILES = HTMLLinker.m DOCUMENT_NAME = autogsdoc @@ -115,6 +104,8 @@ AUTOGSDOC=./$(GNUSTEP_OBJ_DIR_NAME)/autogsdoc include Makefile.preamble +-include GNUmakefile.local + include $(GNUSTEP_MAKEFILES)/tool.make include $(GNUSTEP_MAKEFILES)/ctool.make include $(GNUSTEP_MAKEFILES)/aggregate.make diff --git a/Tools/HTMLLinker.gsdoc b/Tools/HTMLLinker.gsdoc deleted file mode 100644 index 8f82bc1fe..000000000 --- a/Tools/HTMLLinker.gsdoc +++ /dev/null @@ -1,417 +0,0 @@ -<chapter> - <heading>The HTMLLinker tool</heading> - <section> - <heading>Introduction</heading> - <p> - The GNUstep HTML linker is able to fixup links from one HTML - document to other HTML ones. By link we mean the standard - <code><a href="NSString.html#DescriptionOfNSString"></code> - tag. By fixing up a link we mean to modify the path in the - <code>href</code> so that it points to the actual file on disk. - For example, if you the <code>DescriptionOfNSString</code> - location is in the file <code>NSStringOverview.html</code> in the - directory <code>/home/nicola/Doc</code>, when the linker fixes up - the <code><a - href="NSString.html#DescriptionOfNSString"></code> link, it - will replace it with <code><a - href="/home/nicola/Doc/NSStringOverview.html#DescriptionOfNSString"></code>. - Please note that when fixing up the link, the linker modifies both - the path and the file name that the link points to, but not the - location inside the file (the <code>DescriptionOfNSString</code> - in the example). - </p> - </section> - - <section> - <heading>Practical Usage of the linker</heading> - - The typical usage of the linker is with maintaining - cross-references in software documentation. You need to establish - some sort of convention used by all your software documentation - for the link names. For example, suppose that your documentation - is about C libraries. For each C function, you might decide to - tag its documentation in the files with the name - <code>function$function_name</code>. For example, the place in - the doc where it documents the <code>start_library()</code> - function would have the HTML tag <code><a - name="function$start_library"></code>. Having established this - convention, in any HTML file in your documentation in which you - want to create a link to the documentation for the - <code>start_library()</code> function, you use the code - <code><a rel="dynamic" - href="#function$start_library"></code> (please note that you - ignore the problem of locating the actual file which contains the - documentation for the <code>start_library()</code> function, that - is precisely what the linker will do for you). Whenever you - install the documentation for a new project, you first create a - relocation file for the project documentation, by running - <pre> - HTMLLinker -BuildRelocationFileForDir Documentation - </pre> - if for example the project documentation is in the - <code>Documentation</code> subdirectory. This will create a - <code>Documentation/table.htmlink</code> file, which contains a - list of all names found in the project documentation, and for each - of them, the file in which it's found. Then, you install the - project documentation (say for example that it's installed into - <code>/opt/gnustep/Local/Documentation/MyProject</code>), and once - it's installed, you can run the linker to update all links so that - they point to the actual files - <pre> - HTMLLinker /opt/gnustep/Local/Documentation/MyProject \ - -l /opt/gnustep/Local/Documentation/MyProject \ - -l /opt/gnustep/Local/Documentation/MyOtherProject - </pre> - This will fixup all links in <code>MyProject</code>'s HTML files - by using the relocation files of both <code>MyProject</code> and - <code>MyOtherProject</code>, so all links to anything which is - documented inside those files will be generated correctly. - </section> - - <section> - <heading>Usage of the tool with autogsdoc</heading> - - You can use the tool with documentation generated by autogsdoc to - perform the linking (or to relink it). Make sure to use the option - <code>-LinksMarker gsdoc</code> because autogsdoc marks the links - to be fixed up by the linker by using <code>rel="gsdoc"</code>. - </section> - - <section> - <heading>Modes of operation</heading> - The HTML linker works in two phases: - - <ul> - - <li> The first (called <i>generation of the relocation - table</i>) preprocesses a given set of HTML files so that it can - be the destination of links. It builds a relocation table for - the given set of HTML files. This relocation table simply maps - all names (as in <code><a name="xxx"></code>) in the files - to the file in which the name is found. The HTML files are not - touched. The linker is able to merge this dynamically generated - relocation table with pregenerated relocation tables loaded from - files (called <i>relocation files</i>). - </li> - - <li> The second (called <i>linking</i>) links a given file to - the available HTML files on disk, by using the relocation table - to modify the HTML links in the file so that they point to - existing files. - </li> - - </ul> - - The HTML linker can also be run in a special mode, to generate a - relocation file for later reuse. In this mode, the HTML linker - will build the relocation table for all files in a directory, then - save the relocation table into a <code>table.htmlink</code> file - in that directory for later reuse. - - There are three kinds of files: - - <ul> - - <li> - <em>input files</em>: these are HTML files which are modified - as a consequence of linking; they have their links fixed up. - </li> - - <li> - <em>destination files</em>: these are HTML files which are - read to produce relocation tables. - </li> - - <li> - <em>relocation files</em>: these files are not HTML files - - they are only created and read by the linker (unless you have - a tool which can manage them), and are in a specific - very - simple - format. They are used to save relocation information - for later reuse, so that the linker can run faster. Normally, - they have a <code>.htmlink</code> extension. - </li> - - </ul> - </section> - - <section> - <heading>Linker behaviour</heading> - - The linker keeps a main relocation table, which is empty at the - beginning. When run, the linker performs the following steps: - - <ol> - <li> - the linker reads and parses all relocation files specified on - the command line, and merges the relocation tables found there - into the main relocation table. - </li> - <li> - the linker reads and parses all destination files specified on - the command line, and builds a relocation table for them, - merging it into the main relocation table. - </li> - <li> - if any input files are specified on the command line, the - linker links the files using the relocation table. - </li> - </ol> - </section> - - <heading>Specifying input, destination and relocation files</heading> - - All command line arguments which do not begin with a hypen - (<code>-</code>), and which are not the values of defaults (for - example, not the <code>YES</code> in <code>-Warn YES</code>, - because that is the value of the default <code>-Warn</code>), are - interpreted as input files. Each destination file is specified by - using a <code>-d</code> option, and each relocation file by using - a <code>-l</code> option. If a directory is specified as an input - (or destination) file, the linker will recurse into the directory - and add to the list of input (or destination) files all files in - the directory (and in the directory's subdirectories, no matter - how deeply nested) which have one of the following extensions: - <code>.html</code>, <code>.HTML</code>, <code>.htm</code> or - <code>.HTM</code>. If a directory is specified as a relocation - file, the linker will add to the list of relocation files all - files in the directory which have the extension - <code>.htmlink</code>. A typical invocation of the linker is as - follows: - <pre> - HTMLLinker -BuildRelocationFileForDir Doc - </pre> - Builds a relocation file for the documentation in the - directory <code>Doc</code>. After this has been done, the - directory <code>Doc</code> can be used as a <code>-l</code> - argument. - <pre> - HTMLLinker test.html -l Doc - </pre> - Links the file <code>test.html</code> using the relocation file - just generated in the <code>Doc</code> directory. - - <heading>What is a link</heading> - - A link is an anchor tag with and <code>href</code>, such as - <code><a href="dest.html#location"></code>. The destination - file of the link is the file specified in the <code>href</code>; - <code>dest.html</code> in the example. The destination file is - ignored by the linker; the name of the link (which is everything which - follows the <code>#</code>) is used to perform the linking. - - <heading>Which links are fixed up</heading> - - Normally, the linker will only fixup links which have the - <code>rel</code> attribute set to <code>dynamic</code>, as in the - following example: <code><a href="nicola.html" - rel="dynamic"></code>. In this way, you can specify in your - HTML document which links you want to be fixed up, and which you - don't want to be. You can change the type of links to be fixed up - by using the <code>-LinksMarker</code> options, as in - <code>-LinksMarker gsdoc</code>, which causes the linker to fixup - all links with the <code>rel</code> attribute set to - <code>gsdoc</code> rather than <code>dynamic</code>. In certain - situations you might want to force the linker to attempt to fixup - all links; you can run the linker with the <code>-FixupAllLinks - YES</code> option to cause this behaviour. As a special - exception, links which obviously are not to be fixed up, such as - links beginning with <i>mailto:</i> or <i>news:</i>, or links - without a name, are never fixed up. - - <heading>How links are fixed up </heading> - - When the HTML linker encounters a link which needs to be fixed up - (say <code><a href="dest.html#location"></code>), it - searches the relocation table for a destination file which - contains the <code>location</code> name. If no such file is - found, the HTML linker emits a warning, and replaces the link in - the file with a link to the destination without the filename. In - the example, it would simply emit <code><a - href="#location"></code>. If the destination file is found in - the list, instead, the HTML linker replaces the link with the full - path to the destination file on disk. For example, if - according - to the relocation table, the file - <code>/home/nicola/Doc/dest.html</code> contains the name - <code>location</code>, the HTML linker will fixup the link to be - <code><a href="/home/nicola/Doc/dest.html#location"></code> - (as a special exception, if there is a path mapping which matches - the path to the destination file, it's applied to the path in the - link. See below for a detailed explanation of path mappings). - It's important to notice that you must have unique link names for - the linker to work properly. For example, if you have two - different destination files containing the same name, say - <code>NSObject.html</code> and <code>NSString.html</code> both - containing the name <code>init</code>, then the linker can't - resolve <code><a href="#init"></code>, because it has no way - to know if you meant the link to point to the first or the second - destination file! You should choose names better so that they - uniquely specify what they represent contents, for example - <code>NSObject_i_init</code> and <code>NSString_i_init</code> if - the first link is in the place documenting the <code>-init</code> - method of the NSObject class and the second one the one of the - NSString class. Then all links will clearly refer to one place or - the other one, and no confusion will arise. If there are multiple - destination files for a link, the linker will guess which one is - the right one, and that might not give the desired result. - - <heading>How links are checked</heading> - - When a link is fixed up, the linker implicitly checks that the link - is correct, because if the link name can't be found in the relocation - tables, a warning is issued. - - <heading>Path mappings</heading> - - Path mappings are an additional feature of the HTML linker which - can be used when exporting documentation to be served by a web - server. If you are not putting your documentation on a web server - but simply reading it from the filesystem, then you don't need the - path mappings. The issue with exporting documentation to a web - server is that you refer to files using paths which are not - necessarily the same paths where the files are on disk. For - example, suppose that you have some HTML documentation in - <code>/opt/doc/base</code> and some other HTML documentation in - <code>/opt/doc/gui</code>. The HTML files in the two - documentation directories refer to each other. You can run the - HTML linker and fixup all links, and we are happy. But now - suppose that you set up a web server; the web server, for example, - will serve URLs beginning with <code>/Base</code> (meaning as in - requests from a browser of the form - <code>http://www.server.org/Base</code>) by taking files from - <code>/opt/doc/base</code>, and URLs beginning with - <code>Gui</code> by taking files from <code>/opt/doc/gui</code>. - To fixup the links in this case, you need path mappings. A path - mapping specifies that a certain directory on disk is to be - referred in some different way in links. In the example, you - would pass - <pre> - -PathMapping '{ "/opt/doc/base"="/Base"; "/opt/doc/gui"="/Gui"; }' - </pre> - to the linker. - - Each path mapping maps a <em>path on disk</em> to a <em>virtual - path</em>. For example, it maps the path on disk - <code>/opt/doc/base</code> to the virtual path <code>/Base</code>. - Each time the linker fixes up a link, after finding the - destination file, it checks the list of path mappings. If the - path to the destination file begins with the <em>path on disk</em> - of one of the path mappings, then that <em>path on disk</em> is - replaced with the corresponding <em>virtual path</em> in the path - to the destination file before the path to the destination file is - written out in the link. - - For example, if you have the path mapping explained above, and if - the linker is fixing up the link <code><a - href="hi.html#nicola"></code>, where the destination file is - <code>/opt/doc/base/nicola/hi.html</code>, then the destination - path matches the path mapping for <code>/opt/doc/base</code>, so - the path mapping is applied and the link is fixed up to be - <code><a href="/Base/nicola/hi.html#nicola"></code> rather than - <code><a href="/opt/doc/base/nicola/hi.html#nicola"></code> as it - would normally have been without the path mapping. - - <heading>Specifying path mappings</heading> - - <h5>On the command line</h5> - Each path mapping specifies a mapping of a path on disk to a web - server alias. The first way to specify the mappings is on the - command line, in the form of a dictionary argument to the - <code>-PathMappings</code>, as in - <pre> - -PathMappings '{ "/opt/doc/base"="/Base"; "/opt/doc/gui"="/Gui"; }' - </pre> - where <code>/opt/doc/base</code> and <code>/opt/doc/gui</code> are - the paths on disk and <code>/Base</code> and <code>/Gui</code> are - the corresponding web server URL paths. - - <h5>In a path mappings file</h5> - The other way to specify mappings is to write them into a file, - in the format of a dictionary, as, for example, in a file containing - the following lines - <pre> - { - "/opt/doc/base"="/Base"; - "/opt/doc/gui"="/Gui"; - } - </pre> - and then tell the linker to read the path mappings from that file, - by giving the filename as option to the - <code>-PathMappingsFile</code>. For example, if the file - containing the mappings is called <code>mappings</code>, then you need - to pass - <pre> - -PathMappingsFile mappings - </pre> - to the linker to have it read mappings from the file. - - <h5>Command line path mappings override file path mappings</h5> - Both command line path mappings and path mappings from a file can - be used at the same time; in case of conflict, command line path - mappings override path mappings from the file. - - <h3>Summary of all the options</h3> - - Each of the options beginning with a single hypen (<code>-</code>) - require an argument, as in - <pre> - HTMLLinker Documentation -LinksMarker gsdoc -d Documentation - </pre> - which sets <code>LinksMarker</code> to <code>gsdoc</code>. The - options might be anywhere on the command line. Options which do - not begin with a single hypen (such as <code>--help</code>) do not - require an argument, as in - <pre> - HTMLLinker --help - </pre> - - <h4>-d</h4> - - Followed by a destination HTML file, or a directory containing - destination HTML files. - - <h4>-l</h4> - - Followed by a relocation file, or a directory containing relocation files. - - <h4>-FixupAllLinks</h4> - - If set to <code>NO</code> (the default) only links containing the - <code>rel</code> attribute set to <code>dynamic</code> (or - whatever specified as <code>LinksMarkers</code>)are fixed up in - the input files. If set to <code>YES</code>, all links are fixed - up. - - <h4>-LinksMarker</h4> - - If set (and if <code>FixupAllLinks</code> is <code>NO</code>), - only links with the <code>rel</code> attribute set to its value - are processed. By default it is set to <code>dynamic</code>. - - <h4>-PathMappings</h4> - - If set to a dictionary, read the dictionary as path mappings. See - above for more details of path mappings. - - <h4>-PathMappingsFile</h4> - - If set to a string, consider it to be the name of a file; read - path mappings from that file. The file must contain the path - mappings in the form of a dictionary. See above for more details - on path mappings. - - <h4>-Verbose</h4> - - If set to <code>YES</code> prints some more messages than if set - to <code>NO</code> (the default). - - <h4>--help</h4> - - Prints a quick explanation of the command line syntax and exits. - - <h4>--version</h4> - - Prints the version and exits. - - <hr> - -</chapter> diff --git a/Tools/HTMLLinker.m b/Tools/HTMLLinker.m deleted file mode 100644 index e480ec26e..000000000 --- a/Tools/HTMLLinker.m +++ /dev/null @@ -1,1358 +0,0 @@ -/** The GNUstep HTML Linker - - <title>HTMLLinker. A tool to fix up href references in html files - Copyright (C) 2002,2007 Free Software Foundation, Inc. - - Written by: Nicola Pero - Date: January 2002 - - This file is part of the GNUstep Project - - 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. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. - If not, write to the Free Software Foundation, - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - */ - -/* - * See the HTMLLinker.html file for documentation on how to use the tool. - */ - -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" - -/* For convenience, cached for the whole tool. */ - -/* [NSFileManager defaultManager] */ -static NSFileManager *fileManager = nil; - -/* [[NSFileManager defaulManager] currentDirectoryPath] */ -static NSString *currentPath = nil; - -static int verbose = 0; - -/* Enumerate all .html (or .htmlink) files in a directory and - subdirectories. */ -@interface HTMLDirectoryEnumerator : NSEnumerator -{ - NSDirectoryEnumerator *e; - NSString *basePath; - BOOL looksForHTMLLinkFiles; - BOOL returnsAbsolutePaths; -} - -- (id)initWithBasePath: (NSString *)path; - -- (void)setReturnsAbsolutePaths: (BOOL)flag; - -- (void)setLooksForHTMLLinkFiles: (BOOL)flag; - -@end - -@implementation HTMLDirectoryEnumerator : NSEnumerator - -- (id)initWithBasePath: (NSString *)path -{ - ASSIGN (e, [fileManager enumeratorAtPath: path]); - ASSIGN (basePath, path); - return [super init]; -} - -- (void)dealloc -{ - RELEASE (e); - RELEASE (basePath); - [super dealloc]; -} - -- (void)setReturnsAbsolutePaths: (BOOL)flag -{ - returnsAbsolutePaths = flag; -} - -- (void)setLooksForHTMLLinkFiles: (BOOL)flag -{ - looksForHTMLLinkFiles = YES; -} - -- (id)nextObject -{ - NSString *s; - - while ((s = [e nextObject]) != nil) - { - BOOL found = NO; - NSString *extension = [s pathExtension]; - - if (looksForHTMLLinkFiles) - { - if ([extension isEqualToString: @"htmlink"]) - { - found = YES; - } - } - else if ([extension isEqualToString: @"html"] - || [extension isEqualToString: @"HTML"] - || [extension isEqualToString: @"htm"] - || [extension isEqualToString: @"HTM"]) - { - found = YES; - } - - if ([[[e fileAttributes] fileType] isEqual: NSFileTypeDirectory] - && verbose) - { - GSPrintf(stdout, @" traversing %@\n", s); - } - - if (found) - { - if (returnsAbsolutePaths) - { - /* NSDirectoryEnumerator returns the relative path, we - return the absolute. */ - return [basePath stringByAppendingPathComponent: s]; - } - else - { - return s; - } - } - } - - return nil; -} - -@end - -/* The HTMLLinker class is very simple and is the core of the linker. - It just keeps a relocation, and is able to fixup a link by using - the relocation table. */ -@interface HTMLLinker : NSObject -{ - BOOL warn; - BOOL hasPathMappings; - NSMutableDictionary *pathMappings; - NSMutableDictionary *relocationTable; -} - -- (id)initWithWarnFlag: (BOOL)v; - -- (void)registerRelocationFile: (NSString *)pathOnDisk; - -- (void)registerDestinationFile: (NSString *)pathOnDisk; - -/* Register a new path mapping. */ -- (void)registerPathMappings: (NSDictionary *)dict; - -/* Resolve the link 'link' by fixing it up using the relocation table. - Return the resolved link. 'logFile' is only used to print error - messages. It is the file in which the link is originally found; if - there is problem resolving the link, the warning message printed - out states that the problem is in file 'logFile'. */ -- (NSString *)resolveLink: (NSString *)link - logFile: (NSString *)logFile; - -@end - -/* All the parsing code is in the following class. It's not a real - parser in the sense that it is just performing its minimal duty in - the quickest possible way, so calling this a parser is a bit of a - exaggeration ... this code can run very quickly through an HTML - string, extracting the tags or fixing up the tags. No more HTML parsing than this - is done. Remarkably, this does not need XML support in the base - library, so you can use the HTML linker on any system. This class - was written in order to perform its trivial, mechanical duty /very - fast/. You want to be able to run the linker often and on a lot of - files and still be happy. FIXME - Need to implement support for - newer HTML where you can use id="name" in any tag. */ -@interface HTMLParser : NSObject -{ - /* The HTML code that we work on. */ - unichar *chars; - unsigned length; -} -/* Init with some HTML code to parse. */ -- (id)initWithCode: (NSString *)HTML; - -/* Extract all the tags from the HTML code, and return - a list of them. */ -- (NSArray *)names; - -/* Fix up all the links in the HTML code by feeding each of them to - the provided HTMLLinker; return the fixed up HTML code. If - linksMarker is nil, attempts to fix up all links in the HTML code; - if it is not-nil, only attempt to fixup links with rel=marker. - logFile is the file we are fixing up; it's only used when a warning - is issued because there is problem in the linking - the warning - message is displayed as being about links in the file logFile. */ -- (NSString *)resolveLinksUsingHTMLLinker: (HTMLLinker *)linker - logFile: (NSString *)logFile - linksMarker: (NSString *)marker; -@end - - -@implementation HTMLParser - -- (id)initWithCode: (NSString *)HTML -{ - length = [HTML length]; - chars = malloc (sizeof(unichar) * length); - [HTML getCharacters: chars]; - - return [super init]; -} - -- (void)dealloc -{ - free (chars); - [super dealloc]; -} - -- (NSArray *)names -{ - NSMutableArray *names = AUTORELEASE ([NSMutableArray new]); - unsigned i = 0; - - while (i + 3 < length) - { - /* We ignore anything except stuff which begins with "') { break; } - - - /* I suppose i == s might happen if the file contains */ - if (i != s) - { - /* If name != nil we already found it so don't bother. */ - if (name == nil) - { - NSString *attribute; - - attribute = [NSString stringWithCharacters: &chars[s] - length: (i - s)]; - /* Lowercase name so that eg, HREF and href are the - same. */ - attribute = [attribute lowercaseString]; - - if ([attribute isEqualToString: @"name"]) - { - isNameAttribute = YES; - } - } - } - - /* Skip spaces. */ - while (i < length && (chars[i] == ' ' - || chars[i] == '\n' - || chars[i] == '\r' - || chars[i] == '\t')) - { i++; } - - if (i == length) { break; } - - /* Read the '=' */ - if (chars[i] == '=') - { - i++; - } - else - { - /* No '=' -- go on with the next attribute. */ - continue; - } - - if (i == length) { break; } - - /* Skip spaces. */ - while (i < length && (chars[i] == ' ' - || chars[i] == '\n' - || chars[i] == '\r' - || chars[i] == '\t')) - { i++; } - - if (i == length) { break; } - - /* Read the value. */ - if (chars[i] == '"') - { - /* Skip the '"', then read up to a '"'. */ - i++; - if (i == length) { break; } - - s = i; - - while (i < length && (chars[i] != '"')) - { i++; } - } - else if (chars[i] == '\'') - { - /* Skip the '\'', then read up to a '\''. */ - i++; - if (i == length) { break; } - - s = i; - - while (i < length && (chars[i] != '\'')) - { i++; } - } - else - { - /* Read up to a space or '>'. */ - s = i; - - while (i < length - && (chars[i] != ' ' - && chars[i] != '\n' - && chars[i] != '\r' - && chars[i] != '\t' - && chars[i] != '>')) - { i++; } - } - - if (name == nil && isNameAttribute) - { - if (i == s) - { - /* I suppose this might happen if the file - contains */ - name = @""; - } - else - { - name = [NSString stringWithCharacters: &chars[s] - length: (i - s)]; - } - } - } - - if (name != nil) - { - [names addObject: name]; - } - } - i++; - } - - return names; -} - - -- (NSString *)resolveLinksUsingHTMLLinker: (HTMLLinker *)linker - logFile: (NSString *)logFile - linksMarker: (NSString *)marker -{ - /* We represent the output as a linked list. Each element in the - linked list represents a string; concatenating all the strings in - the linked list, you obtain the output. The trick is that these - strings in the linked list might actually be pointers inside the - chars array ... we are never copying stuff from the chars array - - just keeping pointers to substrings inside it - till we generate - the final string at the end ... for speed and efficiency reasons - of course. */ - struct stringFragment - { - unichar *chars; - unsigned length; - BOOL needsFreeing; - struct stringFragment *next; - } *head, *tail; - - /* The index of the beginning of the last string fragment (the tail). */ - unsigned tailIndex = 0; - - /* The temporary index. */ - unsigned i = 0; - - /* The total number of chars in the output string. We don't know - this beforehand because each time we fix up a link, we might add - or remove characters from the output. We update - totalNumberOfChars each time we close a stringFragment. */ - unsigned totalNumberOfChars = 0; - - - /* Initialize the linked list. */ - head = malloc (sizeof (struct stringFragment)); - head->chars = chars; - head->length = 0; - head->needsFreeing = NO; - head->next = NULL; - - /* The last string fragment is the first one at the beginning. */ - tail = head; - - while (i + 3 < length) - { - /* We ignore anything except stuff which begins with "') { break; } - - - /* I suppose i == s might happen if the file contains */ - if (i != s) - { - /* If href != nil && rel != nil we already found it - so don't bother. */ - if (href == nil || rel == nil) - { - NSString *attribute; - - attribute = [NSString stringWithCharacters: &chars[s] - length: (i - s)]; - /* Lowercase name so that eg, HREF and href are the - same. */ - attribute = [attribute lowercaseString]; - - if (href == nil - && [attribute isEqualToString: @"href"]) - { - isHrefAttribute = YES; - } - else if (rel == nil - && [attribute isEqualToString: @"rel"]) - { - isRelAttribute = YES; - } - } - } - - /* Skip spaces. */ - while (i < length && (chars[i] == ' ' - || chars[i] == '\n' - || chars[i] == '\r' - || chars[i] == '\t')) - { i++; } - - if (i == length) { break; } - - /* Read the '=' */ - if (chars[i] == '=') - { - i++; - } - else - { - /* No '=' -- go on with the next attribute. */ - continue; - } - - if (i == length) { break; } - - /* Skip spaces. */ - while (i < length && (chars[i] == ' ' - || chars[i] == '\n' - || chars[i] == '\r' - || chars[i] == '\t')) - { i++; } - - if (i == length) { break; } - - /* Read the value. */ - if (isHrefAttribute) - { - /* Remeber that href starts here. */ - hrefStart = i; - } - - if (chars[i] == '"') - { - /* Skip the '"', then read up to a '"'. */ - i++; - if (i == length) { break; } - - s = i; - - while (i < length && (chars[i] != '"')) - { i++; } - - if (isHrefAttribute) - { - /* Remeber that href ends here. We don't want - the ending " because we already insert those - by our own. */ - hrefEnd = i + 1; - } - } - else if (chars[i] == '\'') - { - /* Skip the '\'', then read up to a '\''. */ - i++; - if (i == length) { break; } - - s = i; - - while (i < length && (chars[i] != '\'')) - { i++; } - - if (isHrefAttribute) - { - hrefEnd = i + 1; - } - } - else - { - /* Read up to a space or '>'. */ - s = i; - - while (i < length - && (chars[i] != ' ' - && chars[i] != '\n' - && chars[i] != '\r' - && chars[i] != '\t' - && chars[i] != '>')) - { i++; } - if (isHrefAttribute) - { - /* We do want the ending space. */ - hrefEnd = i; - } - } - - if (i == length) - { - break; - } - - if (hrefEnd >= length) - { - hrefEnd = length - 1; - } - - if (isRelAttribute) - { - if (i == s) - { - /* I suppose this might happen if the file - contains */ - rel = @""; - } - else - { - rel = [NSString stringWithCharacters: &chars[s] - length: (i - s)]; - } - } - - if (isHrefAttribute) - { - if (i == s) - { - /* I suppose this might happen if the file - contains */ - href = @""; - } - else - { - href = [NSString stringWithCharacters: &chars[s] - length: (i - s)]; - } - } - } - if (href != nil && ((marker == nil) - || [rel isEqualToString: marker])) - { - /* Ok - fixup the link. */ - NSString *link; - struct stringFragment *s; - - link = [linker resolveLink: href logFile: logFile]; - - /* Add " before and after the link. */ - link = [NSString stringWithFormat: @"\"%@\"", link]; - - /* Close the previous string fragment at hrefStart. */ - tail->length = hrefStart - tailIndex; - - totalNumberOfChars += tail->length; - - /* Insert immediately afterwards a string fragment containing - the fixed up link. */ - s = malloc (sizeof (struct stringFragment)); - s->length = [link length]; - - s->chars = malloc (sizeof(unichar) * s->length); - [link getCharacters: s->chars]; - - s->needsFreeing = YES; - s->next = NULL; - - tail->next = s; - tail = s; - - totalNumberOfChars += tail->length; - - /* Now prepare the new tail to start just after the end - of the original href in the original HTML code. */ - s = malloc (sizeof (struct stringFragment)); - s->length = 0; - s->chars = &chars[hrefEnd]; - s->needsFreeing = NO; - s->next = NULL; - tail->next = s; - tail = s; - - tailIndex = hrefEnd; - } - } - i++; - } - - /* Close the last open string fragment. */ - tail->length = length - tailIndex; - totalNumberOfChars += tail->length; - - /* Generate the output. */ - { - /* Allocate space for the whole output in a single chunk now that - we know how big it should be. */ - unichar *outputChars = malloc (sizeof(unichar) * totalNumberOfChars); - unsigned j = 0; - - /* Copy into the output all the string fragments, destroying each - of them as we go on. */ - while (head != NULL) - { - struct stringFragment *s; - - memcpy (&outputChars[j], head->chars, - sizeof(unichar) * head->length); - - j += head->length; - - if (head->needsFreeing) - { - free (head->chars); - } - - s = head->next; - free (head); - head = s; - } - - return [NSString stringWithCharacters: outputChars - length: totalNumberOfChars]; - } -} - -@end - - -@implementation HTMLLinker - -- (id)initWithWarnFlag: (BOOL)v -{ - warn = v; - relocationTable = [NSMutableDictionary new]; - pathMappings = [NSMutableDictionary new]; - return [super init]; -} - -- (void)dealloc -{ - RELEASE (relocationTable); - RELEASE (pathMappings); - [super dealloc]; -} - -- (void)registerRelocationFile: (NSString *)pathOnDisk -{ - /* We only accept absolute paths. */ - if (![pathOnDisk isAbsolutePath]) - { - pathOnDisk = [currentPath stringByAppendingPathComponent: pathOnDisk]; - } - - /* Check if it's a directory; if it is, enumerate all .htmlink files - inside it, and add all of them. */ - { - BOOL isDir; - - if (![fileManager fileExistsAtPath: pathOnDisk isDirectory: &isDir]) - { - NSLog (@"Warning - relocation file '%@' not found - ignored", - pathOnDisk); - return; - } - else - { - if (isDir) - { - HTMLDirectoryEnumerator *e; - NSString *filename; - - e = [HTMLDirectoryEnumerator alloc]; - e = [e initWithBasePath: pathOnDisk]; - [e setLooksForHTMLLinkFiles: YES]; - [e setReturnsAbsolutePaths: YES]; - - while ((filename = [e nextObject]) != nil) - { - [self registerRelocationFile: filename]; - } - return; - } - } - } - - /* Now, read the mappings in the file. */ - { - NSString *file = [NSString stringWithContentsOfFile: pathOnDisk]; - NSString *path = [pathOnDisk stringByDeletingLastPathComponent]; - NSDictionary *d = [file propertyList]; - NSEnumerator *e = [d keyEnumerator]; - NSString *name; - - while ((name = [e nextObject]) != nil) - { - NSString *v = [d objectForKey: name]; - NSString *filePath; - - filePath = [path stringByAppendingPathComponent: v]; - - if (hasPathMappings) - { - /* Manage pathMappings: try to match any of the - pathMappings against pathOnDisk, and perform the path - mapping if we can match. */ - NSEnumerator *en = [pathMappings keyEnumerator]; - NSString *key; - while ((key = [en nextObject])) - { - if ([filePath hasPrefix: key]) - { - NSString *value = [pathMappings objectForKey: key]; - - filePath = [filePath substringFromIndex: [key length]]; - filePath = [value stringByAppendingPathComponent: - filePath]; - break; - } - } - } - - [relocationTable setObject: filePath forKey: name]; - } - } -} - - -- (void)registerDestinationFile: (NSString *)pathOnDisk -{ - NSString *fullPath = pathOnDisk; - - /* We only accept absolute paths. */ - if (![pathOnDisk isAbsolutePath]) - { - pathOnDisk = [currentPath stringByAppendingPathComponent: pathOnDisk]; - } - - /* Check if it's a directory; if it is, enumerate all HTML files - inside it, and add all of them. */ - { - BOOL isDir; - - if (![fileManager fileExistsAtPath: pathOnDisk isDirectory: &isDir]) - { - NSLog (@"Warning - destination file '%@' not found - ignored", - pathOnDisk); - return; - } - else - { - if (isDir) - { - HTMLDirectoryEnumerator *e; - NSString *filename; - - e = [HTMLDirectoryEnumerator alloc]; - e = [e initWithBasePath: pathOnDisk]; - [e setReturnsAbsolutePaths: YES]; - - while ((filename = [e nextObject]) != nil) - { - [self registerDestinationFile: filename]; - } - return; - } - } - } - - if (hasPathMappings) - { - /* Manage pathMappings: try to match any of the pathMappings - against pathOnDisk, and perform the path mapping if we can - match. */ - NSEnumerator *e = [pathMappings keyEnumerator]; - NSString *key; - - while ((key = [e nextObject])) - { - if ([pathOnDisk hasPrefix: key]) - { - NSString *value = [pathMappings objectForKey: key]; - - fullPath = [pathOnDisk substringFromIndex: [key length]]; - fullPath = [value stringByAppendingPathComponent: fullPath]; - break; - } - } - } - - /* Now, read all the names from the file. */ - { - NSString *file = [NSString stringWithContentsOfFile: pathOnDisk]; - HTMLParser *p = [[HTMLParser alloc] initWithCode: file]; - NSArray *names = [p names]; - unsigned i, count; - - RELEASE (p); - - count = [names count]; - - for (i = 0; i < count; i++) - { - NSString *name = [names objectAtIndex: i]; - [relocationTable setObject: fullPath forKey: name]; - } - } -} - -- (void)registerPathMappings: (NSDictionary *)dict -{ - NSEnumerator *e = [dict keyEnumerator]; - NSString *key; - - while ((key = [e nextObject])) - { - NSString *value = [dict objectForKey: key]; - [pathMappings setObject: value forKey: key]; - } - hasPathMappings = YES; -} - -- (NSString *)resolveLink: (NSString *)link - logFile: (NSString *)logFile -{ - NSString *fileLink; - NSString *nameLink; - NSString *relocatedFileLink; - NSString *file; - - /* Do nothing if this is evidently *not* a dynamical link to fixup. */ - if ([link hasPrefix: @"mailto:"] || [link hasPrefix: @"news:"]) - { - return link; - } - - { - /* Break the link string into fileLink (everything which is before - the `#'), and nameLink (everything which is after the `#', `#' - not included). For example, if link is - 'NSObject_Class.html#isa', then fileLink is - 'NSObject_Class.html' and nameLink is 'isa'. */ - - /* Look for the #. */ - NSRange hashRange = [link rangeOfString: @"#"]; - - if (hashRange.location == NSNotFound) - { - fileLink = link; - nameLink = nil; - } - else - { - fileLink = [link substringToIndex: hashRange.location]; - - if (hashRange.location + 1 < [link length]) - { - nameLink = [link substringFromIndex: (hashRange.location + 1)]; - } - else - { - nameLink = nil; - } - } - } - - /* Now lookup nameLink. */ - - /* If it's "", it is not something we can fixup. */ - if (nameLink == nil || [nameLink isEqualToString: @""]) - { - relocatedFileLink = fileLink; - } - else - { - /* Now simply look it up in our relocation table. */ - file = [relocationTable objectForKey: nameLink]; - - /* Not found - leave it unfixed. */ - if (file == nil) - { - if (warn && [fileLink length] > 0) - { - GSPrintf(stderr, @"%@: Unresolved reference to '%@'\n", - logFile, nameLink); - } - - relocatedFileLink = fileLink; - } - else - { - relocatedFileLink = file; - } - } - - /* Now build up the final relocated link, and return it. */ - if (nameLink != nil) - { - return [NSString stringWithFormat: @"%@#%@", relocatedFileLink, - nameLink]; - } - else - { - return relocatedFileLink; - } -} - -@end - -static NSDictionary * -build_relocation_table_for_directory (NSString *dir) -{ - BOOL isDir; - - if (verbose) - GSPrintf(stdout, @" Building relcation table for %@\n", dir); - - /* Check if it's a directory; if it is, enumerate all HTML files - inside it, and add all of them. */ - if (![fileManager fileExistsAtPath: dir isDirectory: &isDir]) - { - NSLog (@"%@ does not exist - exiting", dir); - exit (1); - } - else if (!isDir) - { - NSLog (@"%@ is not a directory - exiting", dir); - exit (1); - } - else - { - HTMLDirectoryEnumerator *e; - NSString *filename; - NSMutableDictionary *relocationTable; - - relocationTable = [NSMutableDictionary new]; - IF_NO_GC ([relocationTable autorelease];) - - e = [HTMLDirectoryEnumerator alloc]; - e = [e initWithBasePath: dir]; - /* The relocation table for a directory is relative to the - directory top, so that the whole directory can be moved - around without having to regenerate the .htmlink file. */ - [e setReturnsAbsolutePaths: NO]; - - while ((filename = [e nextObject]) != nil) - { - NSString *fullPath; - NSString *file; - HTMLParser *p; - NSArray *names; - unsigned i, count; - - fullPath = [dir stringByAppendingPathComponent: filename]; - - file = [NSString stringWithContentsOfFile: fullPath]; - - p = [[HTMLParser alloc] initWithCode: file]; - names = [p names]; - RELEASE (p); - count = [names count]; - - for (i = 0; i < count; i++) - { - NSString *name = [names objectAtIndex: i]; - [relocationTable setObject: filename forKey: name]; - } - } - return relocationTable; - } -} - - -static void print_help_and_exit () -{ - printf ("GNUstep HTMLLinker\n"); - printf ("Usage: HTMLLinker [options] input_files [-l relocation_file] [-d destination_file]\n"); - printf ("Multiple input files, and multiple -l and -d options are allowed.\n"); - printf (" `options' include:\n"); - printf (" --help: print this message;\n"); - printf (" --version: print version information;\n"); - printf (" --verbose: print information while processing;\n"); - printf (" -Warn NO: do not print warnings about unresolved links;\n"); - printf (" -LinksMarker xxx: only fixup links with attribute rel=xxx;\n"); - printf (" -FixupAllLinks YES: attempt to fixup all links (not only ones with the marker);\n"); - printf (" -PathMappingsFile file: read path mappings from file (a dictionary);\n"); - printf (" -PathMappings '{\"/usr/doc\"=\"/Doc\";}': use the supplied path mappings;\n"); - printf (" -BuildRelocationFileForDir yyy: build a relocation file for the dir yyy\n"); - printf (" and save it into yyy/table.htmlink. This option is special\n"); - printf (" and prevents any other processing by the linker.\n"); - exit (0); -} - -static void print_version_and_exit () -{ - printf ("GNUstep HTMLLinker (gnustep-base version %d.%d.%d)\n", - GNUSTEP_BASE_MAJOR_VERSION, - GNUSTEP_BASE_MINOR_VERSION, - GNUSTEP_BASE_SUBMINOR_VERSION); - exit (0); -} - -int main (int argc, char** argv, char** env) -{ - NSUserDefaults *userDefs; - NSArray *args; - NSMutableArray *inputFiles; - unsigned i, count; - BOOL warn, fixupAllLinks; - NSString *linksMarker; - HTMLLinker *linker; - CREATE_AUTORELEASE_POOL(pool); - -#ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); -#endif - - /* Set up the cache. */ - fileManager = [NSFileManager defaultManager]; - currentPath = [fileManager currentDirectoryPath]; - - /* Read basic defaults. */ - userDefs = [NSUserDefaults standardUserDefaults]; - - /* defaults are - - -Warn YES - -LinksMarker dynamic - -FixupAllLinks NO - */ - [userDefs registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys: - @"dynamic", @"LinksMarker", - @"YES", @"Warn", - nil]]; - - warn = [userDefs boolForKey: @"Warn"]; - fixupAllLinks = [userDefs boolForKey: @"FixupAllLinks"]; - linksMarker = [userDefs stringForKey: @"LinksMarker"]; - - - /* If -BuildRelocationFileForDir xxx is passed on the command line, - build a relocation file for the directory xxx and save it in - xxx/table.htmlink. */ - { - NSString *relFile; - relFile = [userDefs stringForKey: @"BuildRelocationFileForDir"]; - - if (relFile != nil) - { - NSDictionary *table; - NSString *outputFile; - - outputFile = [relFile stringByAppendingPathComponent: - @"table.htmlink"]; - - table = build_relocation_table_for_directory (relFile); - [table writeToFile: outputFile atomically: YES]; - exit (0); - } - } - - /* Create the linker object. */ - linker = [[HTMLLinker alloc] initWithWarnFlag: warn]; - - /* First, read all path mappings (before reading any destination - file / relocation file, so we can relocate properly. */ - - /* Read path mappings from PathMappingsFile if specified. */ - { - NSString *pathMapFile = [userDefs stringForKey: @"PathMappingsFile"]; - - if (pathMapFile != nil) - { - NSDictionary *mappings; - - mappings = [NSDictionary dictionaryWithContentsOfFile: pathMapFile]; - - if (mappings == nil) - { - NSLog (@"Warning - %@ does not contain a dictionary - ignored", - pathMapFile); - } - else - { - [linker registerPathMappings: mappings]; - } - } - } - - /* Add PathMappings specified on the command line if any. */ - { - NSDictionary *paths = [userDefs dictionaryForKey: @"PathMappings"]; - - if (paths != nil) - { - [linker registerPathMappings: paths]; - } - } - - /* All non-options on the command line are: - - input files - - destination files if they come after a -d - - relocation files if they come after a -l - - Directories as input files or destination files means 'all .html, .htm, - .HTML, .HTM files in the directory and subdirectories'. - - */ - args = [[NSProcessInfo processInfo] arguments]; - - count = [args count]; - - inputFiles = AUTORELEASE ([NSMutableArray new]); - - for (i = 1; i < count; i++) - { - NSString *arg = [args objectAtIndex: i]; - if ([arg characterAtIndex: 0] == '-') - { - NSString *opt; - opt = ([arg characterAtIndex: 1] == '-') ? - [arg substringFromIndex: 2] : [arg substringFromIndex: 1]; - if ([opt isEqualToString: @"help"] - || [opt isEqualToString: @"h"]) - { - print_help_and_exit (); - } - else if ([opt isEqualToString: @"version"] - || [opt isEqualToString: @"V"]) - { - print_version_and_exit (); - } - else if ([opt isEqualToString: @"verbose"] - || [opt isEqualToString: @"v"]) - { - verbose++; - } - else if ([opt isEqualToString: @"d"]) - { - if ((i + 1) < count) - { - i++; - /* Register a destination file. */ - [linker registerDestinationFile: [args objectAtIndex: i]]; - } - else - { - NSLog (@"Missing argument to -d"); - } - } - else if ([opt isEqualToString: @"l"]) - { - if ((i + 1) < count) - { - i++; - /* Register a destination file. */ - [linker registerRelocationFile: [args objectAtIndex: i]]; - } - else - { - NSLog (@"Missing argument to -l"); - } - } - else - { - /* A GNUstep default - skip it and the next argument. */ - if ((i + 1) < count) - { - i++; - continue; - } - } - } - else - { - BOOL isDir; - - if (![fileManager fileExistsAtPath: arg isDirectory: &isDir]) - { - NSLog (@"Warning - input file '%@' not found - ignored", arg); - } - else - { - if (isDir) - { - HTMLDirectoryEnumerator *e; - NSString *filename; - - e = [HTMLDirectoryEnumerator alloc]; - e = [e initWithBasePath: arg]; - [e setReturnsAbsolutePaths: YES]; - - while ((filename = [e nextObject]) != nil) - { - [inputFiles addObject: filename]; - } - } - else - { - [inputFiles addObject: arg]; - } - } - } - } - - count = [inputFiles count]; - - if (count == 0) - { - NSLog (@"No input files specified."); - } - - - for (i = 0; i < count; i++) - { - NSString *inputFile; - NSString *inputFileContents; - HTMLParser *parser; - - inputFile = [inputFiles objectAtIndex: i]; - if (verbose) - GSPrintf(stdout, @" %@\n", inputFile); - inputFileContents = [NSString stringWithContentsOfFile: inputFile]; - - parser = [[HTMLParser alloc] initWithCode: inputFileContents]; - inputFileContents = [parser resolveLinksUsingHTMLLinker: linker - logFile: inputFile - linksMarker: linksMarker]; - [inputFileContents writeToFile: inputFile atomically: YES]; - RELEASE (parser); - } - - RELEASE (linker); - RELEASE (pool); - - return 0; -} diff --git a/Tools/Makefile.postamble b/Tools/Makefile.postamble index dc7cb22c6..4b9818d29 100644 --- a/Tools/Makefile.postamble +++ b/Tools/Makefile.postamble @@ -6,9 +6,8 @@ # # 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 2 of the License, or (at your option) any later version. -# This program is distributed in the +# the Free Software Foundation; either version 2 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. @@ -41,50 +40,40 @@ after-install:: for file in $(DTD_FILES); do \ $(INSTALL_DATA) $$file $(dtddir)/$$file; \ done; \ - if [ ! -f $(GNUSTEP_DOC_MAN) ]; then \ - $(MKDIRS) $(GNUSTEP_DOC_MAN); \ + if [ ! -f $(GNUSTEP_DOCUMENTATION_MAN) ]; then \ + $(MKDIRS) $(GNUSTEP_DOCUMENTATION_MAN); \ fi; \ - if [ ! -f $(GNUSTEP_DOC_MAN)/man1 ]; then \ - $(MKDIRS) $(GNUSTEP_DOC_MAN)/man1; \ + if [ ! -f $(GNUSTEP_DOCUMENTATION_MAN)/man1 ]; then \ + $(MKDIRS) $(GNUSTEP_DOCUMENTATION_MAN)/man1; \ fi; \ for file in $(MAN1_PAGES) __done; do \ if [ $$file != __done ]; then \ - $(INSTALL_DATA) $$file $(GNUSTEP_DOC_MAN)/man1/$$file; \ - which gzip && rm -f $(GNUSTEP_DOC_MAN)/man1/$$file.gz \ - && gzip -9 $(GNUSTEP_DOC_MAN)/man1/$$file; \ + $(INSTALL_DATA) $$file $(GNUSTEP_DOCUMENTATION_MAN)/man1/$$file; \ + which gzip && rm -f $(GNUSTEP_DOCUMENTATION_MAN)/man1/$$file.gz \ + && gzip -9 $(GNUSTEP_DOCUMENTATION_MAN)/man1/$$file; \ fi; \ done; \ - if [ ! -f $(GNUSTEP_DOC_MAN)/man8 ]; then \ - $(MKDIRS) $(GNUSTEP_DOC_MAN)/man8; \ + if [ ! -f $(GNUSTEP_DOCUMENTATION_MAN)/man8 ]; then \ + $(MKDIRS) $(GNUSTEP_DOCUMENTATION_MAN)/man8; \ fi; \ for file in $(MAN8_PAGES); do \ - $(INSTALL_DATA) $$file $(GNUSTEP_DOC_MAN)/man8/$$file; \ - which gzip && rm -f $(GNUSTEP_DOC_MAN)/man8/$$file.gz \ - && gzip -9 $(GNUSTEP_DOC_MAN)/man8/$$file; \ - done$(END_ECHO) -ifeq ($(GNUSTEP_INSTALL_GDOMAP_AS_SETUID),no) - $(ECHO_NOTHING)echo ""; \ - echo "Note: gdomap has not been made setuid to root, so you must"; \ - echo "start it up as root. Most often this is done at system boot"; \ - echo "by executing 'gdomap -p' in the startup scripts."; \ - echo ""$(END_ECHO) -else - $(ECHO_NOTHING)echo ""; \ + $(INSTALL_DATA) $$file $(GNUSTEP_DOCUMENTATION_MAN)/man8/$$file; \ + which gzip && rm -f $(GNUSTEP_DOCUMENTATION_MAN)/man8/$$file.gz \ + && gzip -9 $(GNUSTEP_DOCUMENTATION_MAN)/man8/$$file; \ + done; \ if [ "`$(WHOAMI)`" != "root" ]; then \ echo ""; \ echo "************************************************************"; \ - echo "WARNING: gdomap has not been made setuid to root ..."; \ - echo "NOTE: Unless gdomap is started as root at system boot time,"; \ - echo "it MUST either be installed owned by root and with the"; \ - echo "'s-bit' or you must have defined 'GDOMAP_PORT_OVERRIDE' in"; \ + echo "FAILED gdomap installation - please re-run this as root ..."; \ + echo "NOTE: gdomap MUST be installed owned by root and with"; \ + echo "the 's-bit' set unless you defined 'GDOMAP_PORT_OVERRIDE' in"; \ echo "gdomap.h before compiling gdomap.c and NSPortNameServer.m"; \ - echo "If either of those cases applies, ignore this message."; \ + echo "in which case you should install it by hand."; \ + echo "If you have installed by hand, ignore this message."; \ echo "************************************************************"; \ echo ""; \ else \ echo "Making gdomap in $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_DIR) setuid to root"; \ - echo "WARNING: if possible, you should remove the setuid flag and"; \ - echo "WARNING: have gdomap started as root at machine boot time."; \ $(INSTALL) -m 05755 $(GNUSTEP_OBJ_DIR)/gdomap $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_DIR); \ fi; \ echo "************************************************************"; \ @@ -97,7 +86,6 @@ else echo "startup command to your system boot scripts!"; \ echo "************************************************************"; \ $(END_ECHO) -endif # Things to do before uninstalling before-uninstall:: @@ -106,14 +94,14 @@ before-uninstall:: done -rmdir $(dtddir) for file in $(MAN1_PAGES); do \ - rm -f $(GNUSTEP_DOC_MAN)/man1/$$file.gz; \ + rm -f $(GNUSTEP_DOCUMENTATION_MAN)/man1/$$file.gz; \ done; - -rmdir $(GNUSTEP_DOC_MAN)/man1; + -rmdir $(GNUSTEP_DOCUMENTATION_MAN)/man1; for file in $(MAN8_PAGES); do \ - rm -f $(GNUSTEP_DOC_MAN)/man8/$$file.gz; \ + rm -f $(GNUSTEP_DOCUMENTATION_MAN)/man8/$$file.gz; \ done; - -rmdir $(GNUSTEP_DOC_MAN)/man8; - -rmdir $(GNUSTEP_DOC_MAN); + -rmdir $(GNUSTEP_DOCUMENTATION_MAN)/man8; + -rmdir $(GNUSTEP_DOCUMENTATION_MAN); # Things to do after uninstalling # after-uninstall:: @@ -137,3 +125,20 @@ before-uninstall:: # after-check:: +# +# If building with the Apple Foundation, we don't include the base 'Headers' +# directory in the includes path, but we need the additions headers so we +# link to them from the current directory. +# + +ifeq ($(FOUNDATION_LIB),apple) + +before-all:: + rm -f GNUstepBase + ln -s ../Headers/GNUstepBase GNUstepBase + +after-clean:: + rm -f GNUstepBase + +endif + diff --git a/Tools/Makefile.preamble b/Tools/Makefile.preamble index bfdd03277..73a7c21a3 100644 --- a/Tools/Makefile.preamble +++ b/Tools/Makefile.preamble @@ -37,17 +37,16 @@ # # Additional flags to pass to the preprocessor -ADDITIONAL_CPPFLAGS += $(WARN_FLAGS) +# ADDITIONAL_CPPFLAGS += # Additional flags to pass to the Objective-C compiler -#ADDITIONAL_OBJCFLAGS += +ADDITIONAL_OBJCFLAGS += -Wall # Additional flags to pass to the C compiler #ADDITIONAL_CFLAGS += # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../Headers/Additions \ - -I../Source/$(GNUSTEP_TARGET_DIR) +ADDITIONAL_INCLUDE_DIRS += -I../Source/$(GNUSTEP_TARGET_DIR) ifeq ($(FOUNDATION_LIB),gnu) ADDITIONAL_INCLUDE_DIRS += -I../Headers diff --git a/Tools/autogsdoc.1 b/Tools/autogsdoc.1 index a7b3e2633..ace596001 100644 --- a/Tools/autogsdoc.1 +++ b/Tools/autogsdoc.1 @@ -609,6 +609,6 @@ This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B autogsdoc -was written by Richard Frith-Macdonald +was written by Richard Frith-McDonald .P This manual page added by Adrian Robert . diff --git a/Tools/autogsdoc.m b/Tools/autogsdoc.m index da8755bf2..0b3d10811 100644 --- a/Tools/autogsdoc.m +++ b/Tools/autogsdoc.m @@ -10,11 +10,11 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -86,12 +86,7 @@ comment text is reformatted and then inserted into the output.
Where multiple comments are associated with the same item, they are joined together with a line break (<br />) between each if - necessary.
- Within a comment the special markup <ignore> and </ignore> - may be used to tell autogsdoc to completely ignore the sourcecode - between these two pieces of markup (ie. the parser will skip from the - point just before it is told to start ignoring, to just after the point - where it is told to stop (or end of file if that occurs first). + necessary.

The tool can easily be used to document programs as well as libraries, @@ -552,7 +547,7 @@ <?xml version="1.0"?> <!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 1.0.3//EN" - "http://www.gnustep.org/gsdoc-1_0_3.dtd"> + "http://www.gnustep.org/gsdoc-1_0_3.xml"> <gsdoc base="index"> <head> <title>My project reference</title> @@ -597,25 +592,16 @@ */ -#import "common.h" +#include -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSSet.h" -#import "Foundation/NSUserDefaults.h" - -#import "AGSParser.h" -#import "AGSOutput.h" -#import "AGSIndex.h" -#import "AGSHtml.h" -#import "GNUstepBase/GSObjCRuntime.h" -#import "GNUstepBase/NSString+GNUstepBase.h" -#import "GNUstepBase/NSMutableString+GNUstepBase.h" +#include "AGSParser.h" +#include "AGSOutput.h" +#include "AGSIndex.h" +#include "AGSHtml.h" +#include "GNUstepBase/GNUstep.h" +#ifdef NeXT_Foundation_LIBRARY +#include "GNUstepBase/GSCategories.h" +#endif /** Invokes the autogsdoc tool. */ int @@ -718,7 +704,7 @@ main(int argc, char **argv, char **env) */ #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; #endif #if GS_WITH_GC == 0 @@ -808,11 +794,6 @@ main(int argc, char **argv, char **env) @"\t\tBOOL\t(NO)\n\tif YES, create documentation pages " @"for display in HTML frames", @"MakeFrames", - @"\t\tString\t(nil)\n\tIf set, look for DTDs in the given directory", - @"DTDs", - @"\t\tBOOL\t(NO)\n\tif YES, wrap paragraphs delimited by \\n\\n in " - @"

tags when possible", - @"GenerateParagraphMarkup", nil]; argSet = [NSSet setWithArray: [argsRecognized allKeys]]; argsGiven = [[NSProcessInfo processInfo] arguments]; @@ -857,10 +838,6 @@ main(int argc, char **argv, char **env) mgr = [NSFileManager defaultManager]; - if ([GSXMLParser respondsToSelector: @selector(setDTDs:)]) - { - [GSXMLParser setDTDs: [defs stringForKey: @"DTDs"]]; - } verbose = [defs boolForKey: @"Verbose"]; warn = [defs boolForKey: @"Warn"]; @@ -1232,7 +1209,6 @@ main(int argc, char **argv, char **env) NSString *hfile = [sFiles objectAtIndex: i]; NSString *gsdocfile; NSString *file; - NSString *sourceName = nil; NSMutableArray *a; NSDictionary *attrs; NSDate *sDate = nil; @@ -1283,7 +1259,6 @@ main(int argc, char **argv, char **env) */ a = [projectRefs sourcesForHeader: hfile]; [a insertObject: hfile atIndex: 0]; - [projectRefs setSources: a forHeader: hfile]; for (j = 0; j < [a count]; j++) { NSString *sfile = [a objectAtIndex: j]; @@ -1294,7 +1269,7 @@ main(int argc, char **argv, char **env) if (sDate == nil || [d earlierDate: sDate] == sDate) { sDate = d; - IF_NO_GC([[sDate retain] autorelease];) + AUTORELEASE(RETAIN(sDate)); } } if (verbose == YES) @@ -1311,7 +1286,6 @@ main(int argc, char **argv, char **env) if ([a count] == 0) { [a insertObject: gsdocfile atIndex: 0]; - [projectRefs setOutputs: a forHeader: hfile]; } for (j = 0; j < [a count]; j++) { @@ -1322,7 +1296,7 @@ main(int argc, char **argv, char **env) if (gDate == nil || [d laterDate: gDate] == gDate) { gDate = d; - IF_NO_GC([[gDate retain] autorelease];) + AUTORELEASE(RETAIN(gDate)); } } if (verbose == YES) @@ -1387,24 +1361,7 @@ main(int argc, char **argv, char **env) } [projectRefs setOutputs: a forHeader: hfile]; } - a = [parser sources]; - /* - * Collect any matching .m files provided as autogsdoc arguments - * for the current header (hfile). - */ - sourceName = [[hfile lastPathComponent] - stringByDeletingPathExtension]; - sourceName = [sourceName stringByAppendingPathExtension: @"m"]; - for (j = 0; j < [sFiles count]; j++) - { - NSString *sourcePath = [sFiles objectAtIndex: j]; - if ([sourcePath hasSuffix: sourceName] - && [mgr isReadableFileAtPath: sourcePath]) - { - [a addObject: sourcePath]; - } - } if ([a count] > 0) { [projectRefs setSources: a forHeader: hfile]; @@ -1538,7 +1495,7 @@ main(int argc, char **argv, char **env) { attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES]; gDate = [attrs fileModificationDate]; - IF_NO_GC([[gDate retain] autorelease];) + AUTORELEASE(RETAIN(gDate)); } /* @@ -1644,7 +1601,7 @@ main(int argc, char **argv, char **env) systemProjects = @""; } projects = [[defs dictionaryForKey: @"Projects"] mutableCopy]; - IF_NO_GC([projects autorelease];) + AUTORELEASE(projects); /* * Merge any system project references. @@ -1817,7 +1774,7 @@ main(int argc, char **argv, char **env) // skeleton for table of contents files [tocSkel setString: @"\n" -@"\n" +@"\n" @"\n" @" \n" @" [typeU]\n" @@ -1923,7 +1880,7 @@ main(int argc, char **argv, char **env) @"named %@ in the documentation output directory.\n" @"Then include this file in the arguments to autogsdoc.\n\n", prjFile); [prjFileContents setString: @"\n" -@"\n" +@"\n" @"\n" @" \n" @" The [prjName] Project\n" @@ -2005,10 +1962,10 @@ main(int argc, char **argv, char **env) */ attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES]; gDate = [attrs fileModificationDate]; - IF_NO_GC([[gDate retain] autorelease];) + AUTORELEASE(RETAIN(gDate)); attrs = [mgr fileAttributesAtPath: htmlfile traverseLink: YES]; hDate = [attrs fileModificationDate]; - IF_NO_GC([[hDate retain] autorelease];) + AUTORELEASE(RETAIN(hDate)); } if ([mgr isReadableFileAtPath: gsdocfile] == YES) diff --git a/Tools/cvtenc.1 b/Tools/cvtenc.1 index 8c0668adc..532aa9049 100644 --- a/Tools/cvtenc.1 +++ b/Tools/cvtenc.1 @@ -16,9 +16,10 @@ cvtenc \- file encoding converter .SH DESCRIPTION .P Converts a file encoded in a specified or default non-unicode encoding to -unicode, or, if the file is already in unicode, converts it to a specified -or default non-unicode encoding. The converted text is printed to standard -out. +unicode (UTF16), or, if the file is already in unicode, converts it to a +specified or default non-unicode encoding. +The converted text is printed to standard out. +If the filename is a hyphen then this tool reads from standard input. .SH OPTIONS .IP "\fB\-Encoding\fR \fI encoding\fR" 4 @@ -34,14 +35,21 @@ escape sequences (as in property lists). Specify '-EscapeOut YES' (the default is 'NO') to generate \\u escape sequences (as in property lists) in the output. Note, this might produce unexpected results for some encodings. +.IP "\fB\-Unicode\fR \fIIN|OUT\fR" 4 +Specify '-Unicode IN' (or '-Unicode OUT') to control the direction of +conversion rather than having the tool guess it on the basis of the content +it reads. Using '-Unicode IN' means that the tool reads UTF16 data and +writes C-String data, while using '-Unicode OUT' merans that the tool reads +C-String data and writes UTF16 data. .SH HISTORY .RS 0 Written in 2002. +Minr update in 2010. .P This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B cvtenc -was written by Richard Frith-Macdonald +was written by Richard Frith-McDonald diff --git a/Tools/cvtenc.m b/Tools/cvtenc.m index 8bfe8299a..0c4a8b811 100644 --- a/Tools/cvtenc.m +++ b/Tools/cvtenc.m @@ -6,30 +6,33 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSException.h" -#import "Foundation/NSString.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSAutoreleasePool.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#import "GNUstepBase/NSString+GNUstepBase.h" +#import "GNUstepBase/GSMime.h" #ifdef NeXT_Foundation_LIBRARY -#import "GNUstepBase/Additions.h" +#include "GNUstepBase/GSCategories.h" #endif #include @@ -63,7 +66,7 @@ main(int argc, char** argv, char **env) NSStringEncoding enc = 0; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; #endif pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; @@ -83,7 +86,7 @@ main(int argc, char** argv, char **env) { enc = [NSString defaultCStringEncoding]; } - else + else if (0 == (enc = [GSMimeDocument encodingFromCharset: n])) { const NSStringEncoding *e; NSMutableString *names; @@ -94,7 +97,7 @@ main(int argc, char** argv, char **env) { NSString *name = [NSString localizedNameOfStringEncoding: *e]; - [names appendFormat: @" %@\n", name]; + [names appendFormat: @" '%@'\n", name]; if ([n isEqual: name] == YES) { enc = *e; @@ -105,17 +108,39 @@ main(int argc, char** argv, char **env) if (enc == 0) { NSLog(@"defaults: unable to find encoding '%@'!\n" - @"Known encoding names are -\n%@", n, names); + @"Localised encoding names are -\n%@", n, names); [pool release]; exit(EXIT_SUCCESS); } } + n = [[NSUserDefaults standardUserDefaults] stringForKey: @"Unicode"]; + n = [[n stringByTrimmingSpaces] lowercaseString]; + if ([n length] > 0) + { + if ([n isEqual: @"in"] || [n isEqual: @"i"]) + { + n = @"i"; + } + else if ([n isEqual: @"out"] || [n isEqual: @"o"]) + { + n = @"o"; + } + else + { + n = nil; + } + } + else + { + n = nil; + } + for (i = 1; found == NO && i < [args count]; i++) { NSString *file = [args objectAtIndex: i]; - if ([file hasPrefix: @"-"] == YES) + if ([file hasPrefix: @"-"] == YES && NO == [file isEqual: @"-"]) { i++; continue; @@ -125,7 +150,15 @@ main(int argc, char** argv, char **env) { NSData *myData; - myData = [[NSData alloc] initWithContentsOfFile: file]; + if (YES == [file isEqual: @"-"]) + { + myData = [[[NSFileHandle fileHandleWithStandardInput] + readDataToEndOfFile] retain]; + } + else + { + myData = [[NSData alloc] initWithContentsOfFile: file]; + } if (myData == nil) { NSLog(@"File read operation failed for %@.", file); @@ -138,13 +171,30 @@ main(int argc, char** argv, char **env) NSStringEncoding oEnc; NSString *myString; - if (l > 1 && (*b == 0xFFFE || *b == 0xFEFF)) + if (nil == n) { + if (l > 1 && (*b == 0xFFFE || *b == 0xFEFF)) + { + iEnc = NSUnicodeStringEncoding; + oEnc = enc; + } + else + { + iEnc = enc; + oEnc = NSUnicodeStringEncoding; + } + } + else if ([n isEqualToString: @"i"]) + { + /* Unicode (UTF16) in + */ iEnc = NSUnicodeStringEncoding; oEnc = enc; } else { + /* Unicode (UTF16) out + */ iEnc = enc; oEnc = NSUnicodeStringEncoding; } @@ -231,13 +281,13 @@ main(int argc, char** argv, char **env) } else { - sprintf(&c[o], "\\U%04x", u[i]); + snprintf(&c[o], 6, "\\U%04x", u[i]); o += 6; } } NSZoneFree(z, u); - myData = [[NSData alloc] initWithBytesNoCopy: c - length: o]; + myData = [[[NSData alloc] + initWithBytesNoCopy: c length: o] autorelease]; } else if (eIn == YES) { @@ -258,10 +308,12 @@ main(int argc, char** argv, char **env) else { NSFileHandle *out; + CREATE_AUTORELEASE_POOL(arp); out = [NSFileHandle fileHandleWithStandardOutput]; [out writeData: myData]; [out synchronizeFile]; + RELEASE(arp); } } } @@ -277,13 +329,20 @@ main(int argc, char** argv, char **env) { NSLog(@"\nThis utility expects a filename as an argument.\n" @"It reads the file, and writes it to STDOUT after converting it\n" - @"to unicode from C string encoding or vice versa.\n" - @"You can supply a '-Encoding name' option to specify the C string\n" + @"to unicode (UTF16) from C-string encoding or vice versa.\n" + @"You can use '-' as the filename argument to read from STDIN.\n" + @"You can supply a '-Encoding name' option to specify the C-string\n" @"encoding to be used, if you don't want to use the default.\n" + @"If you supply an unknown encoding the tool will print a list\n" + @"of all the known encodings.\n" @"You can supply a '-EscapeIn YES' option to specify that input\n" @"should be parsed for \\U escape sequences (as in property lists).\n" @"You can supply a '-EscapeOut YES' option to specify that output\n" - @"should be ascii with \\U escape sequences (for property lists).\n"); + @"should be ascii with \\U escape sequences (for property lists).\n" + @"You can supply a '-Unicode in/out' option to specify that the\n" + @"conversion is from/to unicode (UTF16). This suppresses the normal\n" + @"behavior of guessing the direction of conversion from the content\n" + @"of the incoming data.\n"); } [pool release]; return 0; diff --git a/Tools/defaults.1 b/Tools/defaults.1 index 28e7251ed..3b0c4afe1 100644 --- a/Tools/defaults.1 +++ b/Tools/defaults.1 @@ -98,4 +98,4 @@ This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B defaults -was written by Richard Frith-Macdonald +was written by Richard Frith-McDonald diff --git a/Tools/defaults.m b/Tools/defaults.m index 136afe313..a1a0c1399 100644 --- a/Tools/defaults.m +++ b/Tools/defaults.m @@ -6,30 +6,31 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include - -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSPathUtilities.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define GSEXIT_SUCCESS EXIT_SUCCESS #define GSEXIT_FAILURE EXIT_FAILURE @@ -55,7 +56,7 @@ static NSString *input(char **ptr) { if (*tmp == '\'') { - strcpy(&tmp[-1], tmp); + memmove(&tmp[-1], tmp, strlen(tmp) + 1); } else { @@ -133,7 +134,7 @@ main(int argc, char** argv, char **env) int derror = 0; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif [NSObject enableDoubleReleaseCheck: YES]; pool = [NSAutoreleasePool new]; @@ -400,72 +401,6 @@ main(int argc, char** argv, char **env) } } - domains = [defs volatileDomainNames]; - for (i = 0; i < [domains count]; i++) - { - NSString *domainName = [domains objectAtIndex: i]; - -#if 0 - if (owner == nil || [owner isEqual: domainName]) -#else - if ([owner isEqual: domainName]) -#endif - { - NSDictionary *dom; - - dom = [defs volatileDomainForName: domainName]; - if (dom) - { - if (name == nil) - { - NSEnumerator *enumerator; - NSString *key; - - enumerator = [dom keyEnumerator]; - while ((key = [enumerator nextObject]) != nil) - { - id obj = [dom objectForKey: key]; - const char *ptr; - - ptr = [domainName UTF8String]; - output(ptr); - putchar(' '); - - ptr = [key UTF8String]; - output(ptr); - putchar(' '); - - ptr = [[obj descriptionWithLocale: locale - indent: 0] UTF8String]; - output(ptr); - putchar('\n'); - } - } - else - { - id obj = [dom objectForKey: name]; - - if (obj) - { - const char *ptr; - - ptr = [domainName UTF8String]; - output(ptr); - putchar(' '); - ptr = [name UTF8String]; - output(ptr); - putchar(' '); - ptr = [[obj descriptionWithLocale: locale indent: 0] - UTF8String]; - output(ptr); - putchar('\n'); - found = YES; - } - } - } - } - } - if (found == NO && name != nil) { GSPrintf(stderr, @"defaults read: couldn't read default\n"); @@ -481,7 +416,7 @@ main(int argc, char** argv, char **env) int size = BUFSIZ; int got; int off = 0; - char *buf = objc_malloc(size); + char *buf = malloc(size); char *ptr; /* @@ -492,7 +427,7 @@ main(int argc, char** argv, char **env) { off += BUFSIZ; size += BUFSIZ; - buf = objc_realloc(buf, size); + buf = realloc(buf, size); if (buf == 0) { GSPrintf(stderr, @@ -657,7 +592,8 @@ main(int argc, char** argv, char **env) if ([defs synchronize] == NO) { GSPrintf(stderr, - @"defaults: unable to write to defaults database\n"); + @"defaults: unable to write to defaults database - %s\n", + strerror(errno)); } } else if ([[args objectAtIndex: i] isEqual: @"delete"]) @@ -667,14 +603,14 @@ main(int argc, char** argv, char **env) int size = BUFSIZ; int got; int off = 0; - char *buf = objc_malloc(size); + char *buf = malloc(size); char *ptr; while ((got = fread(buf + off, 1, BUFSIZ, stdin)) == BUFSIZ) { off += BUFSIZ; size += BUFSIZ; - buf = objc_realloc(buf, size); + buf = realloc(buf, size); if (buf == 0) { GSPrintf(stderr, @@ -781,7 +717,8 @@ main(int argc, char** argv, char **env) if ([defs synchronize] == NO) { GSPrintf(stderr, - @"defaults: unable to write to defaults database\n"); + @"defaults: unable to write to defaults database - %s\n", + strerror(errno)); } } else if ([[args objectAtIndex: i] isEqual: @"domains"]) diff --git a/Tools/gdnc.1 b/Tools/gdnc.1 index 7a0758e98..82367a95e 100644 --- a/Tools/gdnc.1 +++ b/Tools/gdnc.1 @@ -78,6 +78,6 @@ This manual page first appeared in gnustep-base 1.7.2 (July 2003). .P .SH AUTHORS .B gdnc -was written by Richard Frith-Macdonald . +was written by Richard Frith-McDonald . .PP This man page was written by Martin Brecher . diff --git a/Tools/gdnc.h b/Tools/gdnc.h index 773870596..7d6d063fe 100644 --- a/Tools/gdnc.h +++ b/Tools/gdnc.h @@ -4,18 +4,21 @@ Written by: Richard Frith-Macdonald Created: October 1998 - This file is part of the GNUstep Project + This file is part of the GNUstep Base Library. - 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 + This library 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 2 of the License, or (at your option) any later version. - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. - If not, write to the Free Software Foundation, - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + This library 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 library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ #define GDNC_SERVICE @"GDNCServer" @@ -26,11 +29,11 @@ object: (NSString*)object userInfo: (NSData*)info selector: (NSString*)aSelector - to: (uint64_t)observer; + to: (unsigned long)observer; @end @protocol GDNCProtocol -- (void) addObserver: (uint64_t)anObserver +- (void) addObserver: (unsigned long)anObserver selector: (NSString*)aSelector name: (NSString*)notificationname object: (NSString*)anObject @@ -45,7 +48,7 @@ - (void) registerClient: (id)client; -- (void) removeObserver: (uint64_t)anObserver +- (void) removeObserver: (unsigned long)anObserver name: (NSString*)notificationname object: (NSString*)anObject for: (id)client; diff --git a/Tools/gdnc.m b/Tools/gdnc.m index aec892d75..a87140cd5 100644 --- a/Tools/gdnc.m +++ b/Tools/gdnc.m @@ -1,47 +1,30 @@ -/* Copyright (C) 1998 Free Software Foundation, Inc. +/** Implementation of GNUstep Distributed Notification Center + Copyright (C) 1998 Free Software Foundation, Inc. Written by: Richard Frith-Macdonald Created: October 1998 This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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 2 of the License, or (at your option) any later version. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" +#include "config.h" +#include -#include -#include +#include +#include -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSBundle.h" -#import "Foundation/NSConnection.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDistantObject.h" -#import "Foundation/NSDistributedNotificationCenter.h" -#import "Foundation/NSException.h" -#import "Foundation/NSHashTable.h" -#import "Foundation/NSHost.h" -#import "Foundation/NSNotification.h" -#import "Foundation/NSPort.h" -#import "Foundation/NSPortNameServer.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSRunLoop.h" -#import "Foundation/NSTask.h" -#import "Foundation/NSUserDefaults.h" - - -#if defined(__MINGW__) +#if defined(__MINGW32__) #include "process.h" #endif @@ -56,20 +39,20 @@ #define NSIG 32 #endif -static BOOL debugging = NO; static BOOL is_daemon = NO; /* Currently running as daemon. */ static BOOL auto_stop = NO; /* Should we shut down when unused? */ +static char ebuf[2048]; #ifdef HAVE_SYSLOG static int log_priority = LOG_DEBUG; static void -gdnc_log (int prio, const char *ebuf) +gdnc_log (int prio) { if (is_daemon) { - syslog (log_priority | prio, "%s", ebuf); + syslog (log_priority | prio, ebuf); } else if (prio == LOG_INFO) { @@ -103,8 +86,8 @@ gdnc_log (int prio, const char *ebuf) #define LOG_ERR 1 #define LOG_INFO 0 #define LOG_WARNING 0 -static void -gdnc_log (int prio, const char *ebuf) +void +gdnc_log (int prio) { write (2, ebuf, strlen (ebuf)); write (2, "\n", 1); @@ -177,19 +160,20 @@ ihandler(int sig) object: (NSString*)object userInfo: (NSData*)info selector: (NSString*)aSelector - to: (uint64_t)observer; + to: (unsigned long)observer; @end @implementation NSDistributedNotificationCenterGDNCDummy - (oneway void) postNotificationName: (NSString*)name object: (NSString*)object userInfo: (NSData*)info selector: (NSString*)aSelector - to: (uint64_t)observer + to: (unsigned long)observer { return; } @end + @interface GDNCNotification : NSObject { @public @@ -210,11 +194,6 @@ ihandler(int sig) RELEASE(info); [super dealloc]; } -- (NSString*) description -{ - return [NSString stringWithFormat: @"%@ Name:'%@' Object:'%@' Info:'%@'", - [super description], name, object, info]; -} + (GDNCNotification*) notificationWithName: (NSString*)notificationName object: (NSString*)notificationObject data: (NSData*)notificationData @@ -263,7 +242,7 @@ ihandler(int sig) @interface GDNCObserver : NSObject { @public - uint64_t observer; + unsigned observer; NSString *notificationName; NSString *notificationObject; NSString *selector; @@ -301,7 +280,7 @@ ihandler(int sig) NSMutableDictionary *observersForObjects; } -- (void) addObserver: (uint64_t)anObserver +- (void) addObserver: (unsigned long)anObserver selector: (NSString*)aSelector name: (NSString*)notificationName object: (NSString*)anObject @@ -313,17 +292,17 @@ ihandler(int sig) - (id) connectionBecameInvalid: (NSNotification*)notification; -- (oneway void) postNotificationName: (NSString*)notificationName - object: (NSString*)notificationObject - userInfo: (NSData*)d - deliverImmediately: (BOOL)deliverImmediately - for: (id)client; +- (void) postNotificationName: (NSString*)notificationName + object: (NSString*)notificationObject + userInfo: (NSData*)d + deliverImmediately: (BOOL)deliverImmediately + for: (id)client; - (void) removeObserver: (GDNCObserver*)observer; - (void) removeObserversForClients: (NSMapTable*)clients; -- (void) removeObserver: (uint64_t)anObserver +- (void) removeObserver: (unsigned long)anObserver name: (NSString*)notificationName object: (NSString*)notificationObject for: (id)client; @@ -493,7 +472,6 @@ ihandler(int sig) name = [service stringByAppendingFormat: @"-%@", name]; if ([ns registerPort: port forName: name] == NO) { - NSLog(@"gdnc - failed to register as %@", name); } } a = [host addresses]; @@ -505,7 +483,6 @@ ihandler(int sig) name = [service stringByAppendingFormat: @"-%@", name]; if ([ns registerPort: port forName: name] == NO) { - NSLog(@"gdnc - failed to register as %@", name); } } } @@ -522,7 +499,7 @@ ihandler(int sig) return self; } -- (void) addObserver: (uint64_t)anObserver +- (void) addObserver: (unsigned long)anObserver selector: (NSString*)aSelector name: (NSString*)notificationName object: (NSString*)anObject @@ -534,10 +511,6 @@ ihandler(int sig) GDNCObserver *obs; NSConnection *connection; - if (debugging) - NSLog(@"Adding observer %llu for %@ %@", - anObserver, notificationName, anObject); - connection = [(NSDistantObject*)client connectionForProxy]; clients = (NSMapTable*)NSMapGet(connections, connection); if (clients == 0) @@ -710,11 +683,11 @@ ihandler(int sig) RELEASE(info); } -- (oneway void) postNotificationName: (NSString*)notificationName - object: (NSString*)notificationObject - userInfo: (NSData*)d - deliverImmediately: (BOOL)deliverImmediately - for: (id)client +- (void) postNotificationName: (NSString*)notificationName + object: (NSString*)notificationObject + userInfo: (NSData*)d + deliverImmediately: (BOOL)deliverImmediately + for: (id)client { NSMutableArray *observers = [NSMutableArray array]; NSMutableArray *byName; @@ -817,8 +790,6 @@ ihandler(int sig) NS_DURING { [obs->queue removeObjectAtIndex: 0]; - if (debugging) - NSLog(@"Posting to observer %llu with %@", obs->observer, n); [obs->client->client postNotificationName: n->name object: n->object userInfo: n->info @@ -828,8 +799,6 @@ ihandler(int sig) NS_HANDLER { obs = nil; - NSLog(@"Problem posting notification to client: %@", - localException); } NS_ENDHANDLER RELEASE(n); @@ -840,11 +809,6 @@ ihandler(int sig) - (void) removeObserver: (GDNCObserver*)observer { - if (debugging) - NSLog(@"Removing observer %llu for %@ %@", - observer->observer, observer->notificationName, - observer->notificationObject); - if (observer->notificationObject) { NSMutableArray *objList; @@ -886,7 +850,7 @@ ihandler(int sig) } } -- (void) removeObserver: (uint64_t)anObserver +- (void) removeObserver: (unsigned long)anObserver name: (NSString*)notificationName object: (NSString*)notificationObject for: (id)client @@ -1071,12 +1035,13 @@ main(int argc, char** argv, char** env) { GDNCServer *server; BOOL subtask = YES; + BOOL debugging = NO; NSProcessInfo *pInfo; NSMutableArray *args; CREATE_AUTORELEASE_POOL(pool); #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; #endif [NSObject enableDoubleReleaseCheck: YES]; pInfo = [NSProcessInfo processInfo]; @@ -1137,7 +1102,7 @@ main(int argc, char** argv, char** env) } NS_HANDLER { - gdnc_log(LOG_CRIT, [[localException description] UTF8String]); + gdnc_log(LOG_CRIT); DESTROY(t); } NS_ENDHANDLER @@ -1154,13 +1119,12 @@ main(int argc, char** argv, char** env) for (sym = 0; sym < NSIG; sym++) { - if (sym == SIGABRT) continue; #ifdef SIGPROF if (sym == SIGPROF) continue; #endif signal(sym, ihandler); } -#ifndef __MINGW__ +#ifndef __MINGW32__ signal(SIGPIPE, SIG_IGN); signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); @@ -1182,7 +1146,7 @@ main(int argc, char** argv, char** env) */ [[NSFileHandle fileHandleWithStandardInput] closeFile]; [[NSFileHandle fileHandleWithStandardOutput] closeFile]; -#ifndef __MINGW__ +#ifndef __MINGW32__ if (debugging == NO) { [[NSFileHandle fileHandleWithStandardError] closeFile]; diff --git a/Tools/gdomap.8 b/Tools/gdomap.8 index fa6731fc9..3975031e8 100644 --- a/Tools/gdomap.8 +++ b/Tools/gdomap.8 @@ -42,8 +42,8 @@ gdomap \- GNUstep Distributed Objects name server The gdomap daemon is used by GNUstep programs to look up distributed objects of processes running on the local machine as well as across the network. This manual page explains the usage of gdomap. For design and implementation -information (nad special notes for packagers), please see the HTML -documentation installed in $GNUSTEP_SYSTEM_DOC, under Command-line Tools. +information, please see the HTML documentation installed in +$GNUSTEP_SYSTEM_DOC, under Command-line Tools. .P Usually the gdomap daemon is started at system boot time and binds itself to port 538. See the @@ -51,7 +51,7 @@ port 538. See the for a sample startup script. .P -By default gdomap probes every machine on the local network to see if there +Gdomap normally probes every machine on the local network to see if there is a copy of gdomap running on it. This is done for class-C networks and subnets of class-C networks. If your host is on a class-B or class-A net then the default behaviour is to treat it as a class-C net and probe only @@ -171,7 +171,7 @@ This manual page first appeared in gnustep-base 1.7.1 (June 2003). .P .SH AUTHORS .B gdomap -was written by Richard Frith-Macdonald +was written by Richard Frith-McDonald .PP This manual page was put together by Martin Brecher . diff --git a/Tools/gdomap.c b/Tools/gdomap.c index ce918470f..7a9fee665 100644 --- a/Tools/gdomap.c +++ b/Tools/gdomap.c @@ -22,34 +22,29 @@ Boston, MA 02111 USA. */ -/* Ported to mingw 07/12/00 by Bjorn Giesler */ +/* Ported to mingw 07/12/00 by Björn Giesler */ #include "config.h" - -#if !defined(__MINGW__) -# if defined(__MINGW32__) || defined(__MINGW64__) -# define __MINGW__ -# endif -#endif - #include #include #include +#ifdef HAVE_STDINT_H +#include +#endif #include /* for gethostname() */ -#ifndef __MINGW__ +#ifndef __MINGW32__ #include /* for MAXHOSTNAMELEN */ #include #include #include #include /* for inet_ntoa() */ -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ #include #include #include /* for strchr() */ #include /* for strchr() */ #include -#if defined(__MINGW__) -#include +#ifdef __MINGW32__ #include #include #include @@ -62,13 +57,13 @@ #include #include #include -#if defined(HAVE_TIME_H) +#ifdef HAVE_TIME_H #include #endif -#if defined(HAVE_PWD_H) +#ifdef HAVE_PWD_H #include #endif -#if defined(HAVE_GRP_H) +#ifdef HAVE_GRP_H #include #endif @@ -79,7 +74,7 @@ /* * Stuff for setting the sockets into non-blocking mode. */ -#if defined(__POSIX_SOURCE) +#ifdef __POSIX_SOURCE #define NBLK_OPT O_NONBLOCK #else #define NBLK_OPT FNDELAY @@ -97,25 +92,13 @@ #if defined(__svr4__) #include #endif -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ -#if defined(HAVE_SYSLOG_H) +#ifdef HAVE_SYSLOG_H #include #endif -#if HAVE_STRERROR - #define lastErr() strerror(errno) -#else -#if defined(__MINGW__) -static errbuf[BUFSIZ]; - #define lastErr() (sprintf(errbuf, "WSAGetLastError()=%d", WSAGetLastError()), errbuf) -#else -static errbuf[BUFSIZ]; - #define lastErr() (sprintf(errbuf, "%m"), errbuf) -#endif -#endif - #include "gdomap.h" /* * ABOUT THIS PROGRAM @@ -149,10 +132,9 @@ static errbuf[BUFSIZ]; __a*((__v+__a-1)/__a); }) typedef unsigned char *uptr; -#ifndef __MINGW__ +#ifndef __MINGW32__ static int is_daemon = 0; /* Currently running as daemon. */ #endif -static int in_config = 0; /* Reading config file. */ static int debug = 0; /* Extra debug gdomap_logging. */ static int nobcst = 0; /* turn off broadcast probing. */ static int nofork = 0; /* turn off fork() for debugging. */ @@ -182,7 +164,7 @@ struct in_addr class_c_mask; * Predeclare some of the functions used. */ static void dump_stats(); -#ifndef __MINGW__ +#ifndef __MINGW32__ static void dump_tables(); #endif static void handle_accept(); @@ -203,7 +185,7 @@ static void queue_probe(struct in_addr* to, struct in_addr *from, char *xgethostname (void); -#if defined(__MINGW__) +#ifdef __MINGW32__ #ifndef HAVE_GETOPT /* A simple implementation of getopt() */ @@ -277,25 +259,16 @@ getopt(int argc, char **argv, char *options) static char ebuf[2048]; -#if defined(HAVE_SYSLOG) +#ifdef HAVE_SYSLOG static int log_priority; static void gdomap_log (int prio) { - if (in_config) - { -#ifndef __MINGW__ - if (geteuid () != getuid ()) - { - strcpy(ebuf, "problem with config file"); - } -#endif - } if (is_daemon) { - syslog (log_priority | prio, "%s", ebuf); + syslog (log_priority | prio, ebuf); } else if (prio == LOG_INFO) { @@ -332,15 +305,6 @@ gdomap_log (int prio) void gdomap_log (int prio) { - if (in_config) - { -#ifndef __MINGW__ - if (geteuid () != getuid ()) - { - strcpy(ebuf, "problem with config file"); - } -#endif - } write (2, ebuf, strlen (ebuf)); write (2, "\n", 1); if (prio == LOG_CRIT) @@ -417,13 +381,13 @@ static fd_set write_fds; /* Descriptors which are writable. */ Bjoern Giesler to work on Win32. */ typedef struct { -#if defined(__MINGW__) +#ifdef __MINGW32__ SOCKET s; #else int s; -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ struct sockaddr_in addr; /* Address of process making request. */ - socklen_t pos; /* Position reading data. */ + unsigned int pos; /* Position reading data. */ union { gdo_req r; unsigned char b[GDO_REQ_SIZE]; @@ -431,11 +395,11 @@ typedef struct { } RInfo; /* State of reading each request. */ typedef struct { -#if defined(__MINGW__) +#ifdef __MINGW32__ SOCKET s; #else int s; -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ int len; /* Length of data to be written. */ int pos; /* Amount of data already written. */ char* buf; /* Buffer for data. */ @@ -449,11 +413,11 @@ static unsigned _wInfoCapacity = 0; static unsigned _wInfoCount = 0; static void -#if defined(__MINGW__) +#ifdef __MINGW32__ delRInfo(SOCKET s) #else delRInfo(int s) -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ { unsigned int i; @@ -466,8 +430,7 @@ delRInfo(int s) } if (i == _rInfoCount) { - snprintf(ebuf, sizeof(ebuf), - "%s requested unallocated RInfo struct (socket %d)", + sprintf(ebuf, "%s requested unallocated RInfo struct (socket %d)", __FUNCTION__, s); gdomap_log(LOG_ERR); return; @@ -481,7 +444,7 @@ delRInfo(int s) static RInfo * -#if defined(__MINGW__) +#ifdef __MINGW32__ getRInfo(SOCKET s, int make) #else getRInfo(int s, int make) @@ -523,11 +486,11 @@ getRInfo(int s, int make) } static void -#if defined(__MINGW__) +#ifdef __MINGW32__ delWInfo(SOCKET s) #else delWInfo(int s) -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ { unsigned int i; @@ -540,8 +503,7 @@ delWInfo(int s) } if (i == _wInfoCount) { - snprintf(ebuf, sizeof(ebuf), - "%s requested unallocated WInfo struct (socket %d)", + sprintf(ebuf, "%s requested unallocated WInfo struct (socket %d)", __FUNCTION__, s); gdomap_log(LOG_ERR); return; @@ -555,7 +517,7 @@ delWInfo(int s) static WInfo * -#if defined(__MINGW__) +#ifdef __MINGW32__ getWInfo(SOCKET s, int make) #else getWInfo(int s, int make) @@ -730,8 +692,8 @@ map_add(uptr n, unsigned char l, unsigned int p, unsigned char t) map_used++; if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Added port %d to map for %.*s", - m->port, m->size, m->name); + sprintf(ebuf, "Added port %d to map for %.*s", + m->port, m->size, m->name); gdomap_log(LOG_DEBUG); } return m; @@ -750,7 +712,7 @@ map_by_name(uptr n, int s) if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Searching map for %.*s", s, n); + sprintf(ebuf, "Searching map for %.*s", s, n); gdomap_log(LOG_DEBUG); } for (index = upper/2; upper != lower; index = lower + (upper - lower)/2) @@ -774,15 +736,14 @@ map_by_name(uptr n, int s) { if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), - "Found port %d for %.*s", map[index]->port, s, n); + sprintf(ebuf, "Found port %d for %.*s", map[index]->port, s, n); gdomap_log(LOG_DEBUG); } return map[index]; } if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Failed to find map entry for %.*s", s, n); + sprintf(ebuf, "Failed to find map entry for %.*s", s, n); gdomap_log(LOG_DEBUG); } return 0; @@ -799,7 +760,7 @@ map_by_port(unsigned p, unsigned char t) if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Searching map for %u:%x", p, t); + sprintf(ebuf, "Searching map for %u:%x", p, t); gdomap_log(LOG_DEBUG); } for (index = 0; index < map_used; index++) @@ -815,7 +776,7 @@ map_by_port(unsigned p, unsigned char t) { if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Found port %d with name %s", + sprintf(ebuf, "Found port %d with name %s", map[index]->port, map[index]->name); gdomap_log(LOG_DEBUG); } @@ -823,7 +784,7 @@ map_by_port(unsigned p, unsigned char t) } if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Failed to find map entry for %u:%x", p, t); + sprintf(ebuf, "Failed to find map entry for %u:%x", p, t); gdomap_log(LOG_DEBUG); } return 0; @@ -841,8 +802,8 @@ map_del(map_ent* e) if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Removing port %d from map for %.*s", - e->port, e->size, e->name); + sprintf(ebuf, "Removing port %d from map for %.*s", + e->port, e->size, e->name); gdomap_log(LOG_DEBUG); } for (i = 0; i < map_used; i++) @@ -1006,7 +967,7 @@ prb_tim(time_t when) static void clear_chan(int desc) { -#if defined(__MINGW__) +#ifdef __MINGW32__ if (desc != INVALID_SOCKET) #else if (desc >= 0 && desc < FD_SETSIZE) @@ -1022,7 +983,7 @@ clear_chan(int desc) else { FD_CLR(desc, &read_fds); -#if defined(__MINGW__) +#ifdef __MINGW32__ closesocket(desc); #else close(desc); @@ -1062,36 +1023,27 @@ dump_stats() tcp_pending++; } } - snprintf(ebuf, sizeof(ebuf), - "tcp messages waiting for send - %d", tcp_pending); + sprintf(ebuf, "tcp messages waiting for send - %d", tcp_pending); gdomap_log(LOG_INFO); - snprintf(ebuf, sizeof(ebuf), - "udp messages waiting for send - %d", udp_pending); + sprintf(ebuf, "udp messages waiting for send - %d", udp_pending); gdomap_log(LOG_INFO); - snprintf(ebuf, sizeof(ebuf), "size of name-to-port map - %d", map_used); + sprintf(ebuf, "size of name-to-port map - %d", map_used); gdomap_log(LOG_INFO); - snprintf(ebuf, sizeof(ebuf), "number of known name servers - %ld", prb_used); + sprintf(ebuf, "number of known name servers - %ld", prb_used); gdomap_log(LOG_INFO); - snprintf(ebuf, sizeof(ebuf), "TCP %d read, %d sent", tcp_read, tcp_sent); + sprintf(ebuf, "TCP %d read, %d sent", tcp_read, tcp_sent); gdomap_log(LOG_INFO); - snprintf(ebuf, sizeof(ebuf), "UDP %d read, %d sent", udp_read, udp_sent); + sprintf(ebuf, "UDP %d read, %d sent", udp_read, udp_sent); gdomap_log(LOG_INFO); } -#ifndef __MINGW__ +#ifndef __MINGW32__ static void dump_tables() { FILE *fptr; soft_int++; - if (access(".", W_OK) != 0) - { - snprintf(ebuf, sizeof(ebuf), - "Failed to access gdomap.dump file for output\n"); - gdomap_log(LOG_ERR); - return; - } fptr = fopen("gdomap.dump", "w"); if (fptr != 0) { @@ -1118,8 +1070,7 @@ dump_tables() } else { - snprintf(ebuf, sizeof(ebuf), - "Failed to open gdomap.dump file for output\n"); + sprintf(ebuf, "Failed to open gdomap.dump file for output\n"); gdomap_log(LOG_ERR); } } @@ -1133,7 +1084,7 @@ dump_tables() static void init_iface() { -#if defined(__MINGW__) +#ifdef __MINGW32__ INTERFACE_INFO InterfaceList[20]; unsigned long nBytesReturned; int i, countActive, nNumInterfaces; @@ -1141,8 +1092,7 @@ init_iface() if (desc == INVALID_SOCKET) { - snprintf(ebuf, sizeof(ebuf), - "Failed to get a socket. Error %d\n", WSAGetLastError()); + sprintf(ebuf, "Failed to get a socket. Error %d\n", WSAGetLastError()); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1151,8 +1101,7 @@ init_iface() if (WSAIoctl(desc, SIO_GET_INTERFACE_LIST, 0, 0, (void*)InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0) == SOCKET_ERROR) { - snprintf(ebuf, sizeof(ebuf), - "Failed WSAIoctl. Error %d\n", WSAGetLastError()); + sprintf(ebuf, "Failed WSAIoctl. Error %d\n", WSAGetLastError()); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1241,7 +1190,7 @@ init_iface() } closesocket(desc); #else -#if defined(SIOCGIFCONF) +#ifdef SIOCGIFCONF struct ifconf ifc; struct ifreq ifreq; void *final; @@ -1285,18 +1234,17 @@ init_iface() { int res = errno; - snprintf(ebuf, sizeof(ebuf), - "SIOCGIFCONF for init_iface found no active interfaces; %s", lastErr()); + sprintf(ebuf, + "SIOCGIFCONF for init_iface found no active interfaces; %m"); gdomap_log(LOG_ERR); if (res == EINVAL) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "Either you have too many network interfaces on your machine (in which case\n" "you need to change the 'MAX_IFACE' constant in gdomap.c and rebuild it), or\n" "your system is buggy, and you need to use the '-a' command line flag for\n" -"gdomap to manually set the interface addresses and masks to be used.\n" -"Try 'gdomap -C' for more information.\n"); +"gdomap to manually set the interface addresses and masks to be used.\n"); gdomap_log(LOG_INFO); } close(desc); @@ -1319,7 +1267,7 @@ init_iface() for (ifr_ptr = ifc.ifc_req; ifr_ptr < final;) { ifreq = *(struct ifreq*)ifr_ptr; -#if defined(HAVE_SA_LEN) +#ifdef HAVE_SA_LEN ifr_ptr += sizeof(ifreq) - sizeof(ifreq.ifr_addr) + ROUND(ifreq.ifr_addr.sa_len, sizeof(struct ifreq*)); #else @@ -1328,7 +1276,7 @@ init_iface() if (ioctl(desc, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - snprintf(ebuf, sizeof(ebuf), "SIOCGIFFLAGS: %s", lastErr()); + sprintf(ebuf, "SIOCGIFFLAGS: %m"); gdomap_log(LOG_ERR); } else if (ifreq.ifr_flags & IFF_UP) @@ -1341,13 +1289,13 @@ init_iface() { broadcast = 1; } -#if defined(IFF_POINTOPOINT) +#ifdef IFF_POINTOPOINT if (ifreq.ifr_flags & IFF_POINTOPOINT) { pointopoint = 1; } #endif -#if defined(IFF_LOOPBACK) +#ifdef IFF_LOOPBACK if (ifreq.ifr_flags & IFF_LOOPBACK) { loopback = 1; @@ -1355,19 +1303,18 @@ init_iface() #endif if (ioctl(desc, SIOCGIFADDR, (char *)&ifreq) < 0) { - snprintf(ebuf, sizeof(ebuf), "SIOCGIFADDR: %s", lastErr()); + sprintf(ebuf, "SIOCGIFADDR: %m"); gdomap_log(LOG_ERR); } else if (ifreq.ifr_addr.sa_family == AF_INET) { /* IP interface */ if (interfaces >= MAX_IFACE) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "You have too many network interfaces on your machine (in which case you need\n" "to change the 'MAX_IFACE' constant in gdomap.c and rebuild it), or your\n" "system is buggy, and you need to use the '-a' command line flag for\n" -"gdomap to manually set the interface addresses and masks to be used.\n" -"Try 'gdomap -C' for more information.\n"); +"gdomap to manually set the interface addresses and masks to be used."); gdomap_log(LOG_INFO); close(desc); exit(EXIT_FAILURE); @@ -1375,13 +1322,12 @@ init_iface() addr[interfaces] = ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr; bcok[interfaces] = (broadcast | pointopoint); -#if defined(IFF_POINTOPOINT) +#ifdef IFF_POINTOPOINT if (pointopoint) { if (ioctl(desc, SIOCGIFDSTADDR, (char*)&ifreq) < 0) { - snprintf(ebuf, sizeof(ebuf), - "SIOCGIFADDR: %s", lastErr()); + sprintf(ebuf, "SIOCGIFADDR: %m"); gdomap_log(LOG_ERR); bcok[interfaces] = 0; } @@ -1394,11 +1340,10 @@ init_iface() else #endif { - if (!loopback - && ioctl(desc, SIOCGIFBRDADDR, (char*)&ifreq) < 0) + if (!loopback && + ioctl(desc, SIOCGIFBRDADDR, (char*)&ifreq) < 0) { - snprintf(ebuf, sizeof(ebuf), - "SIOCGIFBRDADDR: %s", lastErr()); + sprintf(ebuf, "SIOCGIFBRDADDR: %m"); gdomap_log(LOG_ERR); bcok[interfaces] = 0; } @@ -1410,7 +1355,7 @@ init_iface() } if (ioctl(desc, SIOCGIFNETMASK, (char *)&ifreq) < 0) { - snprintf(ebuf, sizeof(ebuf), "SIOCGIFNETMASK: %s", lastErr()); + sprintf(ebuf, "SIOCGIFNETMASK: %m"); gdomap_log(LOG_ERR); /* * If we can't get a netmask - assume a class-c @@ -1441,10 +1386,8 @@ init_iface() if (interfaces == 0) { - snprintf(ebuf, sizeof(ebuf), - "I can't find any network interfaces on this platform - " - "use the '-a' flag to load interface details from a file instead.\n" - "Try 'gdomap -C' for more information.\n"); + sprintf(ebuf, "I can't find any network interfaces on this platform - " + "use the '-a' flag to load interface details from a file instead."); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1458,24 +1401,13 @@ init_iface() static void load_iface(const char* from) { - FILE *fptr; + FILE *fptr = fopen(from, "rt"); char buf[128]; - int line = 0; int num_iface = 0; - in_config = 1; - if (access(from, R_OK) != 0) - { - snprintf(ebuf, sizeof(ebuf), - "Unable to access address config - '%s'", from); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); - } - fptr = fopen(from, "rt"); if (fptr == 0) { - snprintf(ebuf, sizeof(ebuf), - "Unable to open address config - '%s'", from); + sprintf(ebuf, "Unable to open address config - '%s'", from); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1484,7 +1416,6 @@ load_iface(const char* from) { char *ptr = buf; - line++; /* * Strip leading white space. */ @@ -1524,18 +1455,13 @@ load_iface(const char* from) { continue; } - if (num_iface++ > 1000) - { - snprintf(ebuf, sizeof(ebuf), "Too many network interfaces found"); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); - } + num_iface++; } fseek(fptr, 0, 0); if (num_iface == 0) { - snprintf(ebuf, sizeof(ebuf), "No network interfaces found"); + sprintf(ebuf, "No network interfaces found"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1556,7 +1482,6 @@ load_iface(const char* from) char *ptr = buf; char *msk; - line++; /* * Strip leading white space. */ @@ -1629,17 +1554,13 @@ load_iface(const char* from) } if (addr[interfaces].s_addr == (uint32_t)-1) { - snprintf(ebuf, sizeof(ebuf), "line %d of '%s' bad address (%s)", - line, from, buf); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); + sprintf(ebuf, "'%s' is not as valid address", buf); + gdomap_log(LOG_ERR); } else if (mask[interfaces].s_addr == (uint32_t)-1) { - snprintf(ebuf, sizeof(ebuf), "line %d of '%s' bad netmask (%s)", - line, from, ptr); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); + sprintf(ebuf, "'%s' is not as valid netmask", ptr); + gdomap_log(LOG_ERR); } else { @@ -1647,7 +1568,6 @@ load_iface(const char* from) } } fclose(fptr); - in_config = 0; } /* @@ -1664,7 +1584,7 @@ init_my_port() * this should be the default port, since we should have registered * this with the appropriate authority and have it reserved for us. */ -#if defined(GDOMAP_PORT_OVERRIDE) +#ifdef GDOMAP_PORT_OVERRIDE my_port = htons(GDOMAP_PORT_OVERRIDE); #else my_port = htons(GDOMAP_PORT); @@ -1672,10 +1592,9 @@ init_my_port() { if (debug) { - snprintf(ebuf, sizeof(ebuf), "Unable to find service 'gdomap'"); + sprintf(ebuf, "Unable to find service 'gdomap'"); gdomap_log(LOG_WARNING); - snprintf(ebuf, sizeof(ebuf), - "On a unix host it should be in /etc/services " + sprintf(ebuf, "On a unix host it should be in /etc/services " "as 'gdomap %d/tcp' and 'gdomap %d/udp'\n", GDOMAP_PORT, GDOMAP_PORT); gdomap_log(LOG_INFO); @@ -1689,9 +1608,8 @@ init_my_port() { if (debug) { - snprintf(ebuf, sizeof(ebuf), "Unable to find service 'gdomap'"); - snprintf(ebuf, sizeof(ebuf), - "On a unix host it should be in /etc/services " + sprintf(ebuf, "Unable to find service 'gdomap'"); + sprintf(ebuf, "On a unix host it should be in /etc/services " "as 'gdomap %d/tcp' and 'gdomap %d/udp'\n", GDOMAP_PORT, GDOMAP_PORT); gdomap_log(LOG_INFO); @@ -1699,14 +1617,14 @@ init_my_port() } else if (sp->s_port != tcp_port) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "UDP and TCP service entries differ. " "Using the TCP entry for both!"); gdomap_log(LOG_WARNING); } if (tcp_port != my_port) { - snprintf(ebuf, sizeof(ebuf), "gdomap not running on normal port"); + sprintf(ebuf, "gdomap not running on normal port"); gdomap_log(LOG_WARNING); } my_port = tcp_port; @@ -1723,9 +1641,9 @@ init_ports() { int r; struct sockaddr_in sa; -#if defined(__MINGW__) +#ifdef __MINGW32__ unsigned long dummy; -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ /* * Now we set up the sockets to accept incoming connections and set @@ -1734,37 +1652,21 @@ init_ports() */ udp_desc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); -#if defined(__MINGW__) +#ifdef __MINGW32__ if (udp_desc == INVALID_SOCKET) #else if (udp_desc < 0) #endif { - snprintf(ebuf, sizeof(ebuf), "Unable to create UDP socket"); + sprintf(ebuf, "Unable to create UDP socket"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } else if (debug) { - snprintf(ebuf, sizeof(ebuf), "Opened UDP socket %d", udp_desc); + sprintf(ebuf, "Opened UDP socket %d", udp_desc); gdomap_log(LOG_DEBUG); } -#if 0 && defined(SO_EXCLUSIVEADDRUSE) - r = 1; - if ((setsockopt(udp_desc,SOL_SOCKET,SO_REUSEADDR,(char*)&r,sizeof(r)))<0) - { - snprintf(ebuf, sizeof(ebuf), "Unable to set 're-use' on UDP socket"); - gdomap_log(LOG_WARNING); - } - r = 1; - if ((setsockopt - (udp_desc,SOL_SOCKET,SO_EXCLUSIVEADDRUSE,(char*)&r,sizeof(r)))<0) - { - snprintf(ebuf, sizeof(ebuf), - "Unable to set 'exclusive-use' on UDP socket"); - gdomap_log(LOG_WARNING); - } -#endif #ifndef BROKEN_SO_REUSEADDR /* * Under decent systems, SO_REUSEADDR means that the port can be reused @@ -1775,7 +1677,7 @@ init_ports() r = 1; if ((setsockopt(udp_desc,SOL_SOCKET,SO_REUSEADDR,(char*)&r,sizeof(r)))<0) { - snprintf(ebuf, sizeof(ebuf), "Unable to set 're-use' on UDP socket"); + sprintf(ebuf, "Unable to set 're-use' on UDP socket"); gdomap_log(LOG_WARNING); } #endif @@ -1785,32 +1687,32 @@ init_ports() if ((setsockopt(udp_desc,SOL_SOCKET,SO_BROADCAST,(char*)&r,sizeof(r)))<0) { nobcst++; - snprintf(ebuf, sizeof(ebuf), "Unable to use 'broadcast' for probes"); + sprintf(ebuf, "Unable to use 'broadcast' for probes"); gdomap_log(LOG_WARNING); } } -#if defined(__MINGW__) +#ifdef __MINGW32__ dummy = 1; if (ioctlsocket(udp_desc, FIONBIO, &dummy) < 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to handle UDP socket non-blocking"); + sprintf(ebuf, "Unable to handle UDP socket non-blocking"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } -#else /* !__MINGW__ */ +#else /* !__MINGW32__ */ if ((r = fcntl(udp_desc, F_GETFL, 0)) >= 0) { r |= NBLK_OPT; if (fcntl(udp_desc, F_SETFL, r) < 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to set UDP socket non-blocking"); + sprintf(ebuf, "Unable to set UDP socket non-blocking"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } } else { - snprintf(ebuf, sizeof(ebuf), "Unable to handle UDP socket non-blocking"); + sprintf(ebuf, "Unable to handle UDP socket non-blocking"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1825,12 +1727,12 @@ init_ports() sa.sin_port = my_port; if (bind(udp_desc, (void*)&sa, sizeof(sa)) < 0) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "Unable to bind address to UDP socket. Perhaps gdomap is already running"); gdomap_log(LOG_ERR); if (errno == EACCES) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "You probably need to run gdomap as root/system administrator (recommended),\n" "or run the nameserver on a non-standard port that does not require root\n" "privilege (poor option and last resort!!!)"); @@ -1843,37 +1745,21 @@ init_ports() * Now we do the TCP socket. */ tcp_desc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); -#if defined(__MINGW__) +#ifdef __MINGW32__ if (tcp_desc == INVALID_SOCKET) #else if (tcp_desc < 0) #endif { - snprintf(ebuf, sizeof(ebuf), "Unable to create TCP socket"); + sprintf(ebuf, "Unable to create TCP socket"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } else if (debug) { - snprintf(ebuf, sizeof(ebuf), "Opened TDP socket %d", tcp_desc); + sprintf(ebuf, "Opened TDP socket %d", tcp_desc); gdomap_log(LOG_DEBUG); } -#if 0 && defined(SO_EXCLUSIVEADDRUSE) - r = 1; - if ((setsockopt(tcp_desc,SOL_SOCKET,SO_REUSEADDR,(char*)&r,sizeof(r)))<0) - { - snprintf(ebuf, sizeof(ebuf), "Unable to set 're-use' on TCP socket"); - gdomap_log(LOG_WARNING); - } - r = 1; - if ((setsockopt - (tcp_desc,SOL_SOCKET,SO_EXCLUSIVEADDRUSE,(char*)&r,sizeof(r)))<0) - { - snprintf(ebuf, sizeof(ebuf), - "Unable to set 'exclusive-use' on TCP socket"); - gdomap_log(LOG_WARNING); - } -#endif #ifndef BROKEN_SO_REUSEADDR /* * Under decent systems, SO_REUSEADDR means that the port can be reused @@ -1884,37 +1770,37 @@ init_ports() r = 1; if ((setsockopt(tcp_desc,SOL_SOCKET,SO_REUSEADDR,(char*)&r,sizeof(r)))<0) { - snprintf(ebuf, sizeof(ebuf), "Unable to set 're-use' on TCP socket"); + sprintf(ebuf, "Unable to set 're-use' on TCP socket"); gdomap_log(LOG_WARNING); } #endif -#if defined(__MINGW__) +#ifdef __MINGW32__ dummy = 1; if (ioctlsocket(tcp_desc, FIONBIO, &dummy) < 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to handle TCP socket non-blocking"); + sprintf(ebuf, "Unable to handle TCP socket non-blocking"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } -#else /* !__MINGW__ */ +#else /* !__MINGW32__ */ if ((r = fcntl(tcp_desc, F_GETFL, 0)) >= 0) { r |= NBLK_OPT; if (fcntl(tcp_desc, F_SETFL, r) < 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to set TCP socket non-blocking"); + sprintf(ebuf, "Unable to set TCP socket non-blocking"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } } else { - snprintf(ebuf, sizeof(ebuf), "Unable to handle TCP socket non-blocking"); + sprintf(ebuf, "Unable to handle TCP socket non-blocking"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ memset(&sa, '\0', sizeof(sa)); sa.sin_family = AF_INET; @@ -1922,12 +1808,12 @@ init_ports() sa.sin_port = my_port; if (bind(tcp_desc, (void*)&sa, sizeof(sa)) < 0) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "Unable to bind address to TCP socket. Perhaps gdomap is already running"); gdomap_log(LOG_ERR); if (errno == EACCES) { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "You probably need to run gdomap as root/system administrator (recommended),\n" "or run the nameserver on a non-standard port that does not require root\n" "privilege (poor option and last resort!!!)"); @@ -1937,8 +1823,7 @@ init_ports() } if (listen(tcp_desc, QUEBACKLOG) < 0) { - snprintf(ebuf, sizeof(ebuf), - "Unable to listen for connections on TCP socket"); + sprintf(ebuf, "Unable to listen for connections on TCP socket"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -1955,7 +1840,7 @@ init_ports() FD_SET(tcp_desc, &read_fds); FD_SET(udp_desc, &read_fds); -#ifndef __MINGW__ +#ifndef __MINGW32__ /* * Turn off pipe signals so we don't get interrupted if we attempt * to write a response to a process which has died. @@ -1965,7 +1850,7 @@ init_ports() * Enable table dumping to /tmp/gdomap.dump */ signal(SIGUSR1, dump_tables); -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ } @@ -2032,7 +1917,7 @@ init_probe() } if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Initiating probe requests."); + sprintf(ebuf, "Initiating probe requests."); gdomap_log(LOG_DEBUG); } @@ -2067,9 +1952,9 @@ init_probe() int elen = 0; struct in_addr *other; struct in_addr sin; - int high = 0; - int low = 0; - unsigned long net = 0; + int high; + int low; + unsigned long net; int j; struct in_addr b; @@ -2106,7 +1991,7 @@ init_probe() if ((mask[iface].s_addr | class_c_mask.s_addr) != mask[iface].s_addr) { - snprintf(ebuf, sizeof(ebuf), "netmask %s will be " + sprintf(ebuf, "netmask %s will be " "treated as 255.255.255.0 for ", inet_ntoa(mask[iface])); strcat(ebuf, inet_ntoa(addr[iface])); @@ -2249,7 +2134,7 @@ init_probe() if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Probe requests initiated."); + sprintf(ebuf, "Probe requests initiated."); gdomap_log(LOG_DEBUG); } last_probe = time(0); @@ -2265,18 +2150,18 @@ static void handle_accept() { struct sockaddr_in sa; - socklen_t len = sizeof(sa); + unsigned len = sizeof(sa); int desc; desc = accept(tcp_desc, (void*)&sa, &len); if (desc >= 0) { RInfo *ri; -#if defined(__MINGW__) +#ifdef __MINGW32__ unsigned long dummy = 1; #else int r; -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ FD_SET(desc, &read_fds); ri = getRInfo(desc, 1); @@ -2285,25 +2170,24 @@ handle_accept() if (debug) { - snprintf(ebuf, sizeof(ebuf), "accept from %s(%d) to chan %d", + sprintf(ebuf, "accept from %s(%d) to chan %d", inet_ntoa(sa.sin_addr), ntohs(sa.sin_port), desc); gdomap_log(LOG_DEBUG); } /* * Ensure that the connection is non-blocking. */ -#if defined(__MINGW__) +#ifdef __MINGW32__ if (ioctlsocket(desc, FIONBIO, &dummy) < 0) { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "failed to set chan %d non-blocking", desc); + sprintf(ebuf, "failed to set chan %d non-blocking", desc); gdomap_log(LOG_DEBUG); } clear_chan(desc); } -#else /* !__MINGW__ */ +#else /* !__MINGW32__ */ if ((r = fcntl(desc, F_GETFL, 0)) >= 0) { r |= NBLK_OPT; @@ -2311,8 +2195,7 @@ handle_accept() { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "failed to set chan %d non-blocking", desc); + sprintf(ebuf, "failed to set chan %d non-blocking", desc); gdomap_log(LOG_DEBUG); } clear_chan(desc); @@ -2322,22 +2205,21 @@ handle_accept() { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "failed to set chan %d non-blocking", desc); + sprintf(ebuf, "failed to set chan %d non-blocking", desc); gdomap_log(LOG_DEBUG); } clear_chan(desc); } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ } else if (debug) { - snprintf(ebuf, sizeof(ebuf), "accept failed - errno %d", -#if defined(__MINGW__) + sprintf(ebuf, "accept failed - errno %d", +#ifdef __MINGW32__ WSAGetLastError()); #else errno); -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ gdomap_log(LOG_DEBUG); } } @@ -2407,10 +2289,9 @@ handle_io() if (rval < 0 && errno == EBADF) { clear_chan(i); - if (i == tcp_desc || i == udp_desc) + if (i == tcp_desc) { - snprintf(ebuf, sizeof(ebuf), - "Fatal error on socket."); + sprintf(ebuf, "Fatal error on socket."); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -2432,8 +2313,7 @@ handle_io() } else { - snprintf(ebuf, sizeof(ebuf), - "Interrupted in select: %s",strerror(errno)); + sprintf(ebuf, "Interrupted in select: %s",strerror(errno)); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -2461,7 +2341,7 @@ handle_io() /* * Got some descriptor activity - deal with it. */ -#if defined(__MINGW__) +#ifdef __MINGW32__ /* read file descriptors */ for (i = 0; i < rfds.fd_count; i++) { @@ -2493,7 +2373,7 @@ handle_io() handle_write(wfds.fd_array[i]); } } -#else /* !__MINGW__ */ +#else /* !__MINGW32__ */ for (i = 0; i < FD_SETSIZE; i++) { if (FD_ISSET(i, &rfds)) @@ -2527,7 +2407,7 @@ handle_io() } } } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ } } } @@ -2551,10 +2431,12 @@ handle_read(int desc) while (ri->pos < GDO_REQ_SIZE && done == 0) { -#if defined(__MINGW__) - r = recv(desc, (char *)&ptr[ri->pos], GDO_REQ_SIZE - ri->pos, 0); +#ifdef __MINGW32__ + r = recv(desc, &ptr[ri->pos], + GDO_REQ_SIZE - ri->pos, 0); #else - r = read(desc, &ptr[ri->pos], GDO_REQ_SIZE - ri->pos); + r = read(desc, &ptr[ri->pos], + GDO_REQ_SIZE - ri->pos); #endif if (r > 0) { @@ -2571,7 +2453,7 @@ handle_read(int desc) tcp_read++; handle_request(desc); } -#if defined(__MINGW__) +#ifdef __MINGW32__ else if (WSAGetLastError() != WSAEWOULDBLOCK || nothingRead == 1) #else else if (errno != EWOULDBLOCK || nothingRead == 1) @@ -2595,30 +2477,27 @@ handle_recv() RInfo *ri; uptr ptr; struct sockaddr_in* addr; - socklen_t len = sizeof(struct sockaddr_in); + unsigned len = sizeof(struct sockaddr_in); int r; ri = getRInfo(udp_desc, 0); addr = &(ri->addr); ptr = ri->buf.b; - r = recvfrom(udp_desc, (char *)ptr, GDO_REQ_SIZE, 0, (void*)addr, &len); + r = recvfrom(udp_desc, ptr, GDO_REQ_SIZE, 0, (void*)addr, &len); if (r == GDO_REQ_SIZE) { udp_read++; ri->pos = GDO_REQ_SIZE; if (debug) { - snprintf(ebuf, sizeof(ebuf), - "recvfrom %s", inet_ntoa(addr->sin_addr)); - gdomap_log(LOG_DEBUG); + sprintf(ebuf, "recvfrom %s", inet_ntoa(addr->sin_addr)); } if (is_local_host(addr->sin_addr) == 1) { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "recvfrom packet from self discarded"); + sprintf(ebuf, "recvfrom packet from self discarded"); gdomap_log(LOG_DEBUG); } return; @@ -2629,8 +2508,12 @@ handle_recv() { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "recvfrom returned %d - %s", r, lastErr()); + sprintf(ebuf, "recvfrom returned %d - " +#ifdef __MINGW32__ + "WSAGetLastError() = %d\n", r, WSAGetLastError()); +#else + "%m", r); +#endif gdomap_log(LOG_DEBUG); } clear_chan(udp_desc); @@ -2668,13 +2551,12 @@ handle_request(int desc) { if (desc == udp_desc) { - snprintf(ebuf, sizeof(ebuf), "request type '%c' on UDP chan", type); + sprintf(ebuf, "request type '%c' on UDP chan", type); gdomap_log(LOG_DEBUG); } else { - snprintf(ebuf, sizeof(ebuf), - "request type '%c' from chan %d", type, desc); + sprintf(ebuf, "request type '%c' from chan %d", type, desc); gdomap_log(LOG_DEBUG); } if (type == GDO_PROBE || type == GDO_PREPLY || type == GDO_SERVERS @@ -2684,8 +2566,7 @@ handle_request(int desc) } else { - snprintf(ebuf, sizeof(ebuf), - " name: '%.*s' port: %ld", size, buf, port); + sprintf(ebuf, " name: '%.*s' port: %ld", size, buf, port); gdomap_log(LOG_DEBUG); } } @@ -2701,7 +2582,7 @@ handle_request(int desc) { if (debug) { - snprintf(ebuf, sizeof(ebuf), "Illegal port type in request"); + sprintf(ebuf, "Illegal port type in request"); gdomap_log(LOG_DEBUG); } clear_chan(desc); @@ -2727,7 +2608,7 @@ handle_request(int desc) */ if (is_local_host(ri->addr.sin_addr) == 0) { - snprintf(ebuf, sizeof(ebuf), "Illegal attempt to register!"); + sprintf(ebuf, "Illegal attempt to register!"); gdomap_log(LOG_ERR); clear_chan(desc); /* Only local progs may register. */ return; @@ -2763,11 +2644,6 @@ handle_request(int desc) * Special case - we already have this name registered for this * port - so everything is already ok. */ - if (debug) - { - snprintf(ebuf, sizeof(ebuf), "Already registered ... success"); - gdomap_log(LOG_DEBUG); - } *(unsigned long*)wi->buf = htonl(port); } else if (m != 0) @@ -2820,8 +2696,7 @@ handle_request(int desc) { if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), - "re-register from %d to %ld", + sprintf(ebuf, "re-register from %d to %ld", m->port, port); gdomap_log(LOG_DEBUG); } @@ -2832,7 +2707,7 @@ handle_request(int desc) *(unsigned long*)wi->buf = port; } } -#if defined(__MINGW__) +#ifdef __MINGW32__ /* closesocket(sock); */ #else close(sock); @@ -2841,20 +2716,11 @@ handle_request(int desc) } else if (port == 0) { /* Port not provided! */ - if (debug) - { - snprintf(ebuf, sizeof(ebuf), "Port not provided in request!"); - gdomap_log(LOG_DEBUG); - } - *(unsigned long*)wi->buf = 0; + sprintf(ebuf, "port not provided in request"); + gdomap_log(LOG_ERR); } else { /* Use port provided in request. */ - if (debug) - { - snprintf(ebuf, sizeof(ebuf), "Registered on port %lu", port); - gdomap_log(LOG_DEBUG); - } m = map_add(buf, size, port, ptype); port = htonl(m->port); *(unsigned long*)wi->buf = port; @@ -2867,8 +2733,7 @@ handle_request(int desc) { if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), - "requested service is of wrong type"); + sprintf(ebuf, "requested service is of wrong type"); gdomap_log(LOG_DEBUG); } m = 0; /* Name exists but is of wrong type. */ @@ -2926,7 +2791,7 @@ handle_request(int desc) memset(&sa, '\0', sizeof(sa)); sa.sin_family = AF_INET; -#if defined(__MINGW__) +#if defined(__MINGW32__) /* COMMENT: (3 Nov 2004 by Wim Oudshoorn): The comment below might be true. But using addr[0].s_addr has on windows 2003 server @@ -2946,7 +2811,7 @@ handle_request(int desc) sa.sin_addr.s_addr = htonl(INADDR_ANY); #else sa.sin_addr.s_addr = htonl(INADDR_ANY); -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ sa.sin_port = htons(p); result = bind(sock, (void*)&sa, sizeof(sa)); if (result == 0) @@ -2955,7 +2820,7 @@ handle_request(int desc) m = 0; } } -#if defined(__MINGW__) +#ifdef __MINGW32__ closesocket(sock); #else close(sock); @@ -2970,7 +2835,7 @@ handle_request(int desc) { /* Not found. */ if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), "requested service not found"); + sprintf(ebuf, "requested service not found"); gdomap_log(LOG_DEBUG); } *(unsigned short*)wi->buf = 0; @@ -2983,7 +2848,7 @@ handle_request(int desc) */ if (is_local_host(ri->addr.sin_addr) == 0) { - snprintf(ebuf, sizeof(ebuf), "Illegal attempt to un-register!"); + sprintf(ebuf, "Illegal attempt to un-register!"); gdomap_log(LOG_ERR); clear_chan(desc); return; @@ -2997,8 +2862,7 @@ handle_request(int desc) { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "Attempted unregister with wrong type"); + sprintf(ebuf, "Attempted unregister with wrong type"); gdomap_log(LOG_DEBUG); } } @@ -3012,7 +2876,7 @@ handle_request(int desc) { if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), "requested service not found"); + sprintf(ebuf, "requested service not found"); gdomap_log(LOG_DEBUG); } } @@ -3098,10 +2962,10 @@ handle_request(int desc) memcpy(&sin, ri->buf.r.name, IASIZE); if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), "Probe from '%s'", inet_ntoa(sin)); + sprintf(ebuf, "Probe from '%s'", inet_ntoa(sin)); gdomap_log(LOG_DEBUG); } -#if defined(__MINGW__) +#ifdef __MINGW32__ if (IN_CLASSA(sin.s_addr)) { net = sin.s_addr & IN_CLASSA_NET; @@ -3125,8 +2989,7 @@ handle_request(int desc) { if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), - "Add server '%s'", inet_ntoa(*ptr)); + sprintf(ebuf, "Add server '%s'", inet_ntoa(*ptr)); gdomap_log(LOG_DEBUG); } prb_add(ptr); @@ -3167,10 +3030,8 @@ handle_request(int desc) memcpy(&laddr, rbuf+IASIZE, IASIZE); if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), - "Probe sent remote '%s'", inet_ntoa(raddr)); - snprintf(ebuf, sizeof(ebuf), - "Probe sent local '%s'", inet_ntoa(laddr)); + sprintf(ebuf, "Probe sent remote '%s'", inet_ntoa(raddr)); + sprintf(ebuf, "Probe sent local '%s'", inet_ntoa(laddr)); } memcpy(wbuf+IASIZE, &raddr, IASIZE); @@ -3236,11 +3097,10 @@ handle_request(int desc) memcpy(&sin, &ri->buf.r.name, IASIZE); if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), - "Probe reply from '%s'", inet_ntoa(sin)); + sprintf(ebuf, "Probe reply from '%s'", inet_ntoa(sin)); gdomap_log(LOG_DEBUG); } -#if defined(__MINGW__) +#ifdef __MINGW32__ if (IN_CLASSA(sin.s_addr)) { net = sin.s_addr & IN_CLASSA_NET; @@ -3264,8 +3124,7 @@ handle_request(int desc) { if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), - "Add server '%s'", inet_ntoa(*ptr)); + sprintf(ebuf, "Add server '%s'", inet_ntoa(*ptr)); gdomap_log(LOG_DEBUG); } prb_add(ptr); @@ -3288,7 +3147,7 @@ handle_request(int desc) } else { - snprintf(ebuf, sizeof(ebuf), "Illegal operation code received!"); + sprintf(ebuf, "Illegal operation code received!"); gdomap_log(LOG_ERR); clear_chan(desc); return; @@ -3325,8 +3184,8 @@ handle_send() { int r; - r = sendto(udp_desc, (const char *)&entry->dat[entry->pos], - entry->len - entry->pos, 0, (void*)&entry->addr, sizeof(entry->addr)); + r = sendto(udp_desc, &entry->dat[entry->pos], entry->len - entry->pos, + 0, (void*)&entry->addr, sizeof(entry->addr)); /* * 'r' is the number of bytes sent. This should be the number * of bytes we asked to send, or -1 to indicate failure. @@ -3343,7 +3202,7 @@ handle_send() */ if (entry->pos != entry->len) { -#if defined(__MINGW__) +#ifdef __MINGW32__ if (WSAGetLastError() != WSAEWOULDBLOCK) #else if (errno != EWOULDBLOCK) @@ -3351,8 +3210,7 @@ handle_send() { if (debug) { - snprintf(ebuf, sizeof(ebuf), - "failed sendto on %d for %s - %s", + sprintf(ebuf, "failed sendto on %d for %s - %s", udp_desc, inet_ntoa(entry->addr.sin_addr), strerror(errno)); gdomap_log(LOG_DEBUG); } @@ -3364,7 +3222,7 @@ handle_send() udp_sent++; if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), "performed sendto for %s", + sprintf(ebuf, "performed sendto for %s", inet_ntoa(entry->addr.sin_addr)); gdomap_log(LOG_DEBUG); } @@ -3400,15 +3258,14 @@ handle_write(int desc) wi = getWInfo(desc, 0); if (wi == 0) { - snprintf(ebuf, sizeof(ebuf), - "handle_write for unknown descriptor (%d)", desc); + sprintf(ebuf, "handle_write for unknown descriptor (%d)", desc); gdomap_log(LOG_ERR); return; } ptr = wi->buf; len = wi->len; -#if defined(__MINGW__) +#ifdef __MINGW32__ r = send(desc, &ptr[wi->pos], len - wi->pos, 0); #else r = write(desc, &ptr[wi->pos], len - wi->pos); @@ -3417,8 +3274,7 @@ handle_write(int desc) { if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), - "Failed write on chan %d - closing", desc); + sprintf(ebuf, "Failed write on chan %d - closing", desc); gdomap_log(LOG_DEBUG); } /* @@ -3434,8 +3290,7 @@ handle_write(int desc) tcp_sent++; if (debug > 1) { - snprintf(ebuf, sizeof(ebuf), - "Completed write on chan %d - closing", desc); + sprintf(ebuf, "Completed write on chan %d - closing", desc); gdomap_log(LOG_DEBUG); } /* @@ -3519,14 +3374,14 @@ tryRead(int desc, int tim, unsigned char* dat, int len) } else if (len > 0) { -#if defined(__MINGW__) - rval = recv(desc, (char *)&dat[pos], len - pos, 0); +#ifdef __MINGW32__ + rval = recv(desc, &dat[pos], len - pos, 0); #else rval = read(desc, &dat[pos], len - pos); #endif if (rval < 0) { -#if defined(__MINGW__) +#ifdef __MINGW32__ if (WSAGetLastError() != WSAEWOULDBLOCK) #else if (errno != EWOULDBLOCK) @@ -3625,8 +3480,8 @@ tryWrite(int desc, int tim, unsigned char* dat, int len) } else if (len > 0) { -#if defined(__MINGW__) /* FIXME: Is this correct? */ - rval = send(desc, (const char*)&dat[pos], len - pos, 0); +#ifdef __MINGW32__ /* FIXME: Is this correct? */ + rval = send(desc, &dat[pos], len - pos, 0); #else void (*ifun)(); @@ -3641,7 +3496,7 @@ tryWrite(int desc, int tim, unsigned char* dat, int len) if (rval <= 0) { -#if defined(__MINGW__) +#ifdef __MINGW32__ if (WSAGetLastError() != WSAEWOULDBLOCK) #else if (errno != EWOULDBLOCK) @@ -3681,9 +3536,9 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) unsigned long port = *p; gdo_req msg; struct sockaddr_in sin; -#if defined(__MINGW__) +#ifdef __MINGW32__ unsigned long dummy; -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ *p = 0; if (desc < 0) @@ -3691,7 +3546,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) return 1; /* Couldn't create socket. */ } -#if defined(__MINGW__) +#ifdef __MINGW32__ dummy = 1; if (ioctlsocket(desc, FIONBIO, &dummy) < 0) { @@ -3700,7 +3555,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) WSASetLastError(e); return 2; /* Couldn't set non-blocking. */ } -#else /* !__MINGW__ */ +#else /* !__MINGW32__ */ if ((e = fcntl(desc, F_GETFL, 0)) >= 0) { e |= NBLK_OPT; @@ -3719,12 +3574,12 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) errno = e; return 2; /* Couldn't set non-blocking. */ } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ memcpy(&sin, addr, sizeof(sin)); if (connect(desc, (struct sockaddr*)&sin, sizeof(sin)) != 0) { -#if defined(__MINGW__) +#ifdef __MINGW32__ if (WSAGetLastError() == WSAEWOULDBLOCK) #else if (errno == EINPROGRESS) @@ -3734,7 +3589,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) if (e == -2) { e = errno; -#if defined(__MINGW__) +#ifdef __MINGW32__ closesocket(desc); #else close(desc); @@ -3745,7 +3600,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) else if (e == -1) { e = errno; -#if defined(__MINGW__) +#ifdef __MINGW32__ closesocket(desc); #else close(desc); @@ -3757,7 +3612,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) else { e = errno; -#if defined(__MINGW__) +#ifdef __MINGW32__ closesocket(desc); #else close(desc); @@ -3781,7 +3636,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) e = tryWrite(desc, 10, (uptr)&msg, GDO_REQ_SIZE); if (e != GDO_REQ_SIZE) { -#if defined(__MINGW__) +#ifdef __MINGW32__ e = WSAGetLastError(); closesocket(desc); WSASetLastError(e); @@ -3795,7 +3650,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) e = tryRead(desc, 3, (uptr)&port, 4); if (e != 4) { -#if defined(__MINGW__) +#ifdef __MINGW32__ e = WSAGetLastError(); closesocket(desc); WSASetLastError(e); @@ -3820,7 +3675,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) if (tryRead(desc, 3, b, len) != len) { free(b); -#if defined(__MINGW__) +#ifdef __MINGW32__ e = WSAGetLastError(); closesocket(desc); WSASetLastError(e); @@ -3846,7 +3701,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) if (tryRead(desc, 3, b, len) != len) { free(b); -#if defined(__MINGW__) +#ifdef __MINGW32__ e = WSAGetLastError(); closesocket(desc); WSASetLastError(e); @@ -3869,8 +3724,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) } if ((port & 0xffff) != port) { - snprintf(ebuf, sizeof(ebuf), - "Insanely large number of registered names"); + sprintf(ebuf, "Insanely large number of registered names"); gdomap_log(LOG_ERR); port = 0; } @@ -3878,7 +3732,7 @@ int ptype, struct sockaddr_in* addr, unsigned short* p, uptr*v) } *p = (unsigned short)port; -#if defined(__MINGW__) +#ifdef __MINGW32__ closesocket(desc); #else close(desc); @@ -3899,23 +3753,19 @@ nameFail(int why) { case 0: break; case 1: - snprintf(ebuf, sizeof(ebuf), - "failed to contact name server - socket - %s", + sprintf(ebuf, "failed to contact name server - socket - %s", strerror(errno)); gdomap_log(LOG_ERR); case 2: - snprintf(ebuf, sizeof(ebuf), - "failed to contact name server - socket - %s", + sprintf(ebuf, "failed to contact name server - socket - %s", strerror(errno)); gdomap_log(LOG_ERR); case 3: - snprintf(ebuf, sizeof(ebuf), - "failed to contact name server - socket - %s", + sprintf(ebuf, "failed to contact name server - socket - %s", strerror(errno)); gdomap_log(LOG_ERR); case 4: - snprintf(ebuf, sizeof(ebuf), - "failed to contact name server - socket - %s", + sprintf(ebuf, "failed to contact name server - socket - %s", strerror(errno)); gdomap_log(LOG_ERR); } @@ -3947,13 +3797,13 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd if (len == 0) { - snprintf(ebuf, sizeof(ebuf), "no name specified."); + sprintf(ebuf, "no name specified."); gdomap_log(LOG_ERR); return -1; } if (len > 0xffff) { - snprintf(ebuf, sizeof(ebuf), "name length to large."); + sprintf(ebuf, "name length to large."); gdomap_log(LOG_ERR); return -1; } @@ -3976,7 +3826,7 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd */ if (host && host[0] == '*' && host[1] == '\0') { - multi = 1; + multi = 1; } /* * If no host name is given, we use the name of the local host. @@ -3987,8 +3837,7 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd local_hostname = xgethostname(); if (!local_hostname) { - snprintf(ebuf, sizeof(ebuf), - "gethostname() failed: %s", strerror(errno)); + sprintf(ebuf, "gethostname() failed: %s", strerror(errno)); gdomap_log(LOG_ERR); return -1; } @@ -4006,15 +3855,13 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd } if (hp == 0) { - snprintf(ebuf, sizeof(ebuf), - "gethostbyname('%s') failed: %s", host, strerror(errno)); + sprintf(ebuf, "gethostbyname('%s') failed: %s", host, strerror(errno)); gdomap_log(LOG_ERR); return -1; } if (hp->h_addrtype != AF_INET) { - snprintf(ebuf, sizeof(ebuf), - "non-internet network not supported for %s", host); + sprintf(ebuf, "non-internet network not supported for %s", host); gdomap_log(LOG_ERR); return -1; } @@ -4037,8 +3884,7 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd rval = tryHost(GDO_SERVERS, 0, 0, ptype, &sin, &num, (uptr*)&b); if (rval != 0 && host == local_hostname) { - snprintf(ebuf, sizeof(ebuf), - "failed to contact gdomap on %s(%s) - %s", + sprintf(ebuf, "failed to contact gdomap on %s(%s) - %s", local_hostname, inet_ntoa(sin.sin_addr), strerror(errno)); gdomap_log(LOG_ERR); return -1; @@ -4089,19 +3935,11 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd if (op == GDO_REGISTER) { port = (unsigned short)pnum; - if (port == 0 || htons(port) == p) - { - snprintf(ebuf, sizeof(ebuf), - "attempted registration with bad port (%d).", port); - gdomap_log(LOG_ERR); - return -1; - } } rval = tryHost(op, len, (unsigned char*)name, ptype, &sin, &port, 0); if (rval != 0 && host == local_hostname) { - snprintf(ebuf, sizeof(ebuf), - "failed to contact gdomap on %s(%s) - %s", + sprintf(ebuf, "failed to contact gdomap on %s(%s) - %s", local_hostname, inet_ntoa(sin.sin_addr), strerror(errno)); gdomap_log(LOG_ERR); return -1; @@ -4113,8 +3951,7 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd { if (port == 0 || (pnum != 0 && port != pnum)) { - snprintf(ebuf, sizeof(ebuf), - "service already registered."); + sprintf(ebuf, "service already registered."); gdomap_log(LOG_ERR); return -1; } @@ -4141,13 +3978,13 @@ lookup(const char *name, const char *host, int ptype) found = nameServer(name, host, GDO_LOOKUP, ptype, sin, 0, 100); for (i = 0; i < found; i++) { - snprintf(ebuf, sizeof(ebuf), "Found %s on '%s' port %d", name, + sprintf(ebuf, "Found %s on '%s' port %d", name, inet_ntoa(sin[i].sin_addr), ntohs(sin[i].sin_port)); gdomap_log(LOG_INFO); } if (found == 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to find %s.", name); + sprintf(ebuf, "Unable to find %s.", name); gdomap_log(LOG_INFO); } } @@ -4187,8 +4024,7 @@ donames(const char *host) local_hostname = xgethostname(); if (!local_hostname) { - snprintf(ebuf, sizeof(ebuf), - "gethostname() failed: %s", strerror(errno)); + sprintf(ebuf, "gethostname() failed: %s", strerror(errno)); gdomap_log(LOG_ERR); return; } @@ -4206,15 +4042,13 @@ donames(const char *host) } if (hp == 0) { - snprintf(ebuf, sizeof(ebuf), - "gethostbyname('%s') failed: %s", host, strerror(errno)); + sprintf(ebuf, "gethostbyname('%s') failed: %s", host, strerror(errno)); gdomap_log(LOG_ERR); return; } if (hp->h_addrtype != AF_INET) { - snprintf(ebuf, sizeof(ebuf), - "non-internet network not supported for %s", host); + sprintf(ebuf, "non-internet network not supported for %s", host); gdomap_log(LOG_ERR); return; } @@ -4227,21 +4061,21 @@ donames(const char *host) rval = tryHost(GDO_NAMES, 0, 0, 0, &sin, &num, (uptr*)&b); if (rval != 0) { - snprintf(ebuf, sizeof(ebuf), "failed to contact gdomap on %s(%s) - %s", + sprintf(ebuf, "failed to contact gdomap on %s(%s) - %s", local_hostname, inet_ntoa(sin.sin_addr), strerror(errno)); gdomap_log(LOG_ERR); return; } if (num == 0) { - snprintf(ebuf, sizeof(ebuf), "No names currently registered with gdomap"); + sprintf(ebuf, "No names currently registered with gdomap"); gdomap_log(LOG_INFO); } else { uptr p = b; - snprintf(ebuf, sizeof(ebuf), "Registered names are -"); + sprintf(ebuf, "Registered names are -"); gdomap_log(LOG_INFO); while (num-- > 0) { @@ -4249,7 +4083,7 @@ donames(const char *host) memcpy(buf, &p[2], p[0]); buf[p[0]] = '\0'; - snprintf(ebuf, sizeof(ebuf), " %s", buf); + sprintf(ebuf, " %s", buf); gdomap_log(LOG_INFO); p += 2 + p[0]; } @@ -4268,14 +4102,13 @@ doregister(const char *name, int port, int ptype) found = nameServer(name, 0, GDO_REGISTER, ptype, &sin, port, 1); for (i = 0; i < found; i++) { - snprintf(ebuf, sizeof(ebuf), "Registered %s on '%s' port %d", name, + sprintf(ebuf, "Registered %s on '%s' port %d", name, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); gdomap_log(LOG_INFO); } if (found == 0) { - snprintf(ebuf, sizeof(ebuf), - "Unable to register %s on port %d.", name, port); + sprintf(ebuf, "Unable to register %s on port %d.", name, port); gdomap_log(LOG_ERR); } } @@ -4290,13 +4123,13 @@ unregister(const char *name, int port, int ptype) found = nameServer(name, 0, GDO_UNREG, ptype, &sin, port, 1); for (i = 0; i < found; i++) { - snprintf(ebuf, sizeof(ebuf), "Unregistered %s on '%s' port %d", name, + sprintf(ebuf, "Unregistered %s on '%s' port %d", name, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); gdomap_log(LOG_INFO); } if (found == 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to unregister %s.", name); + sprintf(ebuf, "Unable to unregister %s.", name); gdomap_log(LOG_INFO); } } @@ -4325,7 +4158,7 @@ static void do_help(int argc, char **argv, char *options) } printf("%s -[%s]\n", argv[0], options); printf("GNU Distributed Objects name server\n"); - printf("-C help about interfaces and configuration\n"); + printf("-C help about configuration\n"); printf("-H general help\n"); printf("-I pid file to write pid\n"); printf("-L name perform lookup for name then quit.\n"); @@ -4350,7 +4183,7 @@ static void do_help(int argc, char **argv, char *options) exit(EXIT_SUCCESS); } -#if defined(__MINGW__) +#ifdef __MINGW32__ static char* quoteArg(const char *arg) { @@ -4435,11 +4268,6 @@ quoteArg(const char *arg) /** * (A dummy comment to help autogsdoc realize this is a command-line tool.) */ -#if GS_FAKE_MAIN -/* Since we don't link gnustep-base, the main function below has to be - * the real main function. */ -#undef main -#endif int main(int argc, char** argv) { @@ -4452,9 +4280,9 @@ main(int argc, char** argv) const char *lookupf = 0; int donamesf = 0; -#if defined(HAVE_SYSLOG) +#ifdef HAVE_SYSLOG /* Initially, gdomap_log errors to stderr as well as to syslogd. */ -#if defined(SYSLOG_4_2) +#ifdef SYSLOG_4_2 openlog ("gdomap", LOG_NDELAY); log_priority = LOG_DAEMON; #else @@ -4462,7 +4290,7 @@ main(int argc, char** argv) #endif #endif -#if defined(__MINGW__) +#ifdef __MINGW32__ WORD wVersionRequested; WSADATA wsaData; @@ -4474,7 +4302,7 @@ main(int argc, char** argv) * Would use inet_aton(), but older systems don't have it. */ loopback.s_addr = inet_addr("127.0.0.1"); -#if defined(__MINGW__) +#ifdef __MINGW32__ class_a_net = IN_CLASSA_NET; class_a_mask.s_addr = class_a_net; class_b_net = IN_CLASSB_NET; @@ -4534,12 +4362,10 @@ printf( "systems, this facility is not available (or is broken), so you must tell\n" "gdomap the addresses and masks of the interfaces using the '-a' command line\n" "option. The file named with '-a' should contain a series of lines with\n" -"space separated pairs of addresses and masks in 'dot' notation, eg.\n" -"192.168.1.2 255.255.255.0\n" +"space separated pairs of addresses and masks in 'dot' notation.\n" "You must NOT include loopback interfaces in this list.\n" "If you want to support broadcasting of probe information on a network,\n" -"you may supply the broadcast address as a third item on the line, eg.\n" -"192.168.1.9 255.255.255.0 192.168.1.255\n" +"you may supply the broadcast address as a third item on the line.\n" "If your operating system has some other method of giving you a list of\n" "network interfaces and masks, please send me example code so that I can\n" "implement it in gdomap.\n"); @@ -4615,35 +4441,20 @@ printf( case 'c': { - FILE *fptr; - int line = 0; - int count = 0; + FILE *fptr = fopen(optarg, "rt"); char buf[128]; - in_config = 1; - if (access(optarg, R_OK) != 0) - { - snprintf(ebuf, sizeof(ebuf), - "Unable to access probe config - '%s'\n", - optarg); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); - } - fptr = fopen(optarg, "rt"); if (fptr == 0) { - snprintf(ebuf, sizeof(ebuf), - "Unable to open probe config - '%s'\n", - optarg); - gdomap_log(LOG_CRIT); + fprintf(stderr, "Unable to open probe config - '%s'\n", + optarg); exit(EXIT_FAILURE); } while (fgets(buf, sizeof(buf), fptr) != 0) { - char *ptr = buf; + char *ptr = buf; plentry *prb; - line++; /* * Strip leading white space. */ @@ -4684,24 +4495,13 @@ printf( continue; } - if (count++ > 1000) - { - snprintf(ebuf, sizeof(ebuf), - "Too many probe configurations found"); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); - } prb = (plentry*)malloc(sizeof(plentry)); memset((char*)prb, '\0', sizeof(plentry)); prb->addr.s_addr = inet_addr(buf); if (prb->addr.s_addr == (uint32_t)-1) { - snprintf(ebuf, sizeof(ebuf), - "line %d of '%s' (%s) is not a valid address\n", - line, optarg, buf); + fprintf(stderr, "'%s' is not as valid address\n", buf); free(prb); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); } else { @@ -4720,12 +4520,9 @@ printf( { if (tmp->addr.s_addr == prb->addr.s_addr) { - snprintf(ebuf, sizeof(ebuf), - "'%s' repeat in '%s'\n", - buf, optarg); + fprintf(stderr, "'%s' repeat in '%s'\n", + buf, optarg); free(prb); - gdomap_log(LOG_CRIT); - exit(EXIT_FAILURE); break; } tmp = tmp->next; @@ -4738,7 +4535,6 @@ printf( } } fclose(fptr); - in_config = 0; } break; @@ -4785,7 +4581,7 @@ printf( exit (0); } -#if defined(__MINGW__) /* On Win32, we don't fork */ +#ifdef __MINGW32__ /* On Win32, we don't fork */ if (nofork == 0) { char **a = malloc((argc+2) * sizeof(char*)); @@ -4804,7 +4600,7 @@ printf( } if (debug) { - snprintf(ebuf, sizeof(ebuf), "initialisation complete."); + sprintf(ebuf, "initialisation complete."); gdomap_log(LOG_DEBUG); } exit(EXIT_SUCCESS); @@ -4826,7 +4622,7 @@ printf( /* * Try to run in background. */ -#if defined(NeXT) +#ifdef NeXT setpgrp(0, getpid()); #else setsid(); @@ -4836,7 +4632,7 @@ printf( default: if (debug) { - snprintf(ebuf, sizeof(ebuf), "initialisation complete."); + sprintf(ebuf, "initialisation complete."); gdomap_log(LOG_DEBUG); } exit(EXIT_SUCCESS); @@ -4858,32 +4654,32 @@ printf( } if (open("/dev/null", O_RDONLY) != 0) { - snprintf(ebuf, sizeof(ebuf), - "failed to open stdin from /dev/null (%s)\n", strerror(errno)); + sprintf(ebuf, "failed to open stdin from /dev/null (%s)\n", + strerror(errno)); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } if (open("/dev/null", O_WRONLY) != 1) { - snprintf(ebuf, sizeof(ebuf), - "failed to open stdout from /dev/null (%s)\n", strerror(errno)); + sprintf(ebuf, "failed to open stdout from /dev/null (%s)\n", + strerror(errno)); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } if (is_daemon && open("/dev/null", O_WRONLY) != 2) { - snprintf(ebuf, sizeof(ebuf), - "failed to open stderr from /dev/null (%s)\n", strerror(errno)); + sprintf(ebuf, "failed to open stderr from /dev/null (%s)\n", + strerror(errno)); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } if (debug) { - snprintf(ebuf, sizeof(ebuf), "Closed descriptors"); + sprintf(ebuf, "Closed descriptors"); gdomap_log(LOG_DEBUG); } -#endif /* !__MINGW__ */ +#endif /* !__MINGW32__ */ init_my_port(); /* Determine port to listen on. */ init_ports(); /* Create ports to handle requests. */ @@ -4895,25 +4691,22 @@ printf( if (!is_local_host(loopback)) { - snprintf(ebuf, sizeof(ebuf), - "I can't find the loopback interface on this machine."); + sprintf(ebuf, "I can't find the loopback interface on this machine."); gdomap_log(LOG_ERR); - snprintf(ebuf, sizeof(ebuf), -"Perhaps you should correct your machine configuration or use the -a flag.\n" -"Try 'gdomap -C' for more information.\n"); + sprintf(ebuf, +"Perhaps you should correct your machine configuration or use the -a flag."); gdomap_log(LOG_INFO); if (interfaces < MAX_IFACE) { addr[interfaces].s_addr = loopback.s_addr; mask[interfaces] = class_c_mask; interfaces++; - snprintf(ebuf, sizeof(ebuf), - "I am assuming loopback interface on 127.0.0.1"); + sprintf(ebuf, "I am assuming loopback interface on 127.0.0.1"); gdomap_log(LOG_INFO); } else { - snprintf(ebuf, sizeof(ebuf), + sprintf(ebuf, "You have too many network interfaces to add the loopback interface on " "127.0.0.1 - you need to change the 'MAX_IFACE' constant in gdomap.c and " "rebuild it."); @@ -4930,7 +4723,7 @@ printf( { FILE *fptr; -#ifndef __MINGW__ +#ifndef __MINGW32__ if (getuid () == 0) #endif { @@ -4939,8 +4732,7 @@ printf( if (fptr == 0) { - snprintf(ebuf, sizeof(ebuf), - "Unable to create new pid file - '%s'", pidfile); + sprintf(ebuf, "Unable to create new pid file - '%s'", pidfile); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -4948,23 +4740,22 @@ printf( fclose(fptr); chmod(pidfile, 0644); } -#ifndef __MINGW__ +#ifndef __MINGW32__ else { - snprintf(ebuf, sizeof(ebuf), - "Only root user can write to pid file\n"); + sprintf(ebuf, "Only root user can write to pid file\n"); gdomap_log(LOG_WARNING); } #endif } { -#ifndef __MINGW__ +#ifndef __MINGW32__ int uid = -2; int gid = -2; #endif -#if defined(HAVE_PWD_H) -#if defined(HAVE_GETPWNAM) +#ifdef HAVE_PWD_H +#ifdef HAVE_GETPWNAM struct passwd *pw = getpwnam("nobody"); if (pw != 0) @@ -4979,10 +4770,10 @@ printf( /* * As another level of paranoia - restrict this process to /tmp */ -#ifndef __MINGW__ +#ifndef __MINGW32__ if (chdir("/tmp") < 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to change directory to /tmp"); + sprintf(ebuf, "Unable to change directory to /tmp"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } @@ -4991,16 +4782,16 @@ printf( { if (chroot("/tmp") < 0) { - snprintf(ebuf, sizeof(ebuf), "Unable to change root to /tmp"); + sprintf(ebuf, "Unable to change root to /tmp"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } chdir("/"); } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ #endif /* __svr4__ */ -#ifndef __MINGW__ +#ifndef __MINGW32__ /* * Try to become a 'safe' user now that we have * done everything that needs root priv. @@ -5015,33 +4806,30 @@ printf( } if (setgid (gid) < 0) { - snprintf(ebuf, sizeof(ebuf), - "Failed setgid(%d) - %s", gid, strerror(errno)); + sprintf(ebuf, "Failed setgid(%d) - %s", gid, strerror(errno)); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } if (setuid (uid) < 0) { - snprintf(ebuf, sizeof(ebuf), - "Failed setuid(%d) - %s", uid, strerror(errno)); + sprintf(ebuf, "Failed setuid(%d) - %s", uid, strerror(errno)); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } if (getuid () == 0) { - snprintf(ebuf, sizeof(ebuf), - "Still running as root after trying to change"); + sprintf(ebuf, "Still running as root after trying to change"); gdomap_log(LOG_CRIT); exit(EXIT_FAILURE); } -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ } init_probe(); /* Probe other name servers on net. */ if (debug) { - snprintf(ebuf, sizeof(ebuf), "entering main loop.\n"); + sprintf(ebuf, "entering main loop.\n"); gdomap_log(LOG_DEBUG); } handle_io(); @@ -5062,8 +4850,7 @@ queue_probe(struct in_addr* to, struct in_addr* from, int l, struct in_addr* e, if (debug > 2) { - snprintf(ebuf, sizeof(ebuf), - "Probing for server on '%s' from '", inet_ntoa(*to)); + sprintf(ebuf, "Probing for server on '%s' from '", inet_ntoa(*to)); strcat(ebuf, inet_ntoa(*from)); strcat(ebuf, "'"); gdomap_log(LOG_DEBUG); @@ -5071,12 +4858,11 @@ queue_probe(struct in_addr* to, struct in_addr* from, int l, struct in_addr* e, { int i; - snprintf(ebuf, sizeof(ebuf), - " %d additional local addresses sent -", l); + sprintf(ebuf, " %d additional local addresses sent -", l); gdomap_log(LOG_DEBUG); for (i = 0; i < l; i++) { - snprintf(ebuf, sizeof(ebuf), " '%s'", inet_ntoa(e[i])); + sprintf(ebuf, " '%s'", inet_ntoa(e[i])); gdomap_log(LOG_DEBUG); } } @@ -5159,15 +4945,15 @@ xgethostname (void) char *buf; int err; -#if defined(MAXHOSTNAMELEN) +#ifdef MAXHOSTNAMELEN size = MAXHOSTNAMELEN; addnull = 1; #else /* MAXHOSTNAMELEN */ -#if defined(_SC_HOST_NAME_MAX) +#ifdef _SC_HOST_NAME_MAX size = sysconf (_SC_HOST_NAME_MAX); addnull = 1; #endif /* _SC_HOST_NAME_MAX */ -#if defined(INTERNET_MAX_HOST_NAME_LENGTH) +#ifdef INTERNET_MAX_HOST_NAME_LENGTH size = INTERNET_MAX_HOST_NAME_LENGTH; addnull = 1; #endif diff --git a/Tools/gdomap.gsdoc b/Tools/gdomap.gsdoc index fb7509c16..e95283d5f 100644 --- a/Tools/gdomap.gsdoc +++ b/Tools/gdomap.gsdoc @@ -20,13 +20,11 @@ notice and this notice are preserved. gdomap

- The gdomap daemon is used by GNUstep programs to look up distributed - objects of processes running on the local machine as well as across - the network. -

-

- If you are packaging GNUstep for inclusion in a software distribution - you may want to skip to the final section of this document. + The gdomap daemon is used by GNUstep programs to look up distributed + objects of processes running across the network (and between different + user accounts on a single machine). The deamon is NOT used + for lookup where two processes belonging to the same user are using a + host-local connection.

Usually the gdomap daemon is started at system boot time and binds @@ -313,36 +311,6 @@ notice and this notice are preserved. -

- Notes for Packagers - -

- The gdomap process is a system daemon used to coordinate - services between different machines. As such it should be - started (as root) at system boot time (if inter-host messaging - is desired), and you need to write the appropriate startup - scripts for your system and put them in place when the - package is installed.
- Alternatively you may install gdomap setuid to run as root, - and GNUstep programs will launch it on demand ... but this - is not recommended as it provides lass control than when - you write a proper startup script. -

- -

- The default operation of gdomap is to probe the hosts on the - local network to find other machines with copies of gdomap - running, so that all the machines on the network can be kept - informed of the seervices provided by GNUstep servers.
- This probing may be considered unfriendly by other users of - the LAN, so it is usually better to provide a configuration - file specifying the IP addresses of machines to be probed, - and start up gdomap at boot time with the command line option - to tell it to read the file. -

- -
- diff --git a/Tools/gdomap.h b/Tools/gdomap.h index e5657d730..0e81d6243 100644 --- a/Tools/gdomap.h +++ b/Tools/gdomap.h @@ -4,18 +4,21 @@ Written by: Richard Frith-Macdonald Created: October 1996 - This file is part of the GNUstep Project. + This file is part of the GNUstep Base Library. - 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 + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. - If not, write to the Free Software Foundation, - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + This library 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 + Library General Public License for more details. + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ /* @@ -180,7 +183,7 @@ */ #define GDO_NET_MASK 0x70 /* Network protocol of port. */ #define GDO_NET_TCP 0x10 -#define GDO_NET_UDP 0x20 +#define GDO_NET_UDP 0x10 #define GDO_SVC_MASK 0x0f /* High level protocol of port. */ #define GDO_SVC_GDO 0x01 #define GDO_SVC_FOREIGN 0x02 diff --git a/Tools/gsdoc.7 b/Tools/gsdoc.7 index 0a031470b..a0aa87d7d 100644 --- a/Tools/gsdoc.7 +++ b/Tools/gsdoc.7 @@ -51,4 +51,4 @@ This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B gsdoc -was defined by Richard Frith-Macdonald +was defined by Richard Frith-McDonald diff --git a/Tools/gspath.1 b/Tools/gspath.1 index d160ce73d..563a743ad 100644 --- a/Tools/gspath.1 +++ b/Tools/gspath.1 @@ -51,6 +51,6 @@ This manual page first appeared in gnustep-base 1.11.1 (July 2005). .P .SH AUTHORS .B gspath -was written by Richard Frith-Macdonald . +was written by Richard Frith-McDonald . .PP -This man page was written by Richard Frith-McDonald . +This man page was written by Richard Frith-Macdonald . diff --git a/Tools/gspath.m b/Tools/gspath.m index 9e73f9239..4b942a61f 100644 --- a/Tools/gspath.m +++ b/Tools/gspath.m @@ -6,25 +6,20 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" +#include "config.h" +#include /** @@ -57,7 +52,7 @@ main(int argc, char** argv, char **env) NSArray *args; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; @@ -76,7 +71,7 @@ main(int argc, char** argv, char **env) NSString *name = [[args objectAtIndex: 1] lowercaseString]; NSString *sep; -#ifdef __MINGW__ +#ifdef __MINGW32__ sep = @";"; #else sep = @":"; diff --git a/Tools/locale_alias.m b/Tools/locale_alias.m index da20655d2..71b9b8217 100644 --- a/Tools/locale_alias.m +++ b/Tools/locale_alias.m @@ -8,32 +8,15 @@ AFAIK: This only works on machines that support setlocale. The files created may require hand editing. - - This file is part of the GNUstep Project - - 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. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. - If not, write to the Free Software Foundation, - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#import "common.h" - #include #include #include #include #include - -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSDictionary.h" -#import "GNUstepBase/GSLocale.h" +#include +#include #define MAXSTRING 100 @@ -52,7 +35,7 @@ loc_read_file(const char *dir, const char *file) if (strcmp(file, "POSIX") == 0) return 0; - sprintf(name, "%s/%s", dir, file); + snprintf(name, sizeof(name), "%s/%s", dir, file); fp = fopen(name, "r"); if (fp == NULL) return -1; @@ -68,7 +51,8 @@ loc_read_file(const char *dir, const char *file) } if ((s = strstr(buf, "ocale for")) != NULL) { - strcpy(country, s+10); + strncpy(country, s + 10, sizeof(country) - 1); + country[sizeof(country) - 1] = '\0'; s = strchr(country, '\n'); if (s) *s = '\0'; @@ -77,10 +61,11 @@ loc_read_file(const char *dir, const char *file) break; } - strcpy(locale, file); + strncpy(locale, file, sizeof(locale) - 1); + locale[sizeof(locale) - 1] = '\0'; if (strlen(country) > 0 && strcmp(country, language) != 0) { - strcat(country, language); + strncat(country, language, sizeof(country) - 1 - strlen(country)); [dict setObject: [NSString stringWithUTF8String: country] forKey: [NSString stringWithUTF8String: locale]]; } diff --git a/Tools/make_strings/GNUmakefile b/Tools/make_strings/GNUmakefile index 79bdbde09..02dfb3d6a 100644 --- a/Tools/make_strings/GNUmakefile +++ b/Tools/make_strings/GNUmakefile @@ -18,15 +18,16 @@ # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02111 USA. +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + +# Install into the system root by default -PACKAGE_NAME = gnustep-base GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../base.make include $(GNUSTEP_MAKEFILES)/common.make include ../../config.mak VERSION = 0.4.2 +PACKAGE_NAME = make_strings TOOL_NAME = make_strings make_strings_OBJC_FILES = \ diff --git a/Tools/make_strings/GNUmakefile.preamble b/Tools/make_strings/GNUmakefile.preamble index e2ff805f3..a259e7965 100644 --- a/Tools/make_strings/GNUmakefile.preamble +++ b/Tools/make_strings/GNUmakefile.preamble @@ -19,8 +19,7 @@ # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02111 USA. +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. # # @@ -40,7 +39,7 @@ ADDITIONAL_CPPFLAGS += # Additional flags to pass to the Objective-C compiler -ADDITIONAL_OBJCFLAGS += $(WARN_FLAGS) +ADDITIONAL_OBJCFLAGS += -Wall # Additional flags to pass to the C compiler #ADDITIONAL_CFLAGS += diff --git a/Tools/make_strings/SourceEntry.h b/Tools/make_strings/SourceEntry.h index b13828b42..837aed5bf 100644 --- a/Tools/make_strings/SourceEntry.h +++ b/Tools/make_strings/SourceEntry.h @@ -9,14 +9,13 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ #ifndef SourceEntry_h diff --git a/Tools/make_strings/SourceEntry.m b/Tools/make_strings/SourceEntry.m index 8104bacdb..a7133cbea 100644 --- a/Tools/make_strings/SourceEntry.m +++ b/Tools/make_strings/SourceEntry.m @@ -9,14 +9,13 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ #include diff --git a/Tools/make_strings/StringsEntry.h b/Tools/make_strings/StringsEntry.h index 562aae748..65f5079b4 100644 --- a/Tools/make_strings/StringsEntry.h +++ b/Tools/make_strings/StringsEntry.h @@ -9,14 +9,13 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ #ifndef StringsEntry_h diff --git a/Tools/make_strings/StringsEntry.m b/Tools/make_strings/StringsEntry.m index 058feda5f..cb22ada0c 100644 --- a/Tools/make_strings/StringsEntry.m +++ b/Tools/make_strings/StringsEntry.m @@ -9,20 +9,17 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ #include #include -#include -#include #include "StringsEntry.h" diff --git a/Tools/make_strings/StringsFile.h b/Tools/make_strings/StringsFile.h index 1dc8301f4..cffd85a26 100644 --- a/Tools/make_strings/StringsFile.h +++ b/Tools/make_strings/StringsFile.h @@ -9,14 +9,13 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ #ifndef StringsFile_h diff --git a/Tools/make_strings/StringsFile.m b/Tools/make_strings/StringsFile.m index 473439d93..43d456149 100644 --- a/Tools/make_strings/StringsFile.m +++ b/Tools/make_strings/StringsFile.m @@ -9,21 +9,20 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#import "common.h" -#import "Foundation/NSString.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSDate.h" +#include +#include +#include +#include +#include #include "StringsFile.h" diff --git a/Tools/make_strings/make_strings.h b/Tools/make_strings/make_strings.h index 56fabb345..a3ef54541 100644 --- a/Tools/make_strings/make_strings.h +++ b/Tools/make_strings/make_strings.h @@ -9,14 +9,13 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ #ifndef make_strings_h diff --git a/Tools/make_strings/make_strings.m b/Tools/make_strings/make_strings.m index 25c52f507..831d4ec4a 100644 --- a/Tools/make_strings/make_strings.m +++ b/Tools/make_strings/make_strings.m @@ -9,22 +9,20 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#import "common.h" -#import "Foundation/NSString.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSEnumerator.h" -#import "Foundation/NSArray.h" +#include +#include +#include +#include +#include #include "make_strings.h" @@ -89,23 +87,6 @@ static int isname(unsigned char ch) be any reason to). */ - -#define add_arg_ch(ch)\ - {\ - if (arg_len[num_args]+1>=arg_size[num_args])\ - {\ - arg_size[num_args]+=512;\ - args[num_args]=realloc(args[num_args],arg_size[num_args]);\ - if (!args[num_args])\ - {\ - NSLog(@"out of memory!\n");\ - exit(1);\ - }\ - }\ - args[num_args][arg_len[num_args]++]=ch;\ - args[num_args][arg_len[num_args]]=0;\ - } - static int ParseFile(const char *filename,NSMutableDictionary *tables) { FILE *f; @@ -137,6 +118,21 @@ static int ParseFile(const char *filename,NSMutableDictionary *tables) int depth=0; + void add_arg_ch(int ch) + { + if (arg_len[num_args]+1>=arg_size[num_args]) + { + arg_size[num_args]+=512; + args[num_args]=realloc(args[num_args],arg_size[num_args]); + if (!args[num_args]) + { + NSLog(@"out of memory!\n"); + exit(1); + } + } + args[num_args][arg_len[num_args]++]=ch; + args[num_args][arg_len[num_args]]=0; + } filenamestr = [NSString stringWithCString: filename diff --git a/Tools/mkchlog.sh b/Tools/mkchlog.sh new file mode 100644 index 000000000..de465a174 --- /dev/null +++ b/Tools/mkchlog.sh @@ -0,0 +1,6 @@ +#!/bin/sh +svn log -rHEAD --xml --verbose | xsltproc /usr/local/share/svn2cl/svn2cl.xsl - > ChangeLog.new +cat ChangeLog >> ChangeLog.new +mv ChangeLog.new ChangeLog +$EDITOR ChangeLog +svn commit -m 'Added ChangeLog entry from last commit' ChangeLog diff --git a/Tools/pl.m b/Tools/pl.m index 10815ed9b..356a892b6 100644 --- a/Tools/pl.m +++ b/Tools/pl.m @@ -8,31 +8,26 @@ Author: Gregory John Casamento Date: 17 Jan 2000 - This file is part of the GNUstep Project + This file is part of GNUstep - 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 library 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 2 of the License, or (at your option) any later version. + + This library 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; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#import "common.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSData.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" +#import void create_output(id propertyList) { @@ -81,7 +76,7 @@ id process_plist(NSData *inputData) NS_DURING propertyList = [string propertyList]; NS_HANDLER - NSLog(@"%@", localException); + NSLog([localException description]); NS_ENDHANDLER // return the results diff --git a/Tools/pl2link.m b/Tools/pl2link.m index 74b76e4c7..75c684dae 100644 --- a/Tools/pl2link.m +++ b/Tools/pl2link.m @@ -8,26 +8,27 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#import "common.h" + */ -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSProcessInfo.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include int main(int argc, char** argv, char **env) @@ -43,7 +44,7 @@ main(int argc, char** argv, char **env) NSString *entry; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; procinfo = [NSProcessInfo processInfo]; diff --git a/Tools/pldes.1 b/Tools/pldes.1 index 0f6caa70d..86ac3baef 100644 --- a/Tools/pldes.1 +++ b/Tools/pldes.1 @@ -75,7 +75,7 @@ This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B pldes, plget, plparse, plser -were written by Richard Frith-Macdonald . +were written by Richard Frith-McDonald . .PP .B plmerge was written by Jonathan Gapen . diff --git a/Tools/pldes.m b/Tools/pldes.m index 34dd916e3..174230992 100644 --- a/Tools/pldes.m +++ b/Tools/pldes.m @@ -6,27 +6,29 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSAutoreleasePool.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /**

This tool converts a binary serialised property list to a text @@ -41,7 +43,7 @@ main(int argc, char** argv, char **env) unsigned i; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; diff --git a/Tools/plget.m b/Tools/plget.m index 4b8293a66..1cbe355e9 100644 --- a/Tools/plget.m +++ b/Tools/plget.m @@ -6,28 +6,29 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSAutoreleasePool.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /**

This tool extracts a string value from a dictionary in a property @@ -50,8 +51,9 @@ main(int argc, char** argv, char **env) int count; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif + pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; if (proc == nil) { diff --git a/Tools/plmerge.m b/Tools/plmerge.m index 85c6e2541..5ea5e36b5 100644 --- a/Tools/plmerge.m +++ b/Tools/plmerge.m @@ -6,28 +6,32 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSFileManager.h" -#import "Foundation/NSProcessInfo.h" -#import "GNUstepBase/Additions.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef NeXT_Foundation_LIBRARY +#include "GNUstepBase/GSCategories.h" +#include "GNUstepBase/GSObjCRuntime.h" +#endif /**

This tool merges text property lists into a single property list. @@ -44,7 +48,7 @@ main(int argc, char** argv, char **env) unsigned i; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; procinfo = [NSProcessInfo processInfo]; diff --git a/Tools/plparse.m b/Tools/plparse.m index 9eb57c428..d83a31c73 100644 --- a/Tools/plparse.m +++ b/Tools/plparse.m @@ -6,28 +6,27 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSCharacterSet.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSAutoreleasePool.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include /* * If there is any non-ascii characrer in the string, @@ -81,7 +80,7 @@ main(int argc, char** argv, char **env) int retval = 0; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; diff --git a/Tools/plser.m b/Tools/plser.m index 9d0ff73f9..6d5f30e38 100644 --- a/Tools/plser.m +++ b/Tools/plser.m @@ -6,27 +6,29 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSFileHandle.h" -#import "Foundation/NSAutoreleasePool.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /**

This tool converts a text property list to a binary serialised @@ -41,7 +43,7 @@ main(int argc, char** argv, char **env) unsigned i; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; diff --git a/Tools/sfparse.1 b/Tools/sfparse.1 index d13861995..f99061faf 100644 --- a/Tools/sfparse.1 +++ b/Tools/sfparse.1 @@ -34,4 +34,4 @@ This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B sfparse -was written by Richard Frith-Macdonald +was written by Richard Frith-McDonald diff --git a/Tools/sfparse.m b/Tools/sfparse.m index 05a6f6b0e..ddc727fc4 100644 --- a/Tools/sfparse.m +++ b/Tools/sfparse.m @@ -6,28 +6,30 @@ This file is part of the GNUstep Project - This program is free software; you can redistribute it and/or + This library 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#import "common.h" - -#import "Foundation/NSArray.h" -#import "Foundation/NSData.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "Foundation/NSAutoreleasePool.h" -#import "GNUstepBase/Additions.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef NeXT_Foundation_LIBRARY +#include "GNUstepBase/GSCategories.h" +#endif int convert_unicode(NSArray *args) @@ -47,11 +49,11 @@ convert_unicode(NSArray *args) data = [NSData dataWithContentsOfFile: file]; myString = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]; - IF_NO_GC([myString autorelease];) + AUTORELEASE(myString); if ([myString length] == 0) { - myString = [[NSString alloc] initWithData: data - encoding: [NSString defaultCStringEncoding]]; + myString = [[[NSString alloc] initWithData: data + encoding: [NSString defaultCStringEncoding]] autorelease]; } output = [[file lastPathComponent] stringByAppendingPathExtension: @"unicode"]; @@ -118,7 +120,7 @@ main(int argc, char** argv, char **env) int retval = 0; #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; #endif pool = [NSAutoreleasePool new]; proc = [NSProcessInfo processInfo]; @@ -162,8 +164,7 @@ main(int argc, char** argv, char **env) if (result == nil) GSPrintf(stderr, @"Parsing '%@' - nil property list\n", file); else if ([result isKindOfClass: [NSDictionary class]] == YES) - GSPrintf(stderr, @"Parsing '%@' - seems ok (%d entries)\n", - file, [result count]); + GSPrintf(stderr, @"Parsing '%@' - seems ok\n", file); else GSPrintf(stderr, @"Parsing '%@' - unexpected class - %@\n", file, [[result class] description]); diff --git a/Tools/xmlparse.1 b/Tools/xmlparse.1 index 1137e405d..4d6949ee9 100644 --- a/Tools/xmlparse.1 +++ b/Tools/xmlparse.1 @@ -24,4 +24,4 @@ This manual page first appeared in gnustep-base 1.9.2 (March 2004). .P .SH AUTHORS .B xmlparse -was written by Richard Frith-Macdonald +was written by Richard Frith-McDonald diff --git a/Tools/xmlparse.m b/Tools/xmlparse.m index c0ea953c1..d7ea2d992 100644 --- a/Tools/xmlparse.m +++ b/Tools/xmlparse.m @@ -10,25 +10,28 @@ 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. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. You should have received a copy of the GNU General Public - License along with this program; see the file COPYINGv3. + License along with this program; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "config.h" #include - -#import "common.h" -#import "Foundation/NSArray.h" -#import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSPathUtilities.h" -#import "Foundation/NSProcessInfo.h" -#import "Foundation/NSUserDefaults.h" -#import "GNUstepBase/Additions.h" +#ifdef NeXT_Foundation_LIBRARY +#include +#include +#else +#include +#include +#include +#include +#endif +#include @interface GSXMLParser (Loader) + (NSString*) loadEntity: (NSString*)publicId @@ -70,7 +73,7 @@ main(int argc, char **argv, char **env) CREATE_AUTORELEASE_POOL(pool); #ifdef GS_PASS_ARGUMENTS - GSInitializeProcess(argc, argv, env); + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; #endif #ifndef HAVE_LIBXML diff --git a/Version b/Version index b9f5ee9bf..e6359e59c 100644 --- a/Version +++ b/Version @@ -6,10 +6,10 @@ GCC_VERSION=2.9.5 # The version number of this release. MAJOR_VERSION=1 -MINOR_VERSION=20 -SUBMINOR_VERSION=2 +MINOR_VERSION=14 +SUBMINOR_VERSION=0 # numeric value should match above -VERSION_NUMBER=120.2 +VERSION_NUMBER=114.0 GNUSTEP_BASE_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION} VERSION=${GNUSTEP_BASE_VERSION} diff --git a/base.make.in b/base.make.in index 15f08a347..ebc8752dc 100644 --- a/base.make.in +++ b/base.make.in @@ -12,8 +12,8 @@ # # This library 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 2 of the License, or (at your option) any later version. +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # You should have received a copy of the GNU General Public # License along with this library; see the file COPYING.LIB. @@ -42,16 +42,23 @@ ifeq ($(FOUNDATION_LIB),gnu) FND_LIBS = -lgnustep-base FND_DEFINE = -DGNUSTEP_BASE_LIBRARY=1 GNUSTEP_DEFINE = -DGNUSTEP -else -# -# Not using the GNUstep foundation ... must be Apple's -# So we need to use the base additions library. -# - FND_LIBS = -lgnustep-baseadd -framework Foundation + # If gc=yes was passed, use the appropriate library and defines + ifeq ($(gc), yes) + AUXILIARY_CPPFLAGS += -DGS_WITH_GC=1 + AUXILIARY_INCLUDE_DIRS += -I/usr/include/gc + endif endif - GNUSTEP_BASE_HAVE_GNUTLS=@HAVE_GNUTLS@ GNUSTEP_BASE_HAVE_LIBXML=@HAVE_LIBXML@ GNUSTEP_BASE_HAVE_MDNS=@HAVE_MDNS@ - GNUSTEP_BASE_HAVE_AVAHI=@HAVE_AVAHI@ + + GNUSTEP_BASE_HAVE_UCI=@HAVE_UCI@ + + # If we determined that the Objective-C runtime does not support + # native Objective-C exceptions, turn them off. This overrides + # the USE_OBJC_EXCEPTIONS setting in gnustep-make's config.make. + ifeq (@BASE_NATIVE_OBJC_EXCEPTIONS@, 0) + USE_OBJC_EXCEPTIONS = no + endif + endif # BASE_MAKE_LOADED diff --git a/config.mak.in b/config.mak.in index 76299ea6d..62e52e824 100644 --- a/config.mak.in +++ b/config.mak.in @@ -1,29 +1,25 @@ # # Extra make variables for base library # -# Copyright (C) 2005-2010 Free Software Foundation +# Copyright (C) 2005 Free Software Foundation # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. + WHOAMI=@WHOAMI@ DYNAMIC_LINKER=@DYNAMIC_LINKER@ HAVE_LIBXML=@HAVE_LIBXML@ -HAVE_GNUTLS=@HAVE_GNUTLS@ +HAVE_BLOCKS=@HAVE_BLOCKS@ WITH_FFI=@WITH_FFI@ NX_CONST_STRING_CLASS=@NX_CONST_STRING_CLASS@ -OBJCFLAGS+=@OBJCFLAGS@ -OBJC2RUNTIME=@OBJC2RUNTIME@ -OBJCSYNC=@OBJCSYNC@ -WARN_FLAGS=@WARN_FLAGS@ +HAVE_PTHREAD_H=@HAVE_PTHREAD_H@ HAVE_INET_PTON=@HAVE_INET_PTON@ -HAVE_INET_NTOP=@HAVE_INET_NTOP@ -HAVE_OBJC_SYNC_ENTER=@HAVE_OBJC_SYNC_ENTER@ CONFIG_SYSTEM_INCL += @INCLUDE_FLAGS@ ifeq ($(shared),yes) @@ -31,10 +27,10 @@ ifeq ($(shared),yes) CONFIG_SYSTEM_LIB_DIR += @LDIR_FLAGS@ endif -GNUSTEP_INSTALL_GDOMAP_AS_SETUID=@GNUSTEP_INSTALL_GDOMAP_AS_SETUID@ - GNUSTEP_BASE_HAVE_LIBXML=@HAVE_LIBXML@ -GNUSTEP_BASE_HAVE_GNUTLS=@HAVE_GNUTLS@ +GNUSTEP_BASE_HAVE_MDNS=@HAVE_MDNS@ +GNUSTEP_BASE_HAVE_AVAHI=@HAVE_AVAHI@ +GNUSTEP_BASE_HAVE_ICU=@HAVE_ICU@ # Default to building only -baseadd # on non *-gnu-* library combos @@ -42,38 +38,3 @@ ifneq ($(FOUNDATION_LIB),gnu) add=yes base=no endif - -GNUSTEP_BASE_DOMAIN=@GNUSTEP_BASE_DOMAIN@ -GNUSTEP_BASE_RELATIVE_PATHS=@GNUSTEP_BASE_RELATIVE_PATHS@ - -ifeq ($(GNUSTEP_BASE_RELATIVE_PATHS), yes) -ifneq ($(GNUSTEP_BASE_DOMAIN), $(GNUSTEP_INSTALLATION_DOMAIN)) -$(warning "Error: GNUSTEP_INSTALLATION_DOMAIN does not match GNUSTEP_BASE_DOMAIN") -$(warning " ") -$(warning "You can install gnustep-base in one of the four domains: SYSTEM, LOCAL, NETWORK or USER.") -$(warning " ") -$(warning "gnustep-base was configured to be installed into: $(GNUSTEP_BASE_DOMAIN)") -$(warning "but it would now being installed into: $(GNUSTEP_INSTALLATION_DOMAIN)") -$(warning "That's not right: they must match.") -$(warning " ") -$(warning "If you want to install into $(GNUSTEP_BASE_DOMAIN), please use") -$(warning " ") -$(warning " make install GNUSTEP_INSTALLATION_DOMAIN=$(GNUSTEP_BASE_DOMAIN) [plus any other options you need]") -$(warning " ") -$(warning "Instead, if you want to install into $(GNUSTEP_INSTALLATION_DOMAIN), please reconfigure") -$(warning "gnustep-base by doing") -$(warning " ") -$(warning " ./configure --with-installation-domain=$(GNUSTEP_INSTALLATION_DOMAIN) [plus any other options you need]") -$(warning " ") -$(warning "and then recompile and reinstall.") - -# We used to automatically rerun configure here. Unfortunately we -# don't know if the right domain that we should be installing into is -# GNUSTEP_BASE_DOMAIN (specified or automatically picked up by -# configure) or GNUSTEP_INSTALLATION_DOMAIN (specified or -# automatically picked up by make install) so the user really has to -# spend two minutes checking this and fixing it herself. - -$(error "Please fix the installation domain then try again. If you are stuck, contact discuss-gnustep@gnu.org for help.") -endif -endif diff --git a/config/config.constant-string-class.m b/config/config.constant-string-class.m index 67c96bc01..2125ca74c 100644 --- a/config/config.constant-string-class.m +++ b/config/config.constant-string-class.m @@ -8,15 +8,16 @@ 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 2 of the License, or (at your option) any later version. + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. */ /* must be compiled compile using -fconstant-string-class=NSConstantString as an option to gcc. If it doesn't work, it means your gcc doesn't support this option. */ -#include "objc-common.g" +#include +#include /* Define our custom constant string class */ @interface FooConstantString : Object diff --git a/config/config.ffi.c b/config/config.ffi.c deleted file mode 100644 index 4121faebc..000000000 --- a/config/config.ffi.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include - - -typedef struct cls_struct_combined { - float a; - float b; - float c; - float d; -} cls_struct_combined; - -void cls_struct_combined_fn(struct cls_struct_combined arg) -{ -/* - printf("GOT %g %g %g %g, EXPECTED 4 5 1 8\n", - arg.a, arg.b, - arg.c, arg.d); - fflush(stdout); -*/ - if (arg.a != 4 || arg.b != 5 || arg.c != 6 || arg.d != 8) abort(); -} - -static void -cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata) -{ - struct cls_struct_combined a0; - - a0 = *(struct cls_struct_combined*)(args[0]); - - cls_struct_combined_fn(a0); -} - - -int main (void) -{ - ffi_cif cif; - void *code; - ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code); - ffi_type* cls_struct_fields0[5]; - ffi_type cls_struct_type0; - ffi_type* dbl_arg_types[5]; - - cls_struct_type0.size = 0; - cls_struct_type0.alignment = 0; - cls_struct_type0.type = FFI_TYPE_STRUCT; - cls_struct_type0.elements = cls_struct_fields0; - - struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0}; - - cls_struct_fields0[0] = &ffi_type_float; - cls_struct_fields0[1] = &ffi_type_float; - cls_struct_fields0[2] = &ffi_type_float; - cls_struct_fields0[3] = &ffi_type_float; - cls_struct_fields0[4] = NULL; - - dbl_arg_types[0] = &cls_struct_type0; - dbl_arg_types[1] = NULL; - - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void, dbl_arg_types) - != FFI_OK) abort(); - - if (ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) - != FFI_OK) abort(); - - ((void(*)(cls_struct_combined)) (code))(g_dbl); - exit(0); -} diff --git a/config/config.forward.m b/config/config.forward.m index 5bb882e20..d63658c4a 100644 --- a/config/config.forward.m +++ b/config/config.forward.m @@ -1,5 +1,4 @@ - -#include "objc-common.g" +#include int main (void) { diff --git a/config/config.forward2.m b/config/config.forward2.m deleted file mode 100644 index 09d296fc6..000000000 --- a/config/config.forward2.m +++ /dev/null @@ -1,7 +0,0 @@ -#include "objc-common.g" - -int main (void) -{ - IMP (*__objc_msg_forward1)(id,SEL) = __objc_msg_forward2; - return 0; -} diff --git a/config/config.initialize.m b/config/config.initialize.m new file mode 100644 index 000000000..b87a829fc --- /dev/null +++ b/config/config.initialize.m @@ -0,0 +1,110 @@ +/* Test whether Objective-C runtime +initialize support is thread-safe + */ + +#include "objc-common.g" +#include +#include + +#if defined(_WIN32) +# define mySleep(X) usleep(1000*(X)) +#else +# define mySleep(X) sleep(X) +#endif + +/* Use volatile variables so compiler optimisation won't prevent one thread + * from seeing changes made by another. + */ +static volatile unsigned initialize_entered = 0; +static volatile unsigned initialize_exited = 0; +static volatile unsigned class_entered = 0; +static volatile BOOL may_proceed = NO; + +@interface MyClass : NSObject +@end + +@implementation MyClass + ++ (void) initialize +{ + initialize_entered++; + while (NO == may_proceed) + ; + initialize_exited++; +} + ++ (Class) class +{ + class_entered++; + return self; +} + +@end + +static void * +test(void *arg) +{ + [MyClass class]; + return 0; +} + +int +main() +{ + pthread_t t1; + pthread_t t2; + unsigned counter; + + if (0 == pthread_create(&t1, 0, test, 0)) + { + for (counter = 0; 0 == initialize_entered && counter < 5; counter++) + { + mySleep(1); + } + + if (0 == initialize_entered) + { + fprintf(stderr, "Failed to initialize\n"); + return 1; + } + + if (0 == pthread_create(&t2, 0, test, 0)) + { + /* Wait long enough for t2 to try calling +class + */ + mySleep(1); + + if (class_entered > 0) + { + fprintf(stderr, "class entered prematurely\n"); + return 1; + } + + /* Let t1 proceed and wait long enough for it to complete + * +initialize and for both threads to call +class + */ + may_proceed = YES; + for (counter = 0; 2 > class_entered && counter < 5; counter++) + { + mySleep(1); + } + + if (2 == class_entered) + { + return 0; // OK + } + fprintf(stderr, "problem with initialize\n"); + return 1; + } + else + { + fprintf(stderr, "failed to create t2\n"); + return 1; + } + } + else + { + fprintf(stderr, "failed to create t1\n"); + return 1; + } +} + diff --git a/config/config.joinable.m b/config/config.joinable.m deleted file mode 100644 index 7f9221235..000000000 --- a/config/config.joinable.m +++ /dev/null @@ -1,19 +0,0 @@ -/* Test whether Objective-C runtime uses pthreads and doesn't detach - * them properly. If the join attempt succeeds, the thread was created - * joinable (which it shouldn't be) and this program returns 0. - */ - -#include "objc-common.g" -#include - -int -main() -{ - id o = [Object new]; - pthread_t tid; - void *value_ptr; - - tid = (pthread_t)objc_thread_detach (@selector(hash), o, nil); - return pthread_join (tid, &value_ptr); -} - diff --git a/config/config.loadtest.m b/config/config.loadtest.m index edc60e4bf..a7f9f8619 100644 --- a/config/config.loadtest.m +++ b/config/config.loadtest.m @@ -1,7 +1,21 @@ +/* Dummy NXConstantString impl for so libobjc that doesn't include it */ +/* + Copyright (C) 2005 Free Software Foundation -#include "objc-common.g" + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. +*/ +#ifndef NeXT_RUNTIME +#include +@implementation NXConstantString +@end +#endif -@interface Test : NSObject +#include + +@interface Test : Object +static int test_result; +(void) load; +(int) test_result; @end @@ -12,6 +26,4 @@ static int test_result = 1; +(int) test_result {return test_result;} @end -int main (void) { -return [Test test_result]; -} +int main (void) {return [Test test_result];} diff --git a/config/config.nextrt.m b/config/config.nextrt.m index 8034038ae..215f26779 100644 --- a/config/config.nextrt.m +++ b/config/config.nextrt.m @@ -5,7 +5,7 @@ With the GNU runtime, this file does not link. */ -#include "objc-common.g" +#include int libobjects_nextrt_checker () { diff --git a/config/config.non-fragile-ivars.m b/config/config.non-fragile-ivars.m deleted file mode 100644 index 01b264e12..000000000 --- a/config/config.non-fragile-ivars.m +++ /dev/null @@ -1,13 +0,0 @@ -/* A program for testing if the compiler is using non-fragile-ivars. - * Fails to build or returns 1 if the feature is not availale. - */ - -int -main() -{ -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -return __has_feature(objc_nonfragile_abi) ? 0 : 1; -} - diff --git a/config/config.objc.m b/config/config.objc.m index b85545fb8..1080526b5 100644 --- a/config/config.objc.m +++ b/config/config.objc.m @@ -1,5 +1,18 @@ +/* Dummy NXConstantString impl for so libobjc that doesn't include it */ +/* + Copyright (C) 2005 Free Software Foundation -#include "objc-common.g" + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. +*/ +#ifndef NeXT_RUNTIME +#include +@implementation NXConstantString +@end +#endif + +#include @interface Test : Object +(int) testResult; diff --git a/config/config.objc_condition_timed_wait.c b/config/config.objc_condition_timed_wait.c new file mode 100644 index 000000000..2929c6fae --- /dev/null +++ b/config/config.objc_condition_timed_wait.c @@ -0,0 +1,8 @@ + +#include +main() +{ + objc_condition_timedwait(NULL,NULL,NULL); + exit(0); +} + diff --git a/config/config.poll-dev.c b/config/config.poll-dev.c deleted file mode 100644 index 413a6a7ad..000000000 --- a/config/config.poll-dev.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Mac OS X has a native poll implementation since Mac OS X 10.4, but - * this implementation is broken in (at least) OS X 10.4 and 10.5 in - * that it does not support devices. - */ - -#include -#include -#include - -int -main() -{ - int fd, n; - struct pollfd pollfds[1]; - - fd = open("/dev/null", O_RDONLY | O_NONBLOCK, 0); - - pollfds[0].fd = fd; - pollfds[0].events = POLLIN; - n = poll(pollfds, 1, 0); - close(fd); - - return (n == 1 && !(pollfds[0].revents & POLLNVAL)) ? 0 : 1; -} diff --git a/config/config.reuseaddr.c b/config/config.reuseaddr.c index 0b9e93d3f..ef4e25c5b 100644 --- a/config/config.reuseaddr.c +++ b/config/config.reuseaddr.c @@ -5,7 +5,7 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. */ -#if defined(__MINGW32__) || defined(__MINGW64__) +#if defined(__MINGW32__) #include #include #else @@ -16,7 +16,7 @@ #include #include #include -#endif /* __MINGW__ */ +#endif /* __MINGW32__ */ #include #include diff --git a/config/config.setUncaughtExceptionHandler.m b/config/config.setUncaughtExceptionHandler.m new file mode 100644 index 000000000..25f0d0195 --- /dev/null +++ b/config/config.setUncaughtExceptionHandler.m @@ -0,0 +1,9 @@ + +#include "objc-common.g" +#include + +int main (void) +{ + objc_setUncaughtExceptionHandler (0); + return 0; +} diff --git a/config/config.set_unexpected.m b/config/config.set_unexpected.m deleted file mode 100644 index 2eea229bf..000000000 --- a/config/config.set_unexpected.m +++ /dev/null @@ -1,8 +0,0 @@ - -#include "objc-common.g" - -int main (void) -{ - objc_set_unexpected(0); - return 0; -} diff --git a/config/config.unexpected.m b/config/config.unexpected.m deleted file mode 100644 index 521ebc03a..000000000 --- a/config/config.unexpected.m +++ /dev/null @@ -1,8 +0,0 @@ - -#include "objc-common.g" - -int main (void) -{ - _objc_unexpected_exception = 0; - return 0; -} diff --git a/config/config.wprintf.c b/config/config.wprintf.c deleted file mode 100644 index 8f7d82fe8..000000000 --- a/config/config.wprintf.c +++ /dev/null @@ -1,79 +0,0 @@ -/* See if we have a broken register_printf function (e.g. an old version of glibc) */ -/* - Copyright (C) 2005 Free Software Foundation - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. -*/ -#include -#include -#include - -/* , with libc-5.3.9 thinks this - flag PRINTF_ATSIGN_VA_LIST should be 0, but for me, with libc-5.0.9, - it crashes. -mccallum - - Apparently GNU libc 2.xx needs this to be 0 also, along with Linux - libc versions 5.2.xx and higher (including libc6, which is just GNU - libc). -chung */ -#define PRINTF_ATSIGN_VA_LIST \ - (defined(_LINUX_C_LIB_VERSION_MINOR) \ - && _LINUX_C_LIB_VERSION_MAJOR <= 5 \ - && _LINUX_C_LIB_VERSION_MINOR < 2) - -#if ! PRINTF_ATSIGN_VA_LIST -static int -arginfo_func (const struct printf_info *info, size_t n, int *argtypes) -{ - *argtypes = PA_POINTER; - return 1; -} -#endif /* !PRINTF_ATSIGN_VA_LIST */ - -static int -handle_printf_atsign (FILE *stream, - const struct printf_info *info, -#if PRINTF_ATSIGN_VA_LIST - va_list *ap_pointer) -#elif defined(_LINUX_C_LIB_VERSION_MAJOR) \ - && _LINUX_C_LIB_VERSION_MAJOR < 6 - const void **const args) -#else /* GNU libc needs the following. */ - const void *const *args) -#endif -{ -#if ! PRINTF_ATSIGN_VA_LIST - const void *ptr = *args; -#endif - char * string_object; - int len = 0; - - /* xxx This implementation may not pay pay attention to as much - of printf_info as it should. */ - -#if PRINTF_ATSIGN_VA_LIST - string_object = va_arg (*ap_pointer, char *); -#else - string_object = *((char **) ptr); -#endif - if (info->wide == 0) - len = fprintf(stream, "%s", string_object); - return len; -} - -int main() -{ - char *d = "hi there"; - - register_printf_function ('@', - handle_printf_atsign, -#if PRINTF_ATSIGN_VA_LIST - 0); -#else - arginfo_func); -#endif - - printf("test %s = %@\n", d, d); - return 0; -} diff --git a/config/icu.m4 b/config/icu.m4 deleted file mode 100644 index 85d382d7a..000000000 --- a/config/icu.m4 +++ /dev/null @@ -1,37 +0,0 @@ -AC_DEFUN([AC_CHECK_ICU], [ - ok=no - - if test -z "$ICU_CONFIG"; then - AC_PATH_PROG(ICU_CONFIG, icu-config, no) - fi - - if test "$ICU_CONFIG" = "no" ; then - echo "Could not find the icu-config script." - echo "Please ensure that it is in your path." - echo "See http://site.icu-project.org/ for help." - else - ICU_VERSION=`$ICU_CONFIG --version` - AC_MSG_CHECKING(for ICU >= $1) - found=`expr $ICU_VERSION \>= $1` - if test "$found" = "1" ; then - AC_MSG_RESULT(yes) - ok=yes - - AC_MSG_CHECKING(ICU_LIBS) - ICU_LIBS=`$ICU_CONFIG --ldflags-libsonly` - AC_MSG_RESULT($ICU_LIBS) - else - ICU_LIBS="" - ## Either perform custom action or print error message - ifelse([$3], ,echo "can't find ICU >= $1 (got $ICU_VERSION)",) - fi - - AC_SUBST(ICU_LIBS) - fi - - if test $ok = yes; then - ifelse([$2], , :, [$2]) - else - ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3]) - fi -]) diff --git a/config/objc-common.g b/config/objc-common.g deleted file mode 100644 index 74dc0ce80..000000000 --- a/config/objc-common.g +++ /dev/null @@ -1,34 +0,0 @@ -/* Common information for all objc runtime tests. - */ -#include -#include - -#include - -#ifndef NeXT_RUNTIME -#include -@implementation NXConstantString -- (const char*) cString -{ - return 0; -} -- (unsigned int) length -{ - return 0; -} -@end -#endif - -/* Provide dummy implementations for NSObject and NSConstantString - * for runtime implementations which won't link without them. - */ - -@interface NSObject : Object -@end -@implementation NSObject -@end - -@interface NSConstantString : NSObject -@end -@implementation NSConstantString -@end diff --git a/config/objc-con-autoload.m4 b/config/objc-con-autoload.m4 index 8440dab09..6df2deaca 100644 --- a/config/objc-con-autoload.m4 +++ b/config/objc-con-autoload.m4 @@ -32,7 +32,6 @@ AC_TRY_RUN([static int loaded = 0; objc_cv_con_autoload=no) case "$target_os" in cygwin*) objc_cv_con_autoload=yes;; - mingw*) objc_cv_con_autoload=yes;; esac ]) if test $objc_cv_con_autoload = yes; then diff --git a/config/pathtls.m4 b/config/pathtls.m4 deleted file mode 100644 index 903052236..000000000 --- a/config/pathtls.m4 +++ /dev/null @@ -1,144 +0,0 @@ -dnl Code shamelessly stolen from glib-config by Sebastian Rittau -dnl Copyright (C) 2005 Free Software Foundation -dnl Copying and distribution of this file, with or without modification, -dnl are permitted in any medium without royalty provided the copyright -dnl notice and this notice are preserved. -dnl AM_PATH_TLS([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -AC_DEFUN(AM_PATH_TLS,[ -AC_ARG_WITH(tls-prefix, - [ --with-tls-prefix=PFX Prefix where libgnutls is installed (optional)], - tls_config_prefix="$withval", tls_config_prefix="") -AC_ARG_ENABLE(tlstest, - [ --disable-tlstest Do not try to compile and run a test TLS program],, - enable_tlstest=yes) - - if test x$tls_config_prefix != x ; then - tls_config_args="$tls_config_args --prefix=$tls_config_prefix" - if test x${TLS_CONFIG+set} != xset ; then - TLS_CONFIG=$tls_config_prefix/bin/libgnutls-config - fi - fi - - AC_PATH_PROG(TLS_CONFIG, libgnutls-config, no) - min_tls_version=ifelse([$1], ,2.0.0, [$1]) - AC_MSG_CHECKING(for libgnutls - version >= $min_tls_version) - no_tls="" - if test "$TLS_CONFIG" = "no" ; then - TLS_CFLAGS="-I/usr/include" - TLS_LIBS="-L/usr/lib -lgnutls -lgcrypt" - - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $TLS_CFLAGS" - LIBS="$TLS_LIBS $LIBS" -dnl -dnl Now check if the installed libgnutls is sufficiently new. -dnl - rm -f conf.tlstest - AC_TRY_RUN([ -#include -#include -#include - -int -main() -{ - system("touch conf.tlstest"); - - if (gnutls_check_version("$min_tls_version") == 0) - { - printf("\n*** An old version of libgnutls (%s) was found.\n", - gnutls_check_version(0)); - printf("*** You need a version of libtgnuls newer than $min_tls_version.\n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n"); - printf("*** being found. You can fix this is by removing the old version\n"); - printf("*** of libgnutls.\n"); - return 1; - } - return 0; -} -],, no_tls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - else - TLS_CFLAGS=`$TLS_CONFIG $tls_config_args --cflags` - TLS_LIBS=`$TLS_CONFIG $tls_config_args --libs` - tls_config_major_version=`$TLS_CONFIG $tls_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - tls_config_minor_version=`$TLS_CONFIG $tls_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - tls_config_micro_version=`$TLS_CONFIG $tls_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - # Strip '-L/usr/lib' off since this is always in the link path. - TLS_LIBS=`echo $TLS_LIBS | sed -e 's|-L/usr/lib||'` - - if test "x$enable_tlstest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $TLS_CFLAGS" - LIBS="$TLS_LIBS $LIBS" -dnl -dnl Now check if the installed libtgnuls is sufficiently new. -dnl - rm -f conf.tlstest - AC_TRY_RUN([ -#include -#include -#include - -int -main() -{ - system("touch conf.tlstest"); - - if (gnutls_check_version("$min_tls_version") == 0) - { - printf("\n*** An old version of libgnutls (%s) was found.\n", - gnutls_check_version(0)); - printf("*** You need a version of libtgnuls newer than $min_tls_version.\n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n"); - printf("*** being found. You can fix this is by removing the old version\n"); - printf("*** of libgnutls.\n"); - return 1; - } - return 0; -} -],, no_tls=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - - if test "x$no_tls" = x ; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) - else - AC_MSG_RESULT(no) - if test "$TLS_CONFIG" = "no" ; then - echo "*** The libgnutls-config script installed by libgnutls could not be found" - echo "*** If libtgnuls was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path." - else - if test -f conf.tlstest ; then - : - else - echo "*** Could not run libtgnuls test program, checking why..." - CFLAGS="$CFLAGS $TLS_CFLAGS" - LIBS="$LIBS $TLS_LIBS" - dnl FIXME: AC_TRY_LINK - fi - fi - - TLS_CFLAGS="" - TLS_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(TLS_CFLAGS) - AC_SUBST(TLS_LIBS) - rm -f conf.tlstest -]) - diff --git a/config/procfs.m4 b/config/procfs.m4 index 47b56e1dc..1bbb04977 100644 --- a/config/procfs.m4 +++ b/config/procfs.m4 @@ -18,7 +18,7 @@ AC_DEFUN(AC_SYS_PROCFS, # if test -d /proc/0; then # but it doesn't work on my linux - /proc/0 does not exist, but /proc # works fine - if grep 'proc' /proc/mounts >/dev/null 2>/dev/null; then + if (mount | grep 'proc' >/dev/null 2>/dev/null); then ac_cv_sys_procfs=yes else ac_cv_sys_procfs=no @@ -31,14 +31,11 @@ AC_DEFUN(AC_SYS_PROCFS, cygwin*) ac_cv_sys_procfs=yes;; esac elif test "$enable_procfs" = cross; then - ac_cv_sys_procfs=no + AC_MSG_WARN(Pass --enable-procfs argument to enable use of /proc filesystem.) else ac_cv_sys_procfs=no fi]) - if test "$enable_procfs" = cross; then - AC_MSG_WARN(Cross-compiling: Pass --enable-procfs argument to enable use of /proc filesystem.) - fi if test $ac_cv_sys_procfs = yes; then AC_DEFINE(HAVE_PROCFS, 1, [Define if system supports the /proc filesystem]) fi @@ -59,14 +56,11 @@ AC_DEFUN(AC_SYS_PROCFS_PSINFO, ac_cv_sys_procfs_psinfo=yes, ac_cv_sys_procfs_psinfo=no, ac_cv_sys_procfs_psinfo=yes) elif test "$enable_procfs" = cross; then - ac_cv_sys_procfs_psinfo=no + AC_MSG_WARN(Pass --enable-procfs-psinfo argument to enable use of /proc psinfo information.) else ac_cv_sys_procfs_psinfo=no fi]) - if test "$enable_procfs" = cross; then - AC_MSG_WARN(Cross-compiling: Pass --enable-procfs-psinfo argument to enable use of /proc psinfo information.) - fi if test $ac_cv_sys_procfs_psinfo = yes; then AC_DEFINE(HAVE_PROCFS_PSINFO, 1, [Define if system supports reading psinfo from /proc]) fi diff --git a/configure b/configure index c6e9e8451..205a93220 100755 --- a/configure +++ b/configure @@ -1,9 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62. +# Generated by GNU Autoconf 2.61. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -15,7 +15,7 @@ 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 + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -37,45 +37,17 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -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 -if (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=';' - } + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi # Support unset when possible. @@ -91,6 +63,8 @@ fi # 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.) +as_nl=' +' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. @@ -113,7 +87,7 @@ 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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi @@ -126,10 +100,17 @@ PS2='> ' PS4='+ ' # NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && @@ -151,7 +132,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | +echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -177,7 +158,7 @@ else as_have_required=no fi - if test $as_have_required = yes && (eval ": + if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } @@ -259,7 +240,7 @@ IFS=$as_save_IFS 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 + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -280,7 +261,7 @@ _ASEOF 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 + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -360,10 +341,10 @@ fi if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi @@ -432,10 +413,9 @@ fi test \$exitcode = 0") || { echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message } @@ -471,7 +451,7 @@ test \$exitcode = 0") || { 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 + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems @@ -499,6 +479,7 @@ case `echo -n x` in *) ECHO_N='-n';; esac + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -511,22 +492,19 @@ if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null + mkdir conf$$.dir 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 -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln else as_ln_s='cp -p' fi @@ -551,10 +529,10 @@ else as_test_x=' eval sh -c '\'' if test -d "$1"; then - test -d "$1/."; + test -d "$1/."; else case $1 in - -*)set "./$1";; + -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi @@ -635,7 +613,6 @@ ac_includes_default="\ # include #endif" -enable_option_checking=no ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME @@ -673,8 +650,6 @@ LIBS build_alias host_alias target_alias -BASE_NATIVE_OBJC_EXCEPTIONS -BASE_NONFRAGILE_ABI build build_cpu build_vendor @@ -687,8 +662,6 @@ target target_cpu target_vendor target_os -GNUSTEP_BASE_DOMAIN -GNUSTEP_BASE_RELATIVE_PATHS CC CFLAGS LDFLAGS @@ -697,10 +670,9 @@ ac_ct_CC EXEEXT OBJEXT CPP +WHOAMI GREP EGREP -WHOAMI -OBJC_WITH_GC GS_WORDS_BIGENDIAN GS_SINT8 GS_UINT8 @@ -732,16 +704,7 @@ _GSC_S_LNG_LNG DYNAMIC_LINKER NX_CONST_STRING_OBJCFLAGS NX_CONST_STRING_CLASS -OBJCSYNC -OBJC2RUNTIME -OBJCFLAGS -GS_NONFRAGILE -GS_MIXEDABI -HAVE_OBJC_SYNC_ENTER -GS_SIZEOF_MUTEX_T -GS_SIZEOF_COND_T -GS_ALIGNOF_MUTEX_T -GS_ALIGNOF_COND_T +HAVE_PTHREAD_H HAVE_PTS_STREAM_MODULES INCLUDE_STDINT DEFINE_INT8_T @@ -756,7 +719,6 @@ DEFINE_INTPTR_T DEFINE_UINTPTR_T USE_ZLIB HAVE_INET_PTON -HAVE_INET_NTOP GS_PASS_ARGUMENTS GS_FAKE_MAIN WITH_FFI @@ -766,20 +728,10 @@ XML_CFLAGS XML_LIBS HAVE_LIBXSLT HAVE_LIBXML -TLS_CONFIG -TLS_CFLAGS -TLS_LIBS -HAVE_GNUTLS HAVE_MDNS -HAVE_AVAHI -ICU_CONFIG -ICU_LIBS -HAVE_ICU USE_GMP INCLUDE_FLAGS LDIR_FLAGS -WARN_FLAGS -GNUSTEP_INSTALL_GDOMAP_AS_SETUID subdirs VERSION MAJOR_VERSION @@ -789,45 +741,6 @@ GCC_VERSION LIBOBJS LTLIBOBJS' ac_subst_files='' -ac_user_opts=' -enable_option_checking -with_config_file -enable_environment_config_file -enable_importing_config_file -with_default_config -with_installation_domain -enable_nxconstantstring -enable_mixedabi -enable_bfd -enable_procfs -enable_procfs_psinfo -enable_pass_arguments -enable_fake_main -with_include_flags -with_library_flags -enable_libffi -enable_ffcall -enable_invocations -with_ffi_include -with_ffi_library -with_libiconv_library -enable_xml -with_xml_prefix -enable_xmltest -enable_xslt -enable_tls -with_tls_prefix -enable_tlstest -enable_zeroconf -with_zeroconf_api -enable_icu -with_gmp_include -with_gmp_library -enable_setuid_gdomap -enable_openssl -with_openssl_include -with_openssl_library -' ac_precious_vars='build_alias host_alias target_alias @@ -837,13 +750,11 @@ LDFLAGS LIBS CPPFLAGS CPP' -ac_subdirs_all='SSL' +ac_subdirs_all='Source/mframe SSL' # 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 @@ -942,21 +853,13 @@ do datarootdir=$ac_optarg ;; -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + ac_feature=`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_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - 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 ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; @@ -969,21 +872,13 @@ do dvidir=$ac_optarg ;; -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + ac_feature=`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_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - 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 ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -1174,38 +1069,22 @@ do ac_init_version=: ;; -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + ac_package=`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_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - 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 ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + ac_package=`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_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - 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 ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. @@ -1225,7 +1104,7 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option + -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -1234,16 +1113,16 @@ Try \`$0 --help' for more information." >&2 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } 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 + 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 + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; @@ -1252,38 +1131,22 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 + { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) { $as_echo "$as_me: error: Unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; - *) $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. +# Be sure to have absolute directory names. 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 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_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done @@ -1298,7 +1161,7 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes @@ -1314,10 +1177,10 @@ 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_echo "$as_me: error: Working directory cannot be determined" >&2 + { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 + { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } @@ -1325,12 +1188,12 @@ test "X$ac_ls_di" = "X$ac_pwd_ls_di" || 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" | + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1357,12 +1220,12 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. @@ -1411,9 +1274,9 @@ Configuration: Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -1423,25 +1286,25 @@ 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] - --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/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] + --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] + --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/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -1458,7 +1321,6 @@ if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-environment-config-file @@ -1481,42 +1343,16 @@ Optional Features: --disable-importing-config-file Disable importing of an existing GNUstep config file and use inbuilt defaults instead. - --enable-nxconstantstring - Enables the use of the NXConstantString class for old compilers. - --disable-mixedabi - Disables the combined use of fragile and nonfragile ABI so that base - can be built taking full advantage of the nonfragile ABI. - --enable-bfd - Enables the use of libbfd to provide symbolic stack traces. - Enabling this option provides support for symbolic stack traces - on platforms where the backtrace_symbols() function is not - available or does not work properly. - Enabling this option also has the effect of changing the license - of gnustep-base from LGPL to GPL since libbfd uses the GPL license --enable-procfs Use /proc filesystem (default) --enable-procfs-psinfo Use /proc/%pid% to get info --enable-pass-arguments Force user main call to NSProcessInfo initialize --enable-fake-main Force redefine of user main function - --disable-libffi Disable use of libffi library - --enable-ffcall Enable use of the deprecated ffcall library - --disable-invocations Compile even if invocation-dependencies are not met + --enable-libffi Enable use of libffi library + --enable-ffcall Enable use of ffcall library + --disable-do Compile even if DO-dependencies are not met --disable-xml Compile even if XML-dependencies are not met --disable-xmltest Do not try to compile and run a test XML program --disable-xslt Compile even if XSLT-dependency is not met - --disable-tls Disable use of GNUTLS - --disable-tlstest Do not try to compile and run a test TLS program - --disable-zeroconf Disable NSNetServices support - --disable-icu Disable International Components for Unicode - - --enable-setuid-gdomap Enable installing gdomap as a setuid - executable. By default, it is installed - as a normal program intended to be started - by root at system boot time, but it can - also be started up automatically - by any user at any time. Use this - option if you are happy having the program - started automatically on demand. - --disable-openssl Disable support for openssl in URL classes Optional Packages: @@ -1551,27 +1387,12 @@ Optional Packages: is found at runtime. If this is not specified then the path from --with-config-file or from the gnustep-make package is used. - --with-installation-domain=DOMAIN - Specify the domain (SYSTEM, LOCAL, - NETWORK or USER) into which - gnustep-base will be installed. - Whenever relative paths are hardcoded - into gnustep-base (at the moment, this - happens only on MinGW) this option - must be used and must match the domain - where you will be installing - gnustep-base. - If this is not specified, the output of - gnustep-config --installation-domain-for=gnustep-base - (which should normally be LOCAL) is used. --with-include-flags=FLAGS Specify all include flags at once --with-library-flags=FLAGS Specify all library flags at once - --with-ffi-include=PATH Include path for ffi headers - --with-ffi-library=PATH Library path for ffi libs + --with-ffi-include=PATH Include path for ffi (ffcall/libffi) headers + --with-ffi-library=PATH Library path for ffi (ffcall/libffi) libs --with-libiconv-library=PATH Library path for libiconv libraries --with-xml-prefix=PFX Prefix where libxml is installed (optional) - --with-tls-prefix=PFX Prefix where libgnutls is installed (optional) - --with-zeroconf-api=API force use of a specific zeroconf API (mdns or avahi) --with-gmp-include=PATH include path for gmp headers --with-gmp-library=PATH library path for gmp libraries --with-openssl-include=PATH include path for openssl headers @@ -1597,17 +1418,15 @@ 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 + 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|^\.[\\/]||'` + ac_dir_suffix=/`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|/||'` + ac_top_builddir_sub=`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/ ;; @@ -1643,7 +1462,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix echo && $SHELL "$ac_srcdir/configure" --help=recursive else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done @@ -1653,10 +1472,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.62 +generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1667,7 +1486,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.62. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -1703,7 +1522,7 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" + echo "PATH: $as_dir" done IFS=$as_save_IFS @@ -1738,7 +1557,7 @@ do | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; @@ -1790,12 +1609,11 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +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= ;; #( *) $as_unset $ac_var ;; esac ;; esac @@ -1825,9 +1643,9 @@ _ASBOX do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - $as_echo "$ac_var='\''$ac_val'\''" + echo "$ac_var='\''$ac_val'\''" done | sort echo @@ -1842,9 +1660,9 @@ _ASBOX do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - $as_echo "$ac_var='\''$ac_val'\''" + echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1860,8 +1678,8 @@ _ASBOX echo fi test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && @@ -1903,24 +1721,21 @@ _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 +# Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site + set x "$prefix/share/config.site" "$prefix/etc/config.site" else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" +shift +for ac_site_file do - test "x$ac_site_file" = xNONE && continue if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi @@ -1930,16 +1745,16 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1953,38 +1768,29 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$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;} + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +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:$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;} + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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:$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:$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:$LINENO: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: 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=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1994,10 +1800,10 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$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_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi @@ -2026,43 +1832,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu - # If GNUSTEP_MAKEFILES is undefined, try to use gnustep-config to determine it. if test -z "$GNUSTEP_MAKEFILES"; then GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>&5` fi if test -z "$GNUSTEP_MAKEFILES"; then - { { $as_echo "$as_me:$LINENO: error: You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!" >&5 -$as_echo "$as_me: error: You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!" >&2;} + { { echo "$as_me:$LINENO: error: You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!" >&5 +echo "$as_me: error: You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!" >&2;} { (exit 1); exit 1; }; } fi -# If LIBRARY_COMBO is undefined, try to use gnustep-config to determine it. -if test -z "$LIBRARY_COMBO"; then - LIBRARY_COMBO=`gnustep-config --variable=LIBRARY_COMBO 2>&5` -fi - -exceptions=`gnustep-config --objc-flags | grep _NATIVE_OBJC_EXCEPTIONS 2>&5` -if test -z "$exceptions"; then - exceptions=no - BASE_NATIVE_OBJC_EXCEPTIONS=0 -else - exceptions=yes - BASE_NATIVE_OBJC_EXCEPTIONS=1 -fi - - -nonfragile=`gnustep-config --objc-flags | grep _NONFRAGILE_ABI 2>&5` -if test -z "$nonfragile"; then - nonfragile=no - BASE_NONFRAGILE_ABI=0 -else - nonfragile=yes - BASE_NONFRAGILE_ABI=1 -fi - - # We shouldn't be loading GNUstep.sh here. It would load in a lot of # variables which might get confused with the ones that will be used # at runtime. We will load it later once we have determined (and @@ -2095,8 +1875,8 @@ for ac_dir in $CURRENT_GNUSTEP_MAKEFILES "$srcdir"/$CURRENT_GNUSTEP_MAKEFILES; d fi done if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $CURRENT_GNUSTEP_MAKEFILES \"$srcdir\"/$CURRENT_GNUSTEP_MAKEFILES" >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in $CURRENT_GNUSTEP_MAKEFILES \"$srcdir\"/$CURRENT_GNUSTEP_MAKEFILES" >&2;} + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $CURRENT_GNUSTEP_MAKEFILES \"$srcdir\"/$CURRENT_GNUSTEP_MAKEFILES" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $CURRENT_GNUSTEP_MAKEFILES \"$srcdir\"/$CURRENT_GNUSTEP_MAKEFILES" >&2;} { (exit 1); exit 1; }; } fi @@ -2121,34 +1901,34 @@ ac_config_headers="$ac_config_headers Headers/Additions/GNUstepBase/config.h" #-------------------------------------------------------------------- # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 -$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } -{ $as_echo "$as_me:$LINENO: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 -$as_echo "$as_me: error: invalid value of canonical build" >&2;} +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build @@ -2165,27 +1945,27 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 -$as_echo "$as_me: error: invalid value of canonical host" >&2;} +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host @@ -2202,27 +1982,27 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking target system type" >&5 -$as_echo_n "checking target system type... " >&6; } +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } if test "${ac_cv_target+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_target" >&5 -$as_echo "$ac_cv_target" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 -$as_echo "$as_me: error: invalid value of canonical target" >&2;} +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} { (exit 1); exit 1; }; };; esac target=$ac_cv_target @@ -2249,8 +2029,8 @@ test -n "$target_alias" && #--------------------------------------------------------------------- # Location of the GNUstep.conf config file (--with-config-file) #--------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for GNUstep configuration file to use at runtime" >&5 -$as_echo_n "checking for GNUstep configuration file to use at runtime... " >&6; } +{ echo "$as_me:$LINENO: checking for GNUstep configuration file to use at runtime" >&5 +echo $ECHO_N "checking for GNUstep configuration file to use at runtime... $ECHO_C" >&6; } GNUSTEP_CONFIG_FILE="" # This requires gnustep-make > 1.13.0 to work. For gnustep-make = @@ -2289,8 +2069,8 @@ if test "$GNUSTEP_CONFIG_FILE" = ""; then GNUSTEP_CONFIG_FILE="$GNUSTEP_MAKE_CONFIG" ;; esac fi -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_CONFIG_FILE" >&5 -$as_echo "$GNUSTEP_CONFIG_FILE" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_CONFIG_FILE" >&5 +echo "${ECHO_T}$GNUSTEP_CONFIG_FILE" >&6; } #----------------------------------------------------------------- # Whether the GNUstep.conf file path can be set in the environment @@ -2304,8 +2084,8 @@ case "$target_os" in mingw*) enable_env_config=no;; *) enable_env_config=yes;; esac -{ $as_echo "$as_me:$LINENO: checking whether the GNUstep.conf file path can be set in the environment" >&5 -$as_echo_n "checking whether the GNUstep.conf file path can be set in the environment... " >&6; } +{ echo "$as_me:$LINENO: checking whether the GNUstep.conf file path can be set in the environment" >&5 +echo $ECHO_N "checking whether the GNUstep.conf file path can be set in the environment... $ECHO_C" >&6; } # Check whether --enable-environment-config-file was given. if test "${enable_environment_config_file+set}" = set; then enableval=$enable_environment_config_file; ac_cv_environment_config_file=$enableval @@ -2319,16 +2099,16 @@ cat >>confdefs.h <<\_ACEOF #define OPTION_NO_ENVIRONMENT 0 _ACEOF - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else cat >>confdefs.h <<\_ACEOF #define OPTION_NO_ENVIRONMENT 1 _ACEOF - { $as_echo "$as_me:$LINENO: result: no: disabled from the command-line" >&5 -$as_echo "no: disabled from the command-line" >&6; } + { echo "$as_me:$LINENO: result: no: disabled from the command-line" >&5 +echo "${ECHO_T}no: disabled from the command-line" >&6; } fi #-------------------------------------------------------------------- @@ -2347,6 +2127,7 @@ case "$target_os" in GNUSTEP_SYSTEM_ROOT=/usr/GNUstep/System GNUSTEP_LOCAL_ROOT=/usr/GNUstep/Local GNUSTEP_NETWORK_ROOT=/usr/GNUstep/Local + GNUSTEP_USER_DIR=GNUstep GNUSTEP_USER_DEFAULTS_DIR=GNUstep/Defaults GNUSTEP_USER_CONFIG_FILE=.GNUstep.conf ;; @@ -2361,8 +2142,8 @@ esac # installation (or of the config file you specify). # It can be annoying in certain cases though; this option lets you # turn it off. -{ $as_echo "$as_me:$LINENO: checking if we should import an existing configuration file now" >&5 -$as_echo_n "checking if we should import an existing configuration file now... " >&6; } +{ echo "$as_me:$LINENO: checking if we should import an existing configuration file now" >&5 +echo $ECHO_N "checking if we should import an existing configuration file now... $ECHO_C" >&6; } # Check whether --enable-importing-config-file was given. if test "${enable_importing_config_file+set}" = set; then enableval=$enable_importing_config_file; ac_cv_importing_config_file=$enableval @@ -2371,18 +2152,18 @@ else fi if test "$ac_cv_importing_config_file" = "no"; then - { $as_echo "$as_me:$LINENO: result: no: disabled from the command-line" >&5 -$as_echo "no: disabled from the command-line" >&6; } + { echo "$as_me:$LINENO: result: no: disabled from the command-line" >&5 +echo "${ECHO_T}no: disabled from the command-line" >&6; } else - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } fi if test "$ac_cv_importing_config_file" = "yes" ; then - { $as_echo "$as_me:$LINENO: checking for default GNUstep configuration file to use" >&5 -$as_echo_n "checking for default GNUstep configuration file to use... " >&6; } + { echo "$as_me:$LINENO: checking for default GNUstep configuration file to use" >&5 +echo $ECHO_N "checking for default GNUstep configuration file to use... $ECHO_C" >&6; } # Check whether --with-default-config was given. if test "${with_default_config+set}" = set; then @@ -2409,8 +2190,8 @@ fi # installed. GNUSTEP_DEFAULT_CONFIG="$GNUSTEP_MAKE_CONFIG" fi - { $as_echo "$as_me:$LINENO: result: $GNUSTEP_DEFAULT_CONFIG" >&5 -$as_echo "$GNUSTEP_DEFAULT_CONFIG" >&6; } + { echo "$as_me:$LINENO: result: $GNUSTEP_DEFAULT_CONFIG" >&5 +echo "${ECHO_T}$GNUSTEP_DEFAULT_CONFIG" >&6; } # # Only try importing if the default config file has been specified. @@ -2420,8 +2201,8 @@ $as_echo "$GNUSTEP_DEFAULT_CONFIG" >&6; } # Use the default config file to override standard values. # if test ! -f "$GNUSTEP_DEFAULT_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: fail: file \"$GNUSTEP_DEFAULT_CONFIG\" does not exist" >&5 -$as_echo "fail: file \"$GNUSTEP_DEFAULT_CONFIG\" does not exist" >&6; } + { echo "$as_me:$LINENO: result: fail: file \"$GNUSTEP_DEFAULT_CONFIG\" does not exist" >&5 +echo "${ECHO_T}fail: file \"$GNUSTEP_DEFAULT_CONFIG\" does not exist" >&6; } # Ohoh ... things are not going well. We are asked to import # a config file that doesn't exist. So all paths might be unset @@ -2432,15 +2213,15 @@ $as_echo "fail: file \"$GNUSTEP_DEFAULT_CONFIG\" does not exist" >&6; } # system might be already screwed. If they don't want to import # a config file (eg, they don't have one and they don't care about # the hardcoded paths) they should just say so. ;-) - { { $as_echo "$as_me:$LINENO: error: Please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&5 -$as_echo "$as_me: error: Please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&2;} + { { echo "$as_me:$LINENO: error: Please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&5 +echo "$as_me: error: Please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&2;} { (exit 1); exit 1; }; } else - { $as_echo "$as_me:$LINENO: result: trying to import \"$GNUSTEP_DEFAULT_CONFIG\"" >&5 -$as_echo "trying to import \"$GNUSTEP_DEFAULT_CONFIG\"" >&6; } - { $as_echo "$as_me:$LINENO: If this fails, please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&5 -$as_echo "$as_me: If this fails, please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&6;} + { echo "$as_me:$LINENO: result: trying to import \"$GNUSTEP_DEFAULT_CONFIG\"" >&5 +echo "${ECHO_T}trying to import \"$GNUSTEP_DEFAULT_CONFIG\"" >&6; } + { echo "$as_me:$LINENO: If this fails, please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&5 +echo "$as_me: If this fails, please run configure again with the --disable-importing-config-file option or specifying an alternative file using the --with-default-config= option" >&6;} . "$GNUSTEP_DEFAULT_CONFIG" fi fi @@ -2509,75 +2290,18 @@ if test x"$GNUSTEP_USER_DIR_DOC" = x""; then GNUSTEP_USER_DIR_DOC=$GNUSTEP_USER_ if test x"$GNUSTEP_USER_DIR_DOC_MAN" = x""; then GNUSTEP_USER_DIR_DOC_MAN=$GNUSTEP_USER_DIR/Documentation/man; fi if test x"$GNUSTEP_USER_DIR_DOC_INFO" = x""; then GNUSTEP_USER_DIR_DOC_INFO=$GNUSTEP_USER_DIR/Documentation/info; fi -{ $as_echo "$as_me:$LINENO: checking for GNUstep-base installation domain" >&5 -$as_echo_n "checking for GNUstep-base installation domain... " >&6; } - -# Check whether --with-installation-domain was given. -if test "${with_installation_domain+set}" = set; then - withval=$with_installation_domain; result="$withval" -else - result="no" - -fi - -if test "$result" = "no" -then - # Check if gnustep-config supports the option - # --installation-domain-for, and use it if available. That option - # will automatically use the shell variable GNUSTEP_INSTALLATION_DOMAIN or - # the installation-domains.conf files (or the LOCAL default) as appropriate. - # Otherwise, if that option is not available just fall back to - # using GNUSTEP_INSTALLATION_DOMAIN or (if that was not defiend) LOCAL. - if (gnustep-config --help | grep installation-domain) >&5 2>&5 - then - result=`gnustep-config --installation-domain-for=gnustep-base 2>&5` - else - { $as_echo "$as_me:$LINENO: WARNING: The 'gnustep-config' script was not found or out of date." >&5 -$as_echo "$as_me: WARNING: The 'gnustep-config' script was not found or out of date." >&2;} - result=$GNUSTEP_INSTALLATION_DOMAIN - if test "$result" = "" - then - # This case was added on December 2008 and is only for backwards - # compatibility with older versions of gnustep-make. - result=LOCAL - fi - fi -fi -case "$result" in - SYSTEM) - { $as_echo "$as_me:$LINENO: result: SYSTEM" >&5 -$as_echo "SYSTEM" >&6; } - GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS";; - LOCAL) - { $as_echo "$as_me:$LINENO: result: LOCAL" >&5 -$as_echo "LOCAL" >&6; } - GNUSTEP_BASE_PATH="$GNUSTEP_LOCAL_TOOLS";; - NETWORK) - { $as_echo "$as_me:$LINENO: result: NETWORK" >&5 -$as_echo "NETWORK" >&6; } - GNUSTEP_BASE_PATH="$GNUSTEP_NETWORK_TOOLS";; - USER) - { $as_echo "$as_me:$LINENO: result: USER" >&5 -$as_echo "USER" >&6; } - GNUSTEP_BASE_PATH="$GNUSTEP_USER_TOOLS";; - *) - { { $as_echo "$as_me:$LINENO: error: Unknown installation domain '$result' (it should be SYSTEM, LOCAL, NETWORK or USER). Please run configure again with the option --with-installation-domain=LOCAL (or whatever domain you want to install into)." >&5 -$as_echo "$as_me: error: Unknown installation domain '$result' (it should be SYSTEM, LOCAL, NETWORK or USER). Please run configure again with the option --with-installation-domain=LOCAL (or whatever domain you want to install into)." >&2;} - { (exit 1); exit 1; }; } - exit 1;; -esac -# We store GNUSTEP_BASE_DOMAIN in config.mak so that we can check -# at runtime and make sure it is consistent with the -# GNUSTEP_INSTALLATION_DOMAIN that is used at runtime. -GNUSTEP_BASE_DOMAIN=$result - - # # If we are on mingw, we now want to convert the paths to relative # paths (relative to libgnustep-base.dll). # +# TODO: To do it properly, we ought to allow the user to configure +# the installation domain at configure time! This assumes we always +# install into System. +# case "$target_os" in mingw*) + GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS" + # TODO: Improve this hack. # According to Wikipedia, this is the default for Windows 2000, # Windows XP and Windows Server 2003. For Windows Vista this will @@ -2587,15 +2311,6 @@ case "$target_os" in GNUSTEP_NETWORK_USERS_DIR="C:\Documents and Settings" GNUSTEP_LOCAL_USERS_DIR="C:\Documents and Settings" - # TODO: It would be nice to use the 'short' output of - # relative_path.sh, but older versions of relative_path.sh - # did not support specifying the type of output and - # would abort if they were given more than 2 parameters, - # so we can not use the 'short' option if we want gnustep-base - # to work with older versions of gnustep-make. - # Once everyone has upgraded to gnustep-make >= 2.0.5 (I'd say - # two years after it has been released ?), we could switch to the - # 'short' output though. GNUSTEP_SYSTEM_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_APPS` GNUSTEP_SYSTEM_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_APPS` GNUSTEP_SYSTEM_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_WEB_APPS` @@ -2636,246 +2351,222 @@ case "$target_os" in ;; esac -GNUSTEP_BASE_RELATIVE_PATHS=no - -# Now, check if any of the paths is a relative path. -for path in \ - "$GNUSTEP_SYSTEM_APPS" "$GNUSTEP_SYSTEM_ADMIN_APPS" "$GNUSTEP_SYSTEM_WEB_APPS" \ - "$GNUSTEP_SYSTEM_TOOLS" "$GNUSTEP_SYSTEM_ADMIN_TOOLS" \ - "$GNUSTEP_SYSTEM_LIBRARY" "$GNUSTEP_SYSTEM_LIBRARIES" "$GNUSTEP_SYSTEM_HEADERS" \ - "$GNUSTEP_SYSTEM_DOC" "$GNUSTEP_SYSTEM_DOC_MAN" "$GNUSTEP_SYSTEM_DOC_INFO" \ - "$GNUSTEP_NETWORK_APPS" "$GNUSTEP_NETWORK_ADMIN_APPS" "$GNUSTEP_NETWORK_WEB_APPS" \ - "$GNUSTEP_NETWORK_TOOLS" "$GNUSTEP_NETWORK_ADMIN_TOOLS" \ - "$GNUSTEP_NETWORK_LIBRARY" "$GNUSTEP_NETWORK_LIBRARIES" "$GNUSTEP_NETWORK_HEADERS" \ - "$GNUSTEP_NETWORK_DOC" "$GNUSTEP_NETWORK_DOC_MAN" "$GNUSTEP_NETWORK_DOC_INFO" \ - "$GNUSTEP_LOCAL_APPS" "$GNUSTEP_LOCAL_ADMIN_APPS" "$GNUSTEP_LOCAL_WEB_APPS" \ - "$GNUSTEP_LOCAL_TOOLS" "$GNUSTEP_LOCAL_ADMIN_TOOLS" \ - "$GNUSTEP_LOCAL_LIBRARY" "$GNUSTEP_LOCAL_LIBRARIES" "$GNUSTEP_LOCAL_HEADERS" \ - "$GNUSTEP_LOCAL_DOC" "$GNUSTEP_LOCAL_DOC_MAN" "$GNUSTEP_LOCAL_DOC_INFO"; do -case "$path" in - ./*) GNUSTEP_BASE_RELATIVE_PATHS=yes ;; - ../*) GNUSTEP_BASE_RELATIVE_PATHS=yes ;; -esac -done - -{ $as_echo "$as_me:$LINENO: checking if we are hardcoding any relative paths in gnustep-base" >&5 -$as_echo_n "checking if we are hardcoding any relative paths in gnustep-base... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_BASE_RELATIVE_PATHS" >&5 -$as_echo "$GNUSTEP_BASE_RELATIVE_PATHS" >&6; } - - # # Now, we want to print out the paths that we're going to hardcode # into gnustep-base. This is to help users in finding # misconfigurations. # -{ $as_echo "$as_me:$LINENO: We store the following filesystem layout into gnustep-base, to be used when no config file is found" >&5 -$as_echo "$as_me: We store the following filesystem layout into gnustep-base, to be used when no config file is found" >&6;} -{ $as_echo "$as_me:$LINENO: checking for Makefiles directory" >&5 -$as_echo_n "checking for Makefiles directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_MAKEFILES" >&5 -$as_echo "$GNUSTEP_MAKEFILES" >&6; } -{ $as_echo "$as_me:$LINENO: checking for user defaults directory" >&5 -$as_echo_n "checking for user defaults directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DEFAULTS_DIR" >&5 -$as_echo "$GNUSTEP_USER_DEFAULTS_DIR" >&6; } -{ $as_echo "$as_me:$LINENO: checking for user config file" >&5 -$as_echo_n "checking for user config file... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_CONFIG_FILE" >&5 -$as_echo "$GNUSTEP_USER_CONFIG_FILE" >&6; } +{ echo "$as_me:$LINENO: We store the following filesystem layout into gnustep-base, to be used when no config file is found" >&5 +echo "$as_me: We store the following filesystem layout into gnustep-base, to be used when no config file is found" >&6;} +{ echo "$as_me:$LINENO: checking for Makefiles directory" >&5 +echo $ECHO_N "checking for Makefiles directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_MAKEFILES" >&5 +echo "${ECHO_T}$GNUSTEP_MAKEFILES" >&6; } +{ echo "$as_me:$LINENO: checking for user directory" >&5 +echo $ECHO_N "checking for user directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR" >&6; } +{ echo "$as_me:$LINENO: checking for user defaults directory" >&5 +echo $ECHO_N "checking for user defaults directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DEFAULTS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DEFAULTS_DIR" >&6; } +{ echo "$as_me:$LINENO: checking for user config file" >&5 +echo $ECHO_N "checking for user config file... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_CONFIG_FILE" >&5 +echo "${ECHO_T}$GNUSTEP_USER_CONFIG_FILE" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Applications directory" >&5 -$as_echo_n "checking for System Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_APPS" >&5 -$as_echo "$GNUSTEP_SYSTEM_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Admin Applications directory" >&5 -$as_echo_n "checking for System Admin Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_ADMIN_APPS" >&5 -$as_echo "$GNUSTEP_SYSTEM_ADMIN_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Web Applications directory" >&5 -$as_echo_n "checking for System Web Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_WEB_APPS" >&5 -$as_echo "$GNUSTEP_SYSTEM_WEB_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Tools directory" >&5 -$as_echo_n "checking for System Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_TOOLS" >&5 -$as_echo "$GNUSTEP_SYSTEM_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Admin Tools directory" >&5 -$as_echo_n "checking for System Admin Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_ADMIN_TOOLS" >&5 -$as_echo "$GNUSTEP_SYSTEM_ADMIN_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Library directory" >&5 -$as_echo_n "checking for System Library directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_LIBRARY" >&5 -$as_echo "$GNUSTEP_SYSTEM_LIBRARY" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Libraries directory" >&5 -$as_echo_n "checking for System Libraries directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_LIBRARIES" >&5 -$as_echo "$GNUSTEP_SYSTEM_LIBRARIES" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Headers directory" >&5 -$as_echo_n "checking for System Headers directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_HEADERS" >&5 -$as_echo "$GNUSTEP_SYSTEM_HEADERS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Documentation directory" >&5 -$as_echo_n "checking for System Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_DOC" >&5 -$as_echo "$GNUSTEP_SYSTEM_DOC" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Info Documentation directory" >&5 -$as_echo_n "checking for System Info Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_DOC_INFO" >&5 -$as_echo "$GNUSTEP_SYSTEM_DOC_INFO" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System Man Documentation directory" >&5 -$as_echo_n "checking for System Man Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_DOC_MAN" >&5 -$as_echo "$GNUSTEP_SYSTEM_DOC_MAN" >&6; } +{ echo "$as_me:$LINENO: checking for System Applications directory" >&5 +echo $ECHO_N "checking for System Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for System Admin Applications directory" >&5 +echo $ECHO_N "checking for System Admin Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_ADMIN_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_ADMIN_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for System Web Applications directory" >&5 +echo $ECHO_N "checking for System Web Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_WEB_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_WEB_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for System Tools directory" >&5 +echo $ECHO_N "checking for System Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for System Admin Tools directory" >&5 +echo $ECHO_N "checking for System Admin Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_ADMIN_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_ADMIN_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for System Library directory" >&5 +echo $ECHO_N "checking for System Library directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_LIBRARY" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_LIBRARY" >&6; } +{ echo "$as_me:$LINENO: checking for System Libraries directory" >&5 +echo $ECHO_N "checking for System Libraries directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_LIBRARIES" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_LIBRARIES" >&6; } +{ echo "$as_me:$LINENO: checking for System Headers directory" >&5 +echo $ECHO_N "checking for System Headers directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_HEADERS" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_HEADERS" >&6; } +{ echo "$as_me:$LINENO: checking for System Documentation directory" >&5 +echo $ECHO_N "checking for System Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_DOC" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_DOC" >&6; } +{ echo "$as_me:$LINENO: checking for System Info Documentation directory" >&5 +echo $ECHO_N "checking for System Info Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_DOC_INFO" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_DOC_INFO" >&6; } +{ echo "$as_me:$LINENO: checking for System Man Documentation directory" >&5 +echo $ECHO_N "checking for System Man Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_DOC_MAN" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_DOC_MAN" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Applications directory" >&5 -$as_echo_n "checking for Network Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_APPS" >&5 -$as_echo "$GNUSTEP_NETWORK_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Admin Applications directory" >&5 -$as_echo_n "checking for Network Admin Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_ADMIN_APPS" >&5 -$as_echo "$GNUSTEP_NETWORK_ADMIN_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Web Applications directory" >&5 -$as_echo_n "checking for Network Web Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_WEB_APPS" >&5 -$as_echo "$GNUSTEP_NETWORK_WEB_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Tools directory" >&5 -$as_echo_n "checking for Network Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_TOOLS" >&5 -$as_echo "$GNUSTEP_NETWORK_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Admin Tools directory" >&5 -$as_echo_n "checking for Network Admin Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_ADMIN_TOOLS" >&5 -$as_echo "$GNUSTEP_NETWORK_ADMIN_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Library directory" >&5 -$as_echo_n "checking for Network Library directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_LIBRARY" >&5 -$as_echo "$GNUSTEP_NETWORK_LIBRARY" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Libraries directory" >&5 -$as_echo_n "checking for Network Libraries directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_LIBRARIES" >&5 -$as_echo "$GNUSTEP_NETWORK_LIBRARIES" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Headers directory" >&5 -$as_echo_n "checking for Network Headers directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_HEADERS" >&5 -$as_echo "$GNUSTEP_NETWORK_HEADERS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Documentation directory" >&5 -$as_echo_n "checking for Network Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_DOC" >&5 -$as_echo "$GNUSTEP_NETWORK_DOC" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Info Documentation directory" >&5 -$as_echo_n "checking for Network Info Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_DOC_INFO" >&5 -$as_echo "$GNUSTEP_NETWORK_DOC_INFO" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network Man Documentation directory" >&5 -$as_echo_n "checking for Network Man Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_DOC_MAN" >&5 -$as_echo "$GNUSTEP_NETWORK_DOC_MAN" >&6; } +{ echo "$as_me:$LINENO: checking for Network Applications directory" >&5 +echo $ECHO_N "checking for Network Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for Network Admin Applications directory" >&5 +echo $ECHO_N "checking for Network Admin Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_ADMIN_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_ADMIN_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for Network Web Applications directory" >&5 +echo $ECHO_N "checking for Network Web Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_WEB_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_WEB_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for Network Tools directory" >&5 +echo $ECHO_N "checking for Network Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for Network Admin Tools directory" >&5 +echo $ECHO_N "checking for Network Admin Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_ADMIN_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_ADMIN_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for Network Library directory" >&5 +echo $ECHO_N "checking for Network Library directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_LIBRARY" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_LIBRARY" >&6; } +{ echo "$as_me:$LINENO: checking for Network Libraries directory" >&5 +echo $ECHO_N "checking for Network Libraries directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_LIBRARIES" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_LIBRARIES" >&6; } +{ echo "$as_me:$LINENO: checking for Network Headers directory" >&5 +echo $ECHO_N "checking for Network Headers directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_HEADERS" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_HEADERS" >&6; } +{ echo "$as_me:$LINENO: checking for Network Documentation directory" >&5 +echo $ECHO_N "checking for Network Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_DOC" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_DOC" >&6; } +{ echo "$as_me:$LINENO: checking for Network Info Documentation directory" >&5 +echo $ECHO_N "checking for Network Info Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_DOC_INFO" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_DOC_INFO" >&6; } +{ echo "$as_me:$LINENO: checking for Network Man Documentation directory" >&5 +echo $ECHO_N "checking for Network Man Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_DOC_MAN" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_DOC_MAN" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Applications directory" >&5 -$as_echo_n "checking for Local Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_APPS" >&5 -$as_echo "$GNUSTEP_LOCAL_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Admin Applications directory" >&5 -$as_echo_n "checking for Local Admin Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_ADMIN_APPS" >&5 -$as_echo "$GNUSTEP_LOCAL_ADMIN_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Web Applications directory" >&5 -$as_echo_n "checking for Local Web Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_WEB_APPS" >&5 -$as_echo "$GNUSTEP_LOCAL_WEB_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Tools directory" >&5 -$as_echo_n "checking for Local Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_TOOLS" >&5 -$as_echo "$GNUSTEP_LOCAL_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Admin Tools directory" >&5 -$as_echo_n "checking for Local Admin Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_ADMIN_TOOLS" >&5 -$as_echo "$GNUSTEP_LOCAL_ADMIN_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Library directory" >&5 -$as_echo_n "checking for Local Library directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_LIBRARY" >&5 -$as_echo "$GNUSTEP_LOCAL_LIBRARY" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Libraries directory" >&5 -$as_echo_n "checking for Local Libraries directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_LIBRARIES" >&5 -$as_echo "$GNUSTEP_LOCAL_LIBRARIES" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Headers directory" >&5 -$as_echo_n "checking for Local Headers directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_HEADERS" >&5 -$as_echo "$GNUSTEP_LOCAL_HEADERS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Documentation directory" >&5 -$as_echo_n "checking for Local Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_DOC" >&5 -$as_echo "$GNUSTEP_LOCAL_DOC" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Info Documentation directory" >&5 -$as_echo_n "checking for Local Info Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_DOC_INFO" >&5 -$as_echo "$GNUSTEP_LOCAL_DOC_INFO" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local Man Documentation directory" >&5 -$as_echo_n "checking for Local Man Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_DOC_MAN" >&5 -$as_echo "$GNUSTEP_LOCAL_DOC_MAN" >&6; } +{ echo "$as_me:$LINENO: checking for Local Applications directory" >&5 +echo $ECHO_N "checking for Local Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for Local Admin Applications directory" >&5 +echo $ECHO_N "checking for Local Admin Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_ADMIN_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_ADMIN_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for Local Web Applications directory" >&5 +echo $ECHO_N "checking for Local Web Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_WEB_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_WEB_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for Local Tools directory" >&5 +echo $ECHO_N "checking for Local Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for Local Admin Tools directory" >&5 +echo $ECHO_N "checking for Local Admin Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_ADMIN_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_ADMIN_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for Local Library directory" >&5 +echo $ECHO_N "checking for Local Library directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_LIBRARY" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_LIBRARY" >&6; } +{ echo "$as_me:$LINENO: checking for Local Libraries directory" >&5 +echo $ECHO_N "checking for Local Libraries directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_LIBRARIES" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_LIBRARIES" >&6; } +{ echo "$as_me:$LINENO: checking for Local Headers directory" >&5 +echo $ECHO_N "checking for Local Headers directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_HEADERS" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_HEADERS" >&6; } +{ echo "$as_me:$LINENO: checking for Local Documentation directory" >&5 +echo $ECHO_N "checking for Local Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_DOC" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_DOC" >&6; } +{ echo "$as_me:$LINENO: checking for Local Info Documentation directory" >&5 +echo $ECHO_N "checking for Local Info Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_DOC_INFO" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_DOC_INFO" >&6; } +{ echo "$as_me:$LINENO: checking for Local Man Documentation directory" >&5 +echo $ECHO_N "checking for Local Man Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_DOC_MAN" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_DOC_MAN" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Applications directory" >&5 -$as_echo_n "checking for User Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_APPS" >&5 -$as_echo "$GNUSTEP_USER_DIR_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Admin Applications directory" >&5 -$as_echo_n "checking for User Admin Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_ADMIN_APPS" >&5 -$as_echo "$GNUSTEP_USER_DIR_ADMIN_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Web Applications directory" >&5 -$as_echo_n "checking for User Web Applications directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_WEB_APPS" >&5 -$as_echo "$GNUSTEP_USER_DIR_WEB_APPS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Tools directory" >&5 -$as_echo_n "checking for User Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_TOOLS" >&5 -$as_echo "$GNUSTEP_USER_DIR_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Admin Tools directory" >&5 -$as_echo_n "checking for User Admin Tools directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_ADMIN_TOOLS" >&5 -$as_echo "$GNUSTEP_USER_DIR_ADMIN_TOOLS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Library directory" >&5 -$as_echo_n "checking for User Library directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_LIBRARY" >&5 -$as_echo "$GNUSTEP_USER_DIR_LIBRARY" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Libraries directory" >&5 -$as_echo_n "checking for User Libraries directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_LIBRARIES" >&5 -$as_echo "$GNUSTEP_USER_DIR_LIBRARIES" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Headers directory" >&5 -$as_echo_n "checking for User Headers directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_HEADERS" >&5 -$as_echo "$GNUSTEP_USER_DIR_HEADERS" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Documentation directory" >&5 -$as_echo_n "checking for User Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC" >&5 -$as_echo "$GNUSTEP_USER_DIR_DOC" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Info Documentation directory" >&5 -$as_echo_n "checking for User Info Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC_INFO" >&5 -$as_echo "$GNUSTEP_USER_DIR_DOC_INFO" >&6; } -{ $as_echo "$as_me:$LINENO: checking for User Man Documentation directory" >&5 -$as_echo_n "checking for User Man Documentation directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC_MAN" >&5 -$as_echo "$GNUSTEP_USER_DIR_DOC_MAN" >&6; } +{ echo "$as_me:$LINENO: checking for User Applications directory" >&5 +echo $ECHO_N "checking for User Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for User Admin Applications directory" >&5 +echo $ECHO_N "checking for User Admin Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_ADMIN_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_ADMIN_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for User Web Applications directory" >&5 +echo $ECHO_N "checking for User Web Applications directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_WEB_APPS" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_WEB_APPS" >&6; } +{ echo "$as_me:$LINENO: checking for User Tools directory" >&5 +echo $ECHO_N "checking for User Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for User Admin Tools directory" >&5 +echo $ECHO_N "checking for User Admin Tools directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_ADMIN_TOOLS" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_ADMIN_TOOLS" >&6; } +{ echo "$as_me:$LINENO: checking for User Library directory" >&5 +echo $ECHO_N "checking for User Library directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_LIBRARY" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_LIBRARY" >&6; } +{ echo "$as_me:$LINENO: checking for User Libraries directory" >&5 +echo $ECHO_N "checking for User Libraries directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_LIBRARIES" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_LIBRARIES" >&6; } +{ echo "$as_me:$LINENO: checking for User Headers directory" >&5 +echo $ECHO_N "checking for User Headers directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_HEADERS" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_HEADERS" >&6; } +{ echo "$as_me:$LINENO: checking for User Documentation directory" >&5 +echo $ECHO_N "checking for User Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_DOC" >&6; } +{ echo "$as_me:$LINENO: checking for User Info Documentation directory" >&5 +echo $ECHO_N "checking for User Info Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC_INFO" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_DOC_INFO" >&6; } +{ echo "$as_me:$LINENO: checking for User Man Documentation directory" >&5 +echo $ECHO_N "checking for User Man Documentation directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_USER_DIR_DOC_MAN" >&5 +echo "${ECHO_T}$GNUSTEP_USER_DIR_DOC_MAN" >&6; } -{ $as_echo "$as_me:$LINENO: checking for System User directory" >&5 -$as_echo_n "checking for System User directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_USERS_DIR" >&5 -$as_echo "$GNUSTEP_SYSTEM_USERS_DIR" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Network User directory" >&5 -$as_echo_n "checking for Network User directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_USERS_DIR" >&5 -$as_echo "$GNUSTEP_NETWORK_USERS_DIR" >&6; } -{ $as_echo "$as_me:$LINENO: checking for Local User directory" >&5 -$as_echo_n "checking for Local User directory... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_USERS_DIR" >&5 -$as_echo "$GNUSTEP_LOCAL_USERS_DIR" >&6; } +{ echo "$as_me:$LINENO: checking for System User directory" >&5 +echo $ECHO_N "checking for System User directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_SYSTEM_USERS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_SYSTEM_USERS_DIR" >&6; } +{ echo "$as_me:$LINENO: checking for Network User directory" >&5 +echo $ECHO_N "checking for Network User directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_NETWORK_USERS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_NETWORK_USERS_DIR" >&6; } +{ echo "$as_me:$LINENO: checking for Local User directory" >&5 +echo $ECHO_N "checking for Local User directory... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $GNUSTEP_LOCAL_USERS_DIR" >&5 +echo "${ECHO_T}$GNUSTEP_LOCAL_USERS_DIR" >&6; } # # Set the default configuration file values in config.h to be hard-coded @@ -2887,6 +2578,12 @@ cat >>confdefs.h <<_ACEOF #define GNUSTEP_TARGET_MAKEFILES "$GNUSTEP_MAKEFILES" _ACEOF +GNUSTEP_USER_DIR=`echo $GNUSTEP_USER_DIR|sed -e 's/\\\\/\\\\\\\\/g'` + +cat >>confdefs.h <<_ACEOF +#define GNUSTEP_TARGET_USER_DIR "$GNUSTEP_USER_DIR" +_ACEOF + GNUSTEP_USER_DEFAULTS_DIR=`echo $GNUSTEP_USER_DEFAULTS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` cat >>confdefs.h <<_ACEOF @@ -3245,6 +2942,12 @@ cat >>confdefs.h <<_ACEOF _ACEOF + +#------------------------------------------------------------------------------ +# Now we have finished configuring the default GNUstep filesystem setup of +# the target. All GNUstep variables from now on are the ones used to build +#------------------------------------------------------------------------------ + # # Now load the values to be used in locating libraries etc used when # building the base library ... as supplied by the gnustep-make package @@ -3253,16 +2956,11 @@ _ACEOF # ask it to output all variables! That way we have access to (eg) # GNUSTEP_SYSTEM_HEADERS below. # -# We need to unset any values that we really need, or existing settings +# We need to unles any values that we really need, or existing settings # would be used by GNUstep.sh # unset GNUSTEP_SYSTEM_HEADERS unset GNUSTEP_SYSTEM_LIBRARIES -unset GNUSTEP_NETWORK_HEADERS -unset GNUSTEP_NETWORK_LIBRARIES -unset GNUSTEP_LOCAL_HEADERS -unset GNUSTEP_LOCAL_LIBRARIES -GNUSTEP_MAKEFILES="$CURRENT_GNUSTEP_MAKEFILES" GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes . "$CURRENT_GNUSTEP_MAKEFILES/GNUstep.sh" unset GNUSTEP_SH_EXPORT_ALL_VARIABLES @@ -3277,47 +2975,13 @@ if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries" fi -if test x"$GNUSTEP_NETWORK_HEADERS" = x""; then - GNUSTEP_NETWORK_HEADERS="$GNUSTEP_NETWORK_ROOT/Library/Headers" -fi - -if test x"$GNUSTEP_NETWORK_LIBRARIES" = x""; then - GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_ROOT/Library/Libraries" -fi - -if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then - GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_ROOT/Library/Headers" -fi - -if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then - GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_ROOT/Library/Libraries" -fi - -if test x"$GNUSTEP_IS_FLATTENED" = x"no"; then - GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO" - GNUSTEP_NETWORK_HEADERS="$GNUSTEP_NETWORK_HEADERS/$LIBRARY_COMBO" - GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_HEADERS/$LIBRARY_COMBO" - # FIXME: Cross-compiling should read the target from the configure - # options and use it. GNUSTEP_TARGET_* variables do not exist in - # this context (so "$GNUSTEP_TARGET_CPU" will always be "") - if test x"$GNUSTEP_TARGET_CPU" = x""; then - GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_LIBRARIES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" - GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_LIBRARIES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" - GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_LIBRARIES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" - else - GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_LIBRARIES/$GNUSTEP_TARGET_CPU/$GNUSTEP_TARGET_OS/$LIBRARY_COMBO" - GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_LIBRARIES/$GNUSTEP_TARGET_CPU/$GNUSTEP_TARGET_OS/$LIBRARY_COMBO" - GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_LIBRARIES/$GNUSTEP_TARGET_CPU/$GNUSTEP_TARGET_OS/$LIBRARY_COMBO" - fi -fi - # # Add standard library and header directories for configure to use to locate # plain C developer headers/libraries which haver been installed in the # GNUstep hierarchy. # -CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS -I$GNUSTEP_NETWORK_HEADERS -I$GNUSTEP_LOCAL_HEADERS" -LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES -L$GNUSTEP_NETWORK_LIBRARIES -L$GNUSTEP_LOCAL_LIBRARIES" +CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS" +LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES" #-------------------------------------------------------------------- # Find the compiler @@ -3330,10 +2994,10 @@ 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:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -3346,7 +3010,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3357,11 +3021,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -3370,10 +3034,10 @@ 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:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -3386,7 +3050,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3397,11 +3061,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then @@ -3409,10 +3073,10 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 -$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; @@ -3427,10 +3091,10 @@ 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:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -3443,7 +3107,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3454,11 +3118,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -3467,10 +3131,10 @@ 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:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -3488,7 +3152,7 @@ do continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3511,11 +3175,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -3526,10 +3190,10 @@ if test -z "$CC"; then 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:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -3542,7 +3206,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3553,11 +3217,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 -$as_echo "$CC" >&6; } + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -3570,10 +3234,10 @@ if test -z "$CC"; then 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:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. @@ -3586,7 +3250,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3597,11 +3261,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -3613,10 +3277,10 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 -$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; @@ -3628,48 +3292,44 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH +echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF @@ -3688,22 +3348,27 @@ main () } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +ac_clean_files="$ac_clean_files a.out 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:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&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.*" - +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. 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_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done @@ -3714,11 +3379,10 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; 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' @@ -3729,7 +3393,7 @@ 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 ) + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most @@ -3756,15 +3420,15 @@ else ac_file='' fi -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables +echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi @@ -3773,8 +3437,8 @@ ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then @@ -3783,51 +3447,49 @@ if test "$cross_compiling" != yes; then *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. +echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will @@ -3836,31 +3498,31 @@ $as_echo "$ac_try_echo") >&5 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_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else - { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3883,41 +3545,40 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; 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_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile +echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3943,21 +3604,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no @@ -3967,19 +3627,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$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 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes @@ -4006,21 +3662,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" @@ -4045,21 +3700,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag @@ -4085,21 +3739,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -4114,8 +3767,8 @@ 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:$LINENO: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$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 @@ -4131,10 +3784,10 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC @@ -4205,21 +3858,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -4235,15 +3887,15 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac @@ -4258,15 +3910,15 @@ 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 -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" @@ -4298,21 +3950,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. @@ -4336,14 +3987,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err @@ -4351,7 +4001,7 @@ $as_echo "$ac_try_echo") >&5 # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. @@ -4376,8 +4026,8 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 -$as_echo "$CPP" >&6; } +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do @@ -4405,21 +4055,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. @@ -4443,14 +4092,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err @@ -4458,7 +4106,7 @@ $as_echo "$ac_try_echo") >&5 # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. @@ -4474,9 +4122,9 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi @@ -4488,38 +4136,210 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then - $as_echo_n "(cached) " >&6 +# Extract the first word of "whoami", so it can be a program name with args. +set dummy whoami; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_WHOAMI+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST + case $WHOAMI in + [\\/]* | ?:[\\/]*) + ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a path. + ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$PATH:/usr/ucb" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_WHOAMI="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_path_WHOAMI" && ac_cv_path_WHOAMI="echo" + ;; +esac +fi +WHOAMI=$ac_cv_path_WHOAMI +if test -n "$WHOAMI"; then + { echo "$as_me:$LINENO: result: $WHOAMI" >&5 +echo "${ECHO_T}$WHOAMI" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + +#-------------------------------------------------------------------- +# specific target_os options +#-------------------------------------------------------------------- +INCLUDE_FLAGS="$CPPFLAGS" +LDIR_FLAGS="$LDFLAGS" +# This is just for configuring. Later, in config.make, INCLUDE_FLAGS +# goes in CONFIG_SYSTEM_INCL and LIBS goes in CONFIG_SYSTEM_LIBS +case "$target_os" in + freebsd* | openbsd* ) + CPPFLAGS="$CPPFLAGS -I/usr/local/include" + LDFLAGS="$LDFLAGS -L/usr/local/lib";; + netbsd*) CPPFLAGS="$CPPFLAGS -I/usr/pkg/include" + LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";; +esac + +#---------------------------------------------------------------- +# Find out if nested functions work on this machine +#---------------------------------------------------------------- +{ echo "$as_me:$LINENO: checking whether nested functions work" >&5 +echo $ECHO_N "checking whether nested functions work... $ECHO_C" >&6; } + +if test "$cross_compiling" = yes; then + gcc_nested=1 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include "$srcdir/config/config.nested.c" +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + gcc_nested=1 +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +gcc_nested=0 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +if test $gcc_nested = 0; then + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define BROKEN_NESTED_FUNCTIONS 1 +_ACEOF + +else + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +fi + +#-------------------------------------------------------------------- +# Set Apple/Darwin/OSX/NeXT information for other tests +#-------------------------------------------------------------------- +OBJC_RUNTIME_LIB=`echo $LIBRARY_COMBO | tr '-' ' ' | awk '{print $1}'` +{ echo "$as_me:$LINENO: checking the Objective-C runtime" >&5 +echo $ECHO_N "checking the Objective-C runtime... $ECHO_C" >&6; } +if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then + { echo "$as_me:$LINENO: result: NeXT" >&5 +echo "${ECHO_T}NeXT" >&6; } + LIBOBJC='-lobjc' + OBJCFLAGS="-fnext-runtime -DNeXT_RUNTIME" +else + { echo "$as_me:$LINENO: result: GNU" >&5 +echo "${ECHO_T}GNU" >&6; } + LIBOBJC='-lobjc' + OBJCFLAGS="-fgnu-runtime" +fi + +#-------------------------------------------------------------------- +# Miscellaneous flags +#-------------------------------------------------------------------- +# Set location of GNUstep dirs for later use +if test "$GNUSTEP_IS_FLATTENED" = no; then + clean_target_os=`$CURRENT_GNUSTEP_MAKEFILES/clean_os.sh $target_os` + clean_target_cpu=`$CURRENT_GNUSTEP_MAKEFILES/clean_cpu.sh $target_cpu` + obj_dir=$clean_target_cpu/$clean_target_os + lobj_dir=$clean_target_cpu/$clean_target_os/$LIBRARY_COMBO + GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES/$obj_dir" + GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO" +else + obj_dir= + lobj_dir= + GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES" + GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS" +fi + +# +# The following one is so that headers of custom libraries into +# $GNUSTEP_HDIR are used before the standard ones +# +INCLUDE_FLAGS="$INCLUDE_FLAGS -I$GNUSTEP_HDIR" +LDIR_FLAGS="$LDIR_FLAGS -L$GNUSTEP_LDIR/$LIBRARY_COMBO -L$GNUSTEP_LDIR" + +#-------------------------------------------------------------------- +# Check if Objective-C is installed +#-------------------------------------------------------------------- + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 - $as_echo_n 0123456789 >"conftest.in" + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" + echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` @@ -4534,60 +4354,74 @@ case `"$ac_path_GREP" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - $ac_path_GREP_found && break 3 - done + + $ac_path_GREP_found && break 3 done done + +done IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } - fi +fi + else ac_cv_path_GREP=$GREP fi + fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else - if test -z "$EGREP"; then + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 - $as_echo_n 0123456789 >"conftest.in" + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" + echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` @@ -4602,31 +4436,40 @@ case `"$ac_path_EGREP" --version 2>&1` in rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac - $ac_path_EGREP_found && break 3 - done + + $ac_path_EGREP_found && break 3 done done + +done IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } - fi +fi + else ac_cv_path_EGREP=$EGREP fi + fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -4653,21 +4496,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no @@ -4759,40 +4601,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF @@ -4814,11 +4653,11 @@ fi for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -4836,21 +4675,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" @@ -4858,14 +4696,12 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -4874,564 +4710,22 @@ done - if test "${ac_cv_header_minix_config_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for minix/config.h" >&5 -$as_echo_n "checking for minix/config.h... " >&6; } -if test "${ac_cv_header_minix_config_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 -$as_echo "$ac_cv_header_minix_config_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking minix/config.h usability" >&5 -$as_echo_n "checking minix/config.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking minix/config.h presence" >&5 -$as_echo_n "checking minix/config.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: minix/config.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: minix/config.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: minix/config.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: minix/config.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: minix/config.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for minix/config.h" >&5 -$as_echo_n "checking for minix/config.h... " >&6; } -if test "${ac_cv_header_minix_config_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_minix_config_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 -$as_echo "$ac_cv_header_minix_config_h" >&6; } - -fi -if test $ac_cv_header_minix_config_h = yes; then - MINIX=yes -else - MINIX= -fi - - - if test "$MINIX" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define _POSIX_SOURCE 1 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define _POSIX_1_SOURCE 2 -_ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define _MINIX 1 -_ACEOF - - fi - - - - { $as_echo "$as_me:$LINENO: checking whether it is safe to define __EXTENSIONS__" >&5 -$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if test "${ac_cv_safe_to_define___extensions__+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default -int -main () -{ - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_safe_to_define___extensions__=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_safe_to_define___extensions__=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_safe_to_define___extensions__" >&5 -$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } - test $ac_cv_safe_to_define___extensions__ = yes && - cat >>confdefs.h <<\_ACEOF -#define __EXTENSIONS__ 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define _ALL_SOURCE 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define _GNU_SOURCE 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define _POSIX_PTHREAD_SEMANTICS 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF -#define _TANDEM_SOURCE 1 -_ACEOF - - - -# Extract the first word of "whoami", so it can be a program name with args. -set dummy whoami; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_WHOAMI+set}" = set; then - $as_echo_n "(cached) " >&6 -else - case $WHOAMI in - [\\/]* | ?:[\\/]*) - ac_cv_path_WHOAMI="$WHOAMI" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_dummy="$PATH:/usr/ucb" -for as_dir in $as_dummy -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_WHOAMI="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - - test -z "$ac_cv_path_WHOAMI" && ac_cv_path_WHOAMI="echo" - ;; -esac -fi -WHOAMI=$ac_cv_path_WHOAMI -if test -n "$WHOAMI"; then - { $as_echo "$as_me:$LINENO: result: $WHOAMI" >&5 -$as_echo "$WHOAMI" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - -#-------------------------------------------------------------------- -# specific target_os options -#-------------------------------------------------------------------- -INCLUDE_FLAGS="$CPPFLAGS" -LDIR_FLAGS="$LDFLAGS" -# This is just for configuring. Later, in config.make, INCLUDE_FLAGS -# goes in CONFIG_SYSTEM_INCL and LIBS goes in CONFIG_SYSTEM_LIBS -case "$target_os" in - freebsd* | openbsd* ) - CPPFLAGS="$CPPFLAGS -I/usr/local/include" - LDFLAGS="$LDFLAGS -L/usr/local/lib";; - netbsd*) CPPFLAGS="$CPPFLAGS -I/usr/pkg/include" - LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";; -esac - -#-------------------------------------------------------------------- -# Set Apple/Darwin/OSX/NeXT information for other tests -#-------------------------------------------------------------------- -OBJC_WITH_GC=no -OBJC_RUNTIME_LIB=`echo $LIBRARY_COMBO | tr '-' ' ' | awk '{print $1}'` -{ $as_echo "$as_me:$LINENO: checking the Objective-C runtime" >&5 -$as_echo_n "checking the Objective-C runtime... " >&6; } -if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then - { $as_echo "$as_me:$LINENO: result: NeXT" >&5 -$as_echo "NeXT" >&6; } - LIBOBJC='-lobjc' - OBJCFLAGS="-fnext-runtime -DNeXT_RUNTIME" -elif test "$OBJC_RUNTIME_LIB" = "gnugc"; then - { $as_echo "$as_me:$LINENO: result: GNU" >&5 -$as_echo "GNU" >&6; } - LIBOBJC='-lobjc_gc -ldl -lgc' - OBJCFLAGS="-fgnu-runtime" - OBJC_WITH_GC=yes -else - { $as_echo "$as_me:$LINENO: result: GNU" >&5 -$as_echo "GNU" >&6; } - LIBOBJC='-lobjc' - OBJCFLAGS="-fgnu-runtime" -fi - -#-------------------------------------------------------------------- -# Miscellaneous flags -#-------------------------------------------------------------------- - -# Check to see if the libobjc library is in our GNUSTEP_SYSTEM_LIBRARIES. -# If so, there are probably other libraries that we want there also, so -# leave the proper includes in CPPFLAGS and LDFLAGS -{ $as_echo "$as_me:$LINENO: checking for custom shared objc library" >&5 -$as_echo_n "checking for custom shared objc library... " >&6; } -if test "${gs_cv_objc_libdir+set}" = set; then - $as_echo_n "(cached) " >&6 -else - gs_cv_objc_libdir=NONE -gs_cv_objc_incdir=NONE -# Try GNUSTEP_SYSTEM_LIBRARIES first -if test "$GNUSTEP_IS_FLATTENED" = yes; then - GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES" - GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS" -else - GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES/$obj_dir" - GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO" -fi - -if test -f "$GNUSTEP_HDIR/objc/objc.h"; then - if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then - gs_cv_objc_libdir="$GNUSTEP_LDIR" - gs_cv_objc_incdir="$GNUSTEP_HDIR" - fi -fi - -# Try GNUSTEP_NETWORK_LIBRARIES second (override GNUSTEP_SYSTEM if -# found) -if test "$GNUSTEP_IS_FLATTENED" = yes; then - GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES" - GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS" -else - GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES/$obj_dir" - GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS/$LIBRARY_COMBO" -fi - -if test -f "$GNUSTEP_HDIR/objc/objc.h"; then - if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then - gs_cv_objc_libdir="$GNUSTEP_LDIR" - gs_cv_objc_incdir="$GNUSTEP_HDIR" - fi -fi - -# Try GNUSTEP_LOCAL_LIBRARIES third (override GNUSTEP_SYSTEM and -# GNUSTEP_NETWORK if found) -if test "$GNUSTEP_IS_FLATTENED" = yes; then - GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES" - GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS" -else - GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES/$obj_dir" - GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS/$LIBRARY_COMBO" -fi - -if test -f "$GNUSTEP_HDIR/objc/objc.h"; then - if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then - gs_cv_objc_libdir="$GNUSTEP_LDIR" - gs_cv_objc_incdir="$GNUSTEP_HDIR" - fi -fi - -fi - -{ $as_echo "$as_me:$LINENO: result: $gs_cv_objc_libdir" >&5 -$as_echo "$gs_cv_objc_libdir" >&6; } - -if test "$gs_cv_objc_libdir" != "NONE"; then - # - # The following one is so that headers of custom libraries into - # $GNUSTEP_HDIR are used before the standard ones - # - INCLUDE_FLAGS="$INCLUDE_FLAGS -I$gs_cv_objc_incdir" - LDIR_FLAGS="$LDIR_FLAGS -L$gs_cv_objc_libdir/$LIBRARY_COMBO -L$gs_cv_objc_libdir" - CPPFLAGS="$CPPFLAGS -I$gs_cv_objc_incdir" - LDFLAGS="$LDFLAGS -L$gs_cv_objc_libdir" -fi - -#-------------------------------------------------------------------- -# Check if Objective-C is installed -#-------------------------------------------------------------------- - -for ac_header in objc/runtime.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - for ac_header in objc/objc.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5447,33 +4741,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -5487,72 +4780,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -5562,556 +4852,18 @@ done if test $ac_cv_header_objc_objc_h = no; then echo "Check to make sure you have a full installation of the GCC" echo "compiler that includes the Objective-C headers and libraries" - { { $as_echo "$as_me:$LINENO: error: Could not find Objective-C headers" >&5 -$as_echo "$as_me: error: Could not find Objective-C headers" >&2;} + { { echo "$as_me:$LINENO: error: Could not find Objective-C headers" >&5 +echo "$as_me: error: Could not find Objective-C headers" >&2;} { (exit 1); exit 1; }; } fi -if test $OBJC_WITH_GC = yes; then - -for ac_header in gc.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - gc_ok=yes -else - gc_ok=no -fi - -done - - if test "$gc_ok" = no; then - { { $as_echo "$as_me:$LINENO: error: Garbage collection was required, but the gc.h header couldn't be found." >&5 -$as_echo "$as_me: error: Garbage collection was required, but the gc.h header couldn't be found." >&2;} - { (exit 1); exit 1; }; } - fi - saved_LIBS="$LIBS" - LIBS+=" -lgc" - { $as_echo "$as_me:$LINENO: checking for GC_malloc" >&5 -$as_echo_n "checking for GC_malloc... " >&6; } -if test "${ac_cv_func_GC_malloc+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define GC_malloc to an innocuous variant, in case declares GC_malloc. - For example, HP-UX 11i declares gettimeofday. */ -#define GC_malloc innocuous_GC_malloc - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char GC_malloc (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef GC_malloc - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char GC_malloc (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_GC_malloc || defined __stub___GC_malloc -choke me -#endif - -int -main () -{ -return GC_malloc (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_GC_malloc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_GC_malloc=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_GC_malloc" >&5 -$as_echo "$ac_cv_func_GC_malloc" >&6; } -if test $ac_cv_func_GC_malloc = yes; then - gc_ok=yes -else - gc_ok=no -fi - - if test "$gc_ok" = no; then - { { $as_echo "$as_me:$LINENO: error: Garbage collection was required, but the gc library couldn't be found." >&5 -$as_echo "$as_me: error: Garbage collection was required, but the gc library couldn't be found." >&2;} - { (exit 1); exit 1; }; } - fi - { $as_echo "$as_me:$LINENO: checking for GC_register_my_thread" >&5 -$as_echo_n "checking for GC_register_my_thread... " >&6; } -if test "${ac_cv_func_GC_register_my_thread+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define GC_register_my_thread to an innocuous variant, in case declares GC_register_my_thread. - For example, HP-UX 11i declares gettimeofday. */ -#define GC_register_my_thread innocuous_GC_register_my_thread - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char GC_register_my_thread (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef GC_register_my_thread - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char GC_register_my_thread (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_GC_register_my_thread || defined __stub___GC_register_my_thread -choke me -#endif - -int -main () -{ -return GC_register_my_thread (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_GC_register_my_thread=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_GC_register_my_thread=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_GC_register_my_thread" >&5 -$as_echo "$ac_cv_func_GC_register_my_thread" >&6; } - - if test "$ac_cv_func_GC_register_my_thread" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_GC_REGISTER_MY_THREAD 1 -_ACEOF - - fi - { $as_echo "$as_me:$LINENO: checking for GC_allow_register_threads" >&5 -$as_echo_n "checking for GC_allow_register_threads... " >&6; } -if test "${ac_cv_func_GC_allow_register_threads+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define GC_allow_register_threads to an innocuous variant, in case declares GC_allow_register_threads. - For example, HP-UX 11i declares gettimeofday. */ -#define GC_allow_register_threads innocuous_GC_allow_register_threads - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char GC_allow_register_threads (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef GC_allow_register_threads - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char GC_allow_register_threads (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_GC_allow_register_threads || defined __stub___GC_allow_register_threads -choke me -#endif - -int -main () -{ -return GC_allow_register_threads (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_GC_allow_register_threads=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_GC_allow_register_threads=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_GC_allow_register_threads" >&5 -$as_echo "$ac_cv_func_GC_allow_register_threads" >&6; } - - if test "$ac_cv_func_GC_allow_register_threads" = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_GC_ALLOW_REGISTER_THREADS 1 -_ACEOF - - fi - LIBS="-lobjc_gc -ldl" - { $as_echo "$as_me:$LINENO: checking for class_ivar_set_gcinvisible" >&5 -$as_echo_n "checking for class_ivar_set_gcinvisible... " >&6; } -if test "${ac_cv_func_class_ivar_set_gcinvisible+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define class_ivar_set_gcinvisible to an innocuous variant, in case declares class_ivar_set_gcinvisible. - For example, HP-UX 11i declares gettimeofday. */ -#define class_ivar_set_gcinvisible innocuous_class_ivar_set_gcinvisible - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char class_ivar_set_gcinvisible (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef class_ivar_set_gcinvisible - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char class_ivar_set_gcinvisible (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_class_ivar_set_gcinvisible || defined __stub___class_ivar_set_gcinvisible -choke me -#endif - -int -main () -{ -return class_ivar_set_gcinvisible (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_class_ivar_set_gcinvisible=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_class_ivar_set_gcinvisible=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_class_ivar_set_gcinvisible" >&5 -$as_echo "$ac_cv_func_class_ivar_set_gcinvisible" >&6; } -if test $ac_cv_func_class_ivar_set_gcinvisible = yes; then - gc_ok=yes -else - gc_ok=no -fi - - if test "$gc_ok" = no; then - { { $as_echo "$as_me:$LINENO: error: Garbage collection was required, but the gc runtime couldn't be found." >&5 -$as_echo "$as_me: error: Garbage collection was required, but the gc runtime couldn't be found." >&2;} - { (exit 1); exit 1; }; } - fi - LIBS="$saved_LIBS" - -fi - #-------------------------------------------------------------------- # Check for strange network stuff used by gdomap #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: for gdomap network details" >&5 -$as_echo "$as_me: for gdomap network details" >&6;} -{ $as_echo "$as_me:$LINENO: checking for variable length socket addresses" >&5 -$as_echo_n "checking for variable length socket addresses... " >&6; } +{ echo "$as_me:$LINENO: for gdomap network details" >&5 +echo "$as_me: for gdomap network details" >&6;} +{ echo "$as_me:$LINENO: checking for variable length socket addresses" >&5 +echo $ECHO_N "checking for variable length socket addresses... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -6137,21 +4889,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then sa_len=1 else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 sa_len=0 @@ -6159,20 +4910,20 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $sa_len = 1; then - { $as_echo "$as_me:$LINENO: result: found" >&5 -$as_echo "found" >&6; } + { echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_SA_LEN 1 _ACEOF else - { $as_echo "$as_me:$LINENO: result: not found" >&5 -$as_echo "not found" >&6; } + { echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6; } fi -{ $as_echo "$as_me:$LINENO: checking for gcc visibility attribute support" >&5 -$as_echo_n "checking for gcc visibility attribute support... " >&6; } +{ echo "$as_me:$LINENO: checking for gcc visibility attribute support" >&5 +echo $ECHO_N "checking for gcc visibility attribute support... $ECHO_C" >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" cat >conftest.$ac_ext <<_ACEOF @@ -6188,27 +4939,26 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: found" >&5 -$as_echo "found" >&6; } + { echo "$as_me:$LINENO: result: found" >&5 +echo "${ECHO_T}found" >&6; } gs_visibility=1 else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - { $as_echo "$as_me:$LINENO: result: not present" >&5 -$as_echo "not present" >&6; } + { echo "$as_me:$LINENO: result: not present" >&5 +echo "${ECHO_T}not present" >&6; } gs_visibility=0 fi @@ -6225,8 +4975,8 @@ CFLAGS="$saved_CFLAGS" #-------------------------------------------------------------------- # Check if system has buggy SO_REUSEADDR #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking whether SO_REUSEADDR is broken" >&5 -$as_echo_n "checking whether SO_REUSEADDR is broken... " >&6; } +{ echo "$as_me:$LINENO: checking whether SO_REUSEADDR is broken" >&5 +echo $ECHO_N "checking whether SO_REUSEADDR is broken... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then reuseaddr_ok=0 else @@ -6244,32 +4994,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then reuseaddr_ok=1 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) reuseaddr_ok=0 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -6290,96 +5037,52 @@ _ACEOF echo "an operating-system timeout has expired." echo "For servers other than gdomap, GNUstep does not normally need" echo "a particular network port, so the problem is unlikely to arise." - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi #-------------------------------------------------------------------- # Check for thread flags for libobjc. #-------------------------------------------------------------------- # -{ $as_echo "$as_me:$LINENO: checking for objc threading flags" >&5 -$as_echo_n "checking for objc threading flags... " >&6; } +{ echo "$as_me:$LINENO: checking for objc threading flags" >&5 +echo $ECHO_N "checking for objc threading flags... $ECHO_C" >&6; } # # Get them from gnustep-make which contains the real code to get them # objc_threaded=`grep objc_threaded: $CURRENT_GNUSTEP_MAKEFILES/$lobj_dir/config.make | sed -e 's/objc_threaded:=//'` # -{ $as_echo "$as_me:$LINENO: result: $objc_threaded" >&5 -$as_echo "$objc_threaded" >&6; } +{ echo "$as_me:$LINENO: result: $objc_threaded" >&5 +echo "${ECHO_T}$objc_threaded" >&6; } #-------------------------------------------------------------------- # Byte order information needed for foundation headers. #-------------------------------------------------------------------- - - { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } if test "${ac_cv_c_bigendian+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_c_bigendian=unknown - # See if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if ! (defined __BIG_ENDIAN__ || defined __LITTLE_ENDIAN__) - neither is defined; - #endif - typedef int dummy; - -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_cv_c_bigendian=universal -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test $ac_cv_c_bigendian = unknown; then - # See if sys/param.h defines the BYTE_ORDER macro. - cat >conftest.$ac_ext <<_ACEOF + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include - #include +#include int main () { -#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ - && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ - && LITTLE_ENDIAN) - bogus endian macros - #endif +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif ; return 0; @@ -6391,34 +5094,33 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include - #include +#include int main () { #if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif + not big endian +#endif ; return 0; @@ -6430,21 +5132,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no @@ -6452,31 +5153,29 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat >conftest.$ac_ext <<_ACEOF + # It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include - +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { -#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) - bogus endian macros - #endif - + _ascii (); _ebcdic (); ; return 0; } @@ -6487,139 +5186,30 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - # It does; now see whether it defined to _BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -int -main () -{ -#ifndef _BIG_ENDIAN - not big endian - #endif - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - fi - if test $ac_cv_c_bigendian = unknown; then - # Compile a test program. - if test "$cross_compiling" = yes; then - # Try to guess by grepping values from an object file. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -short int ascii_mm[] = - { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; - short int ascii_ii[] = - { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; - int use_ascii (int i) { - return ascii_mm[i] + ascii_ii[i]; - } - short int ebcdic_ii[] = - { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; - short int ebcdic_mm[] = - { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; - int use_ebcdic (int i) { - return ebcdic_mm[i] + ebcdic_ii[i]; - } - extern int foo; - -int -main () -{ -return use_ascii (foo) == use_ebcdic (foo); - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then - ac_cv_c_bigendian=yes - fi - if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then - if test "$ac_cv_c_bigendian" = unknown; then - ac_cv_c_bigendian=no - else - # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown - fi - fi else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -6638,14 +5228,14 @@ int main () { - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long int l; - char c[sizeof (long int)]; - } u; - u.l = 1; - return u.c[sizeof (long int) - 1] == 1; + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; ; return 0; @@ -6657,57 +5247,55 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=no else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -$as_echo "$ac_cv_c_bigendian" >&6; } - case $ac_cv_c_bigendian in #( - yes) - cat >>confdefs.h <<\_ACEOF + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF -;; #( - no) - ;; #( - universal) - ;; #( - *) - { { $as_echo "$as_me:$LINENO: error: unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" >&5 -$as_echo "$as_me: error: unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; - esac +esac if test $ac_cv_c_bigendian = yes; then GS_WORDS_BIGENDIAN=1 @@ -6719,14 +5307,68 @@ fi #-------------------------------------------------------------------- # Type size information needed for foundation headers. #-------------------------------------------------------------------- +{ echo "$as_me:$LINENO: checking for void*" >&5 +echo $ECHO_N "checking for void*... $ECHO_C" >&6; } +if test "${ac_cv_type_voidp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef void* ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_voidp=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_voidp=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_voidp" >&5 +echo "${ECHO_T}$ac_cv_type_voidp" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of void*" >&5 -$as_echo_n "checking size of void*... " >&6; } +{ echo "$as_me:$LINENO: checking size of void*" >&5 +echo $ECHO_N "checking size of void*... $ECHO_C" >&6; } if test "${ac_cv_sizeof_voidp+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -6737,10 +5379,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef void* ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (void*))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -6753,14 +5396,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -6774,10 +5416,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef void* ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (void*))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -6790,21 +5433,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -6818,7 +5460,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -6828,10 +5470,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef void* ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (void*))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -6844,14 +5487,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -6865,10 +5507,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef void* ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (void*))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -6881,21 +5524,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -6909,7 +5551,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -6929,10 +5571,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef void* ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (void*))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -6945,21 +5588,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -6970,9 +5612,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_voidp=$ac_lo;; '') if test "$ac_cv_type_voidp" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (void*) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (void*) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (void*) +echo "$as_me: error: cannot compute sizeof (void*) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -6987,8 +5629,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (void*)); } -static unsigned long int ulongval () { return (long int) (sizeof (void*)); } + typedef void* ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -6998,22 +5641,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (void*))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (void*)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (void*)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -7026,46 +5667,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_voidp=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_voidp" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (void*) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (void*) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (void*) +echo "$as_me: error: cannot compute sizeof (void*) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_voidp=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_voidp" >&5 -$as_echo "$ac_cv_sizeof_voidp" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_voidp" >&5 +echo "${ECHO_T}$ac_cv_sizeof_voidp" >&6; } @@ -7080,14 +5718,68 @@ GS_UINT8="unsigned char" +{ echo "$as_me:$LINENO: checking for short" >&5 +echo $ECHO_N "checking for short... $ECHO_C" >&6; } +if test "${ac_cv_type_short+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef short ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_short=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_short=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 +echo "${ECHO_T}$ac_cv_type_short" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of short" >&5 -$as_echo_n "checking size of short... " >&6; } +{ echo "$as_me:$LINENO: checking size of short" >&5 +echo $ECHO_N "checking size of short... $ECHO_C" >&6; } if test "${ac_cv_sizeof_short+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -7098,10 +5790,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef short ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -7114,14 +5807,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -7135,10 +5827,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef short ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -7151,21 +5844,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -7179,7 +5871,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -7189,10 +5881,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef short ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (short))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -7205,14 +5898,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -7226,10 +5918,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef short ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -7242,21 +5935,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -7270,7 +5962,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -7290,10 +5982,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef short ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -7306,21 +5999,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -7331,9 +6023,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_short=$ac_lo;; '') if test "$ac_cv_type_short" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (short) +echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -7348,8 +6040,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (short)); } -static unsigned long int ulongval () { return (long int) (sizeof (short)); } + typedef short ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -7359,22 +6052,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (short))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (short)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (short)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -7387,46 +6078,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_short=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_short" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (short) +echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_short=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 -$as_echo "$ac_cv_sizeof_short" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 +echo "${ECHO_T}$ac_cv_sizeof_short" >&6; } @@ -7437,14 +6125,68 @@ _ACEOF +{ echo "$as_me:$LINENO: checking for int" >&5 +echo $ECHO_N "checking for int... $ECHO_C" >&6; } +if test "${ac_cv_type_int+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef int ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_int=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_int=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 +echo "${ECHO_T}$ac_cv_type_int" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of int" >&5 -$as_echo_n "checking size of int... " >&6; } +{ echo "$as_me:$LINENO: checking size of int" >&5 +echo $ECHO_N "checking size of int... $ECHO_C" >&6; } if test "${ac_cv_sizeof_int+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -7455,10 +6197,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef int ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -7471,14 +6214,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -7492,10 +6234,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef int ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -7508,21 +6251,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -7536,7 +6278,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -7546,10 +6288,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef int ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (int))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -7562,14 +6305,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -7583,10 +6325,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef int ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -7599,21 +6342,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -7627,7 +6369,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -7647,10 +6389,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef int ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -7663,21 +6406,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -7688,9 +6430,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_int=$ac_lo;; '') if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (int) +echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -7705,8 +6447,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (int)); } -static unsigned long int ulongval () { return (long int) (sizeof (int)); } + typedef int ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -7716,22 +6459,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (int))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (int)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (int)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -7744,46 +6485,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_int=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (int) +echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_int=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 -$as_echo "$ac_cv_sizeof_int" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 +echo "${ECHO_T}$ac_cv_sizeof_int" >&6; } @@ -7794,14 +6532,68 @@ _ACEOF +{ echo "$as_me:$LINENO: checking for long" >&5 +echo $ECHO_N "checking for long... $ECHO_C" >&6; } +if test "${ac_cv_type_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef long ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_long=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 +echo "${ECHO_T}$ac_cv_type_long" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of long" >&5 -$as_echo_n "checking size of long... " >&6; } +{ echo "$as_me:$LINENO: checking size of long" >&5 +echo $ECHO_N "checking size of long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -7812,10 +6604,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -7828,14 +6621,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -7849,10 +6641,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -7865,21 +6658,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -7893,7 +6685,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -7903,10 +6695,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -7919,14 +6712,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -7940,10 +6732,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -7956,21 +6749,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -7984,7 +6776,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -8004,10 +6796,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -8020,21 +6813,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -8045,9 +6837,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_long=$ac_lo;; '') if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (long) +echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -8062,8 +6854,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (long)); } -static unsigned long int ulongval () { return (long int) (sizeof (long)); } + typedef long ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -8073,22 +6866,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (long))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (long)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (long)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -8101,46 +6892,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_long=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (long) +echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_long=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 -$as_echo "$ac_cv_sizeof_long" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long" >&6; } @@ -8151,14 +6939,68 @@ _ACEOF +{ echo "$as_me:$LINENO: checking for long long" >&5 +echo $ECHO_N "checking for long long... $ECHO_C" >&6; } +if test "${ac_cv_type_long_long+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef long long ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_long_long=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_long_long=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 +echo "${ECHO_T}$ac_cv_type_long_long" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of long long" >&5 -$as_echo_n "checking size of long long... " >&6; } +{ echo "$as_me:$LINENO: checking size of long long" >&5 +echo $ECHO_N "checking size of long long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long_long+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -8169,10 +7011,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long long))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -8185,14 +7028,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -8206,10 +7048,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -8222,21 +7065,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -8250,7 +7092,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -8260,10 +7102,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long long))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -8276,14 +7119,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -8297,10 +7139,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long long))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -8313,21 +7156,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -8341,7 +7183,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -8361,10 +7203,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef long long ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (long long))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -8377,21 +7220,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -8402,9 +7244,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_long_long=$ac_lo;; '') if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long long) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (long long) +echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -8419,8 +7261,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (long long)); } -static unsigned long int ulongval () { return (long int) (sizeof (long long)); } + typedef long long ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -8430,22 +7273,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (long long))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (long long)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (long long)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -8458,46 +7299,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_long_long=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_long_long" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long long) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (long long) +echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_long_long=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 -$as_echo "$ac_cv_sizeof_long_long" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 +echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6; } @@ -8508,14 +7346,68 @@ _ACEOF +{ echo "$as_me:$LINENO: checking for float" >&5 +echo $ECHO_N "checking for float... $ECHO_C" >&6; } +if test "${ac_cv_type_float+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef float ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_float=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_float=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_float" >&5 +echo "${ECHO_T}$ac_cv_type_float" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of float" >&5 -$as_echo_n "checking size of float... " >&6; } +{ echo "$as_me:$LINENO: checking size of float" >&5 +echo $ECHO_N "checking size of float... $ECHO_C" >&6; } if test "${ac_cv_sizeof_float+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -8526,10 +7418,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef float ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -8542,14 +7435,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -8563,10 +7455,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef float ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -8579,21 +7472,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -8607,7 +7499,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -8617,10 +7509,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef float ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (float))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -8633,14 +7526,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -8654,10 +7546,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef float ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -8670,21 +7563,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -8698,7 +7590,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -8718,10 +7610,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef float ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -8734,21 +7627,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -8759,9 +7651,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_float=$ac_lo;; '') if test "$ac_cv_type_float" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (float) +echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -8776,8 +7668,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (float)); } -static unsigned long int ulongval () { return (long int) (sizeof (float)); } + typedef float ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -8787,22 +7680,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (float))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (float)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (float)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -8815,46 +7706,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_float=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_float" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (float) +echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_float=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 -$as_echo "$ac_cv_sizeof_float" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 +echo "${ECHO_T}$ac_cv_sizeof_float" >&6; } @@ -8865,14 +7753,68 @@ _ACEOF +{ echo "$as_me:$LINENO: checking for double" >&5 +echo $ECHO_N "checking for double... $ECHO_C" >&6; } +if test "${ac_cv_type_double+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef double ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_double=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_double=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 +echo "${ECHO_T}$ac_cv_type_double" >&6; } + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of double" >&5 -$as_echo_n "checking size of double... " >&6; } +{ echo "$as_me:$LINENO: checking size of double" >&5 +echo $ECHO_N "checking size of double... $ECHO_C" >&6; } if test "${ac_cv_sizeof_double+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. @@ -8883,10 +7825,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; @@ -8899,14 +7842,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -8920,10 +7862,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -8936,21 +7879,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` @@ -8964,7 +7906,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF @@ -8974,10 +7916,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (double))) < 0)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; @@ -8990,14 +7933,13 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err @@ -9011,10 +7953,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; @@ -9027,21 +7970,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` @@ -9055,7 +7997,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= @@ -9075,10 +8017,11 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default + typedef double ac__type_sizeof_; int main () { -static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)]; +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; @@ -9091,21 +8034,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` @@ -9116,9 +8058,9 @@ done case $ac_lo in ?*) ac_cv_sizeof_double=$ac_lo;; '') if test "$ac_cv_type_double" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (double) +echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else @@ -9133,8 +8075,9 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default -static long int longval () { return (long int) (sizeof (double)); } -static unsigned long int ulongval () { return (long int) (sizeof (double)); } + typedef double ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int @@ -9144,22 +8087,20 @@ main () FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; - if (((long int) (sizeof (double))) < 0) + if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); - if (i != ((long int) (sizeof (double)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%ld", i); + fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (double)))) + if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; - fprintf (f, "%lu", i); + fprintf (f, "%lu\n", i); } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ return ferror (f) || fclose (f) != 0; ; @@ -9172,46 +8113,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_double=`cat conftest.val` else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_double" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double) + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (double) +echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_double=0 fi fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 -$as_echo "$ac_cv_sizeof_double" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 +echo "${ECHO_T}$ac_cv_sizeof_double" >&6; } @@ -9235,8 +8173,8 @@ else GS_SADDR="long long" GS_UADDR="unsigned long long" else - { { $as_echo "$as_me:$LINENO: error: Unable to find integer of same size as void*" >&5 -$as_echo "$as_me: error: Unable to find integer of same size as void*" >&2;} + { { echo "$as_me:$LINENO: error: Unable to find integer of same size as void*" >&5 +echo "$as_me: error: Unable to find integer of same size as void*" >&2;} { (exit 1); exit 1; }; } fi fi @@ -9252,8 +8190,8 @@ else GS_SINT16="signed int" GS_UINT16="unsigned int" else - { { $as_echo "$as_me:$LINENO: error: Unable to determine type for 16-bit integer" >&5 -$as_echo "$as_me: error: Unable to determine type for 16-bit integer" >&2;} + { { echo "$as_me:$LINENO: error: Unable to determine type for 16-bit integer" >&5 +echo "$as_me: error: Unable to determine type for 16-bit integer" >&2;} { (exit 1); exit 1; }; } fi fi @@ -9272,8 +8210,8 @@ else GS_SINT32="signed short" GS_UINT32="unsigned short" else - { { $as_echo "$as_me:$LINENO: error: Unable to determine type for 32-bit integer" >&5 -$as_echo "$as_me: error: Unable to determine type for 32-bit integer" >&2;} + { { echo "$as_me:$LINENO: error: Unable to determine type for 32-bit integer" >&5 +echo "$as_me: error: Unable to determine type for 32-bit integer" >&2;} { (exit 1); exit 1; }; } fi fi @@ -9317,8 +8255,8 @@ else else # 128-bit ints not supported - but we need a dummy type for byte-swapping # of 128-bit values arriving from another system. - GS_SINT128="struct { gsu8 a[16]; }" - GS_UINT128="struct { gsu8 a[16]; }" + GS_SINT128="struct { gsu8 a16; }" + GS_UINT128="struct { gsu8 a16; }" GS_HAVE_I128=0 fi fi @@ -9329,8 +8267,8 @@ fi if test $ac_cv_sizeof_float = 4; then GS_FLT32="float" else - { { $as_echo "$as_me:$LINENO: error: Unable to determine type for 32-bit float" >&5 -$as_echo "$as_me: error: Unable to determine type for 32-bit float" >&2;} + { { echo "$as_me:$LINENO: error: Unable to determine type for 32-bit float" >&5 +echo "$as_me: error: Unable to determine type for 32-bit float" >&2;} { (exit 1); exit 1; }; } fi @@ -9338,8 +8276,8 @@ fi if test $ac_cv_sizeof_double = 8; then GS_FLT64="double" else - { { $as_echo "$as_me:$LINENO: error: Unable to determine type for 64-bit float" >&5 -$as_echo "$as_me: error: Unable to determine type for 64-bit float" >&2;} + { { echo "$as_me:$LINENO: error: Unable to determine type for 64-bit float" >&5 +echo "$as_me: error: Unable to determine type for 64-bit float" >&2;} { (exit 1); exit 1; }; } fi @@ -9418,10 +8356,10 @@ fi # Makes the following substitutions: # Defines CON_AUTOLOAD (whether constructor functions are autoloaded) #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking loading of constructor functions" >&5 -$as_echo_n "checking loading of constructor functions... " >&6; } +{ echo "$as_me:$LINENO: checking loading of constructor functions" >&5 +echo $ECHO_N "checking loading of constructor functions... $ECHO_C" >&6; } if test "${objc_cv_con_autoload+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then objc_cv_con_autoload=no @@ -9446,54 +8384,50 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then objc_cv_con_autoload=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) objc_cv_con_autoload=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi case "$target_os" in cygwin*) objc_cv_con_autoload=yes;; - mingw*) objc_cv_con_autoload=yes;; esac fi if test $objc_cv_con_autoload = yes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define CON_AUTOLOAD 1 _ACEOF else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi # Copyright (C) 2005 Free Software Foundation @@ -9509,17 +8443,17 @@ fi #-------------------------------------------------------------------- DYNAMIC_LINKER=null if test "${ac_cv_header_dlfcn_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for dlfcn.h" >&5 -$as_echo_n "checking for dlfcn.h... " >&6; } + { echo "$as_me:$LINENO: checking for dlfcn.h" >&5 +echo $ECHO_N "checking for dlfcn.h... $ECHO_C" >&6; } if test "${ac_cv_header_dlfcn_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5 -$as_echo "$ac_cv_header_dlfcn_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5 +echo "${ECHO_T}$ac_cv_header_dlfcn_h" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking dlfcn.h usability" >&5 -$as_echo_n "checking dlfcn.h usability... " >&6; } +{ echo "$as_me:$LINENO: checking dlfcn.h usability" >&5 +echo $ECHO_N "checking dlfcn.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9535,33 +8469,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking dlfcn.h presence" >&5 -$as_echo_n "checking dlfcn.h presence... " >&6; } +{ echo "$as_me:$LINENO: checking dlfcn.h presence" >&5 +echo $ECHO_N "checking dlfcn.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9575,64 +8508,63 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: dlfcn.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: dlfcn.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: dlfcn.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: dlfcn.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for dlfcn.h" >&5 -$as_echo_n "checking for dlfcn.h... " >&6; } +{ echo "$as_me:$LINENO: checking for dlfcn.h" >&5 +echo $ECHO_N "checking for dlfcn.h... $ECHO_C" >&6; } if test "${ac_cv_header_dlfcn_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dlfcn_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5 -$as_echo "$ac_cv_header_dlfcn_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5 +echo "${ECHO_T}$ac_cv_header_dlfcn_h" >&6; } fi if test $ac_cv_header_dlfcn_h = yes; then @@ -9642,17 +8574,17 @@ fi if test $DYNAMIC_LINKER = null; then if test "${ac_cv_header_dl_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for dl.h" >&5 -$as_echo_n "checking for dl.h... " >&6; } + { echo "$as_me:$LINENO: checking for dl.h" >&5 +echo $ECHO_N "checking for dl.h... $ECHO_C" >&6; } if test "${ac_cv_header_dl_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dl_h" >&5 -$as_echo "$ac_cv_header_dl_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_dl_h" >&5 +echo "${ECHO_T}$ac_cv_header_dl_h" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking dl.h usability" >&5 -$as_echo_n "checking dl.h usability... " >&6; } +{ echo "$as_me:$LINENO: checking dl.h usability" >&5 +echo $ECHO_N "checking dl.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9668,33 +8600,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking dl.h presence" >&5 -$as_echo_n "checking dl.h presence... " >&6; } +{ echo "$as_me:$LINENO: checking dl.h presence" >&5 +echo $ECHO_N "checking dl.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9708,64 +8639,63 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: dl.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: dl.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dl.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: dl.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: dl.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: dl.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: dl.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: dl.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dl.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: dl.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dl.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: dl.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dl.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: dl.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dl.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: dl.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dl.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: dl.h: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: dl.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: dl.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: dl.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: dl.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: dl.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dl.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: dl.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for dl.h" >&5 -$as_echo_n "checking for dl.h... " >&6; } +{ echo "$as_me:$LINENO: checking for dl.h" >&5 +echo $ECHO_N "checking for dl.h... $ECHO_C" >&6; } if test "${ac_cv_header_dl_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dl_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dl_h" >&5 -$as_echo "$ac_cv_header_dl_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_dl_h" >&5 +echo "${ECHO_T}$ac_cv_header_dl_h" >&6; } fi if test $ac_cv_header_dl_h = yes; then @@ -9776,17 +8706,17 @@ fi fi if test $DYNAMIC_LINKER = null; then if test "${ac_cv_header_windows_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for windows.h" >&5 -$as_echo_n "checking for windows.h... " >&6; } + { echo "$as_me:$LINENO: checking for windows.h" >&5 +echo $ECHO_N "checking for windows.h... $ECHO_C" >&6; } if test "${ac_cv_header_windows_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_windows_h" >&5 -$as_echo "$ac_cv_header_windows_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_windows_h" >&5 +echo "${ECHO_T}$ac_cv_header_windows_h" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking windows.h usability" >&5 -$as_echo_n "checking windows.h usability... " >&6; } +{ echo "$as_me:$LINENO: checking windows.h usability" >&5 +echo $ECHO_N "checking windows.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9802,33 +8732,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking windows.h presence" >&5 -$as_echo_n "checking windows.h presence... " >&6; } +{ echo "$as_me:$LINENO: checking windows.h presence" >&5 +echo $ECHO_N "checking windows.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9842,64 +8771,63 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: windows.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: windows.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: windows.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: windows.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: windows.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: windows.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: windows.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: windows.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: windows.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: windows.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: windows.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: windows.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: windows.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: windows.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: windows.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: windows.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: windows.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: windows.h: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: windows.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: windows.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: windows.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: windows.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: windows.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: windows.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: windows.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for windows.h" >&5 -$as_echo_n "checking for windows.h... " >&6; } +{ echo "$as_me:$LINENO: checking for windows.h" >&5 +echo $ECHO_N "checking for windows.h... $ECHO_C" >&6; } if test "${ac_cv_header_windows_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_windows_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_windows_h" >&5 -$as_echo "$ac_cv_header_windows_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_windows_h" >&5 +echo "${ECHO_T}$ac_cv_header_windows_h" >&6; } fi if test $ac_cv_header_windows_h = yes; then @@ -9910,17 +8838,17 @@ fi fi if test $DYNAMIC_LINKER = null; then if test "${ac_cv_header_dld_defs_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for dld/defs.h" >&5 -$as_echo_n "checking for dld/defs.h... " >&6; } + { echo "$as_me:$LINENO: checking for dld/defs.h" >&5 +echo $ECHO_N "checking for dld/defs.h... $ECHO_C" >&6; } if test "${ac_cv_header_dld_defs_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dld_defs_h" >&5 -$as_echo "$ac_cv_header_dld_defs_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_dld_defs_h" >&5 +echo "${ECHO_T}$ac_cv_header_dld_defs_h" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking dld/defs.h usability" >&5 -$as_echo_n "checking dld/defs.h usability... " >&6; } +{ echo "$as_me:$LINENO: checking dld/defs.h usability" >&5 +echo $ECHO_N "checking dld/defs.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9936,33 +8864,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking dld/defs.h presence" >&5 -$as_echo_n "checking dld/defs.h presence... " >&6; } +{ echo "$as_me:$LINENO: checking dld/defs.h presence" >&5 +echo $ECHO_N "checking dld/defs.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -9976,64 +8903,63 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: dld/defs.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: dld/defs.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: dld/defs.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: dld/defs.h: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: dld/defs.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: dld/defs.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: dld/defs.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: dld/defs.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: dld/defs.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dld/defs.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: dld/defs.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for dld/defs.h" >&5 -$as_echo_n "checking for dld/defs.h... " >&6; } +{ echo "$as_me:$LINENO: checking for dld/defs.h" >&5 +echo $ECHO_N "checking for dld/defs.h... $ECHO_C" >&6; } if test "${ac_cv_header_dld_defs_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dld_defs_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_dld_defs_h" >&5 -$as_echo "$ac_cv_header_dld_defs_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_dld_defs_h" >&5 +echo "${ECHO_T}$ac_cv_header_dld_defs_h" >&6; } fi if test $ac_cv_header_dld_defs_h = yes; then @@ -10045,17 +8971,17 @@ fi # NB: This is used as follows: in Source/Makefile.postamble we copy # $(DYNAMIC_LINKER)-load.h into dynamic-load.h -{ $as_echo "$as_me:$LINENO: checking for dynamic linker type" >&5 -$as_echo_n "checking for dynamic linker type... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $DYNAMIC_LINKER" >&5 -$as_echo "$DYNAMIC_LINKER" >&6; } +{ echo "$as_me:$LINENO: checking for dynamic linker type" >&5 +echo $ECHO_N "checking for dynamic linker type... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $DYNAMIC_LINKER" >&5 +echo "${ECHO_T}$DYNAMIC_LINKER" >&6; } if test $DYNAMIC_LINKER = simple; then -{ $as_echo "$as_me:$LINENO: checking for dladdr in -ldl" >&5 -$as_echo_n "checking for dladdr in -ldl... " >&6; } +{ echo "$as_me:$LINENO: checking for dladdr in -ldl" >&5 +echo $ECHO_N "checking for dladdr in -ldl... $ECHO_C" >&6; } if test "${ac_cv_lib_dl_dladdr+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" @@ -10087,36 +9013,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_dl_dladdr=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dladdr=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dladdr" >&5 -$as_echo "$ac_cv_lib_dl_dladdr" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dladdr" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dladdr" >&6; } if test $ac_cv_lib_dl_dladdr = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 @@ -10140,8 +9062,8 @@ fi #-------------------------------------------------------------------- # Check whether Objective-C /really/ works #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking whether objc really works" >&5 -$as_echo_n "checking whether objc really works... " >&6; } +{ echo "$as_me:$LINENO: checking whether objc really works" >&5 +echo $ECHO_N "checking whether objc really works... $ECHO_C" >&6; } saved_LIBS="$LIBS" saved_CPPFLAGS="$CPPFLAGS" LIBS="$LIBS $LIBOBJC" @@ -10151,7 +9073,7 @@ if test x"$objc_threaded" != x""; then fi LIBS="$LIBS $extra_LIBS" if test "${objc_works+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then objc_works=yes @@ -10170,32 +9092,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then objc_works=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) objc_works=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -10204,41 +9123,35 @@ fi fi if test $objc_works = yes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } echo "I don't seem to be able to use your Objective-C compiler to produce" echo "working binaries! Please check your Objective-C compiler installation." echo "If you are using gcc-3.x make sure that your compiler's libgcc_s and libobjc" echo "can be found by the dynamic linker - usually that requires you to play" echo "with LD_LIBRARY_PATH or /etc/ld.so.conf." echo "Please refer to your compiler installation instructions for more help." - { { $as_echo "$as_me:$LINENO: error: The Objective-C compiler does not work or is not installed properly." >&5 -$as_echo "$as_me: error: The Objective-C compiler does not work or is not installed properly." >&2;} + { { echo "$as_me:$LINENO: error: The Objective-C compiler does not work or is not installed properly." >&5 +echo "$as_me: error: The Objective-C compiler does not work or is not installed properly." >&2;} { (exit 1); exit 1; }; } fi # Don't revert any Objective-C flags as they are used in the next test #--------------------------------------------------------------------- -# See if we are using a compiler which allows us to change the class +# Guess if we are using a compiler which allows us to change the class # to be used for constant strings by using the -fconstant-string-class # option. If that is the case, we change it to NSConstantString. -# Unless we are building for the apple runtime (ie only building base -# additions library and not implementing a constant string class). #--------------------------------------------------------------------- -if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then - NX_CONST_STRING_OBJCFLAGS="" - NX_CONST_STRING_CLASS=NXConstantString -else - strclass_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString" - { $as_echo "$as_me:$LINENO: checking if the compiler supports -fconstant-string-class" >&5 -$as_echo_n "checking if the compiler supports -fconstant-string-class... " >&6; } - if test "${objc_compiler_supports_constant_string_class+set}" = set; then - $as_echo_n "(cached) " >&6 +strclass_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString" +{ echo "$as_me:$LINENO: checking if the compiler supports -fconstant-string-class" >&5 +echo $ECHO_N "checking if the compiler supports -fconstant-string-class... $ECHO_C" >&6; } +if test "${objc_compiler_supports_constant_string_class+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then objc_compiler_supports_constant_string_class=no @@ -10257,32 +9170,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then objc_compiler_supports_constant_string_class=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) objc_compiler_supports_constant_string_class=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -10290,34 +9200,18 @@ fi fi - if test $objc_compiler_supports_constant_string_class = yes; then - NX_CONST_STRING_OBJCFLAGS="-fconstant-string-class=NSConstantString" - NX_CONST_STRING_CLASS=NSConstantString - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - # Check whether --enable-nxconstantstring was given. -if test "${enable_nxconstantstring+set}" = set; then - enableval=$enable_nxconstantstring; +if test $objc_compiler_supports_constant_string_class = yes; then + NX_CONST_STRING_OBJCFLAGS="-fconstant-string-class=NSConstantString" + NX_CONST_STRING_CLASS=NSConstantString + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - enable_nxconstantstring=no -fi - - if test $enable_nxconstantstring = yes; then - NX_CONST_STRING_OBJCFLAGS="" - NX_CONST_STRING_CLASS=NXConstantString - { $as_echo "$as_me:$LINENO: WARNING: You have enabled the use of NXConstantString as the string class in gnustep-base. The objective-c runtime library typically implements its own class of the same name, so you must either enforce a link order which ensures that the gnustep-base implementation is used, or (better) you must remove the class from the runtime library!" >&5 -$as_echo "$as_me: WARNING: You have enabled the use of NXConstantString as the string class in gnustep-base. The objective-c runtime library typically implements its own class of the same name, so you must either enforce a link order which ensures that the gnustep-base implementation is used, or (better) you must remove the class from the runtime library!" >&2;} - else - { { $as_echo "$as_me:$LINENO: error: Your compiler does not appear to implement the -fconstant-string-class option needed for support of strings. Please check for a more recent version or consider using --enable-nxconstantstring" >&5 -$as_echo "$as_me: error: Your compiler does not appear to implement the -fconstant-string-class option needed for support of strings. Please check for a more recent version or consider using --enable-nxconstantstring" >&2;} - { (exit 1); exit 1; }; } - fi - fi - CPPFLAGS="$strclass_CPPFLAGS" + NX_CONST_STRING_OBJCFLAGS="" + NX_CONST_STRING_CLASS=NXConstantString + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi +CPPFLAGS="$strclass_CPPFLAGS" @@ -10330,10 +9224,10 @@ fi # Defines HAVE_LOAD_METHOD if +load methods are called before main. # Needed by NSProcessInfo.m #--------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking if +load method is executed before main" >&5 -$as_echo_n "checking if +load method is executed before main... " >&6; } +{ echo "$as_me:$LINENO: checking if +load method is executed before main" >&5 +echo $ECHO_N "checking if +load method is executed before main... $ECHO_C" >&6; } if test "${objc_load_method_worked+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then objc_load_method_worked=no @@ -10352,32 +9246,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then objc_load_method_worked=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) objc_load_method_worked=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -10391,420 +9282,116 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_LOAD_METHOD 1 _ACEOF - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi # Don't revert any Objective-C flags as they are used in the next test #-------------------------------------------------------------------- -# Check for ability to add a thread in runtime -#-------------------------------------------------------------------- - -for ac_func in objc_thread_add -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -#-------------------------------------------------------------------- -# Check for thread synchronisation support in runtime -#-------------------------------------------------------------------- - -for ac_func in objc_sync_enter -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -if test $ac_cv_func_objc_sync_enter = yes ; then - OBJCSYNC=1 -else - OBJCSYNC=0 -fi - - -#-------------------------------------------------------------------- -# Check for ObjC2 support in runtime -#-------------------------------------------------------------------- - -for ac_func in objc_setProperty -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -if test $ac_cv_func_objc_setProperty = yes ; then - OBJC2RUNTIME=1 -else - OBJC2RUNTIME=0 -fi - - -GS_NONFRAGILE=0 -GS_MIXEDABI=0 -if test "$nonfragile" = "yes"; then - saved_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $OBJCFLAGS -fobjc-nonfragile-abi -x objective-c" - { $as_echo "$as_me:$LINENO: checking for non-fragile-abi support" >&5 -$as_echo_n "checking for non-fragile-abi support... " >&6; } - if test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -#include "$srcdir/config/config.non-fragile-ivars.m" -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - non_fragile=yes -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -non_fragile=no -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - - CPPFLAGS="$saved_CPPFLAGS" - if test $non_fragile = yes; then - OBJCFLAGS="$OBJCFLAGS -fobjc-nonfragile-abi" - - GS_NONFRAGILE=1 - # Check whether --enable-mixedabi was given. -if test "${enable_mixedabi+set}" = set; then - enableval=$enable_mixedabi; -else - enable_mixedabi=yes -fi - - if test $enable_mixedabi = yes; then - GS_MIXEDABI=1 - fi - fi - { $as_echo "$as_me:$LINENO: result: $non_fragile" >&5 -$as_echo "$non_fragile" >&6; } -fi - - - - -# Don't revert any Objective-C flags as they are used in the next test - -#-------------------------------------------------------------------- +# This function needed by NSLock.m for conditioned wait # get_uninstalled_dtable used by behavior.m and objc-load.m +# Thread functions used by NSThread #-------------------------------------------------------------------- + + +for ac_func in objc_condition_timedwait objc_thread_add +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -10825,284 +9412,17 @@ fi rm -f conftest* -# Don't revert any Objective-C flags as they are used in the next test - -#-------------------------------------------------------------------- -# One of these is needed by for handling uncaught exceptions -#-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for objc_set_unexpected() in runtime" >&5 -$as_echo_n "checking for objc_set_unexpected() in runtime... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -#include "$srcdir/config/config.set_unexpected.m" -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - have_set_unexpected=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - have_set_unexpected=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -if test $have_set_unexpected = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_SET_UNEXPECTED 1 -_ACEOF - -fi -{ $as_echo "$as_me:$LINENO: result: $have_set_unexpected" >&5 -$as_echo "$have_set_unexpected" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for _objc_unexpected_exception in runtime" >&5 -$as_echo_n "checking for _objc_unexpected_exception in runtime... " >&6; } -if test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -#include "$srcdir/config/config.unexpected.m" -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - have_unexpected=yes -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -have_unexpected=no -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - -if test $have_unexpected = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_UNEXPECTED 1 -_ACEOF - -fi -{ $as_echo "$as_me:$LINENO: result: $have_unexpected" >&5 -$as_echo "$have_unexpected" >&6; } - -if test "$exceptions" = "yes"; then - if test $have_set_unexpected = no; then - if test $have_unexpected = no; then - { { $as_echo "$as_me:$LINENO: error: Your objective-c runtime library does not appear to support any mechanism to set a handler for uncaught native exceptions. Please upgrade your runtime or re-install gnustep-make without native-objc-exceptions!" >&5 -$as_echo "$as_me: error: Your objective-c runtime library does not appear to support any mechanism to set a handler for uncaught native exceptions. Please upgrade your runtime or re-install gnustep-make without native-objc-exceptions!" >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi - -# Don't revert any Objective-C flags as they are used in the next test - -#-------------------------------------------------------------------- -# Function needed by @synchronize directive -#-------------------------------------------------------------------- - -for ac_func in objc_sync_enter -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -HAVE_OBJC_SYNC_ENTER=no -if test $ac_cv_func_objc_sync_enter = yes ; then - HAVE_OBJC_SYNC_ENTER=yes -fi - - LIBS="$saved_LIBS" CPPFLAGS="$saved_CPPFLAGS" #-------------------------------------------------------------------- # Generic settings needed by NSZone.m #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for size_t" >&5 -$as_echo_n "checking for size_t... " >&6; } +{ echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } if test "${ac_cv_type_size_t+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_type_size_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof (size_t)) - return 0; - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11110,11 +9430,14 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default +typedef size_t ac__type_new_; int main () { -if (sizeof ((size_t))) - return 0; +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; ; return 0; } @@ -11125,38 +9448,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - : + ac_cv_type_size_t=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_type_size_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - + ac_cv_type_size_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 -$as_echo "$ac_cv_type_size_t" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6; } if test $ac_cv_type_size_t = yes; then : else @@ -11167,10 +9481,10 @@ _ACEOF fi -{ $as_echo "$as_me:$LINENO: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } +{ echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6; } if test "${ac_cv_c_inline+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do @@ -11193,21 +9507,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_inline=$ac_kw else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -11218,8 +9531,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in @@ -11241,10 +9554,10 @@ esac #-------------------------------------------------------------------- # Following header checks needed for bzero in Storage.m and other places #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -11271,21 +9584,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no @@ -11377,40 +9689,37 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF @@ -11421,24 +9730,22 @@ fi - -for ac_header in string.h memory.h alloca.h +for ac_header in string.h memory.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11454,33 +9761,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11494,72 +9800,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -11573,21 +9876,20 @@ done for ac_header in float.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11603,33 +9905,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11643,72 +9944,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -11727,21 +10025,20 @@ done for ac_header in sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11757,33 +10054,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11797,72 +10093,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -11871,24 +10164,22 @@ done - -for ac_header in sys/cdefs.h sys/syslimits.h sys/param.h +for ac_header in sys/syslimits.h sys/param.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11904,33 +10195,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -11944,219 +10234,84 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -# Twisted header checks for some BSDs with stupid interdependencies - -for ac_header in sys/syslimits.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if HAVE_SYS_CDEFS_H - #include - #endif - #include - - -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in sys/param.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#if HAVE_SYS_CDEFS_H - #include - #endif - #if HAVE_SYS_SYSLIMITS_H - #include - #endif - - -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done +# Twisted header check for NetBSD for ac_header in sys/mount.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -12164,10 +10319,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#if HAVE_SYS_CDEFS_H - #include - #endif - #if HAVE_SYS_SYSLIMITS_H +#if HAVE_SYS_SYSLIMITS_H #include #endif #if HAVE_SYS_PARAM_H @@ -12183,21 +10335,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" @@ -12205,14 +10356,12 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -12225,21 +10374,20 @@ done for ac_header in sys/types.h windows.h locale.h langinfo.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12255,33 +10403,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12295,72 +10442,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -12369,10 +10513,10 @@ done saved_LIBS="$LIBS" -{ $as_echo "$as_me:$LINENO: checking for main in -lm" >&5 -$as_echo_n "checking for main in -lm... " >&6; } +{ echo "$as_me:$LINENO: checking for main in -lm" >&5 +echo $ECHO_N "checking for main in -lm... $ECHO_C" >&6; } if test "${ac_cv_lib_m_main+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" @@ -12398,36 +10542,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_m_main=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_m_main=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_main" >&5 -$as_echo "$ac_cv_lib_m_main" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_main" >&5 +echo "${ECHO_T}$ac_cv_lib_m_main" >&6; } if test $ac_cv_lib_m_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 @@ -12448,18 +10588,13 @@ fi - - - - - -for ac_func in statvfs link symlink readlink geteuid getlogin getpwnam getpwnam_r getpwuid getpwuid_r getgrgid getgrgid_r getgrnam getgrnam_r rint getopt +for ac_func in statvfs link symlink readlink geteuid getlogin getpwnam getpwuid getgrgid rint getopt do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -12512,41 +10647,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -12565,21 +10694,20 @@ LIBS="$saved_LIBS" for ac_header in time.h sys/time.h tzfile.h sys/rusage.h ucbinclude/sys/resource.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12595,33 +10723,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12635,72 +10762,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -12712,11 +10836,11 @@ done for ac_func in time ctime tzset do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -12769,41 +10893,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -12840,21 +10958,20 @@ fi for ac_header in sys/socket.h netinet/in.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12870,33 +10987,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12910,213 +11026,96 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done -{ $as_echo "$as_me:$LINENO: checking for socklen_t" >&5 -$as_echo_n "checking for socklen_t... " >&6; } -if test "${ac_cv_type_socklen_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_socklen_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof (socklen_t)) - return 0; - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof ((socklen_t))) - return 0; - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_socklen_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 -$as_echo "$ac_cv_type_socklen_t" >&6; } -if test $ac_cv_type_socklen_t = yes; then - -cat >>confdefs.h <<_ACEOF -#define HAVE_SOCKLEN_T 1 -_ACEOF - - -fi - #-------------------------------------------------------------------- # These headers/functions needed for stacktrace in NSException.m #-------------------------------------------------------------------- -PASS_ARG=no -# Check whether --enable-bfd was given. -if test "${enable_bfd+set}" = set; then - enableval=$enable_bfd; -else - enable_bfd=$PASS_ARG -fi - - -if test $enable_bfd = yes; then for ac_header in bfd.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13132,33 +11131,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13172,72 +11170,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -13245,10 +11240,10 @@ fi done -{ $as_echo "$as_me:$LINENO: checking for dyn_string_append in -liberty" >&5 -$as_echo_n "checking for dyn_string_append in -liberty... " >&6; } +{ echo "$as_me:$LINENO: checking for dyn_string_append in -liberty" >&5 +echo $ECHO_N "checking for dyn_string_append in -liberty... $ECHO_C" >&6; } if test "${ac_cv_lib_iberty_dyn_string_append+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-liberty $LIBS" @@ -13280,36 +11275,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_iberty_dyn_string_append=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_iberty_dyn_string_append=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_iberty_dyn_string_append" >&5 -$as_echo "$ac_cv_lib_iberty_dyn_string_append" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_iberty_dyn_string_append" >&5 +echo "${ECHO_T}$ac_cv_lib_iberty_dyn_string_append" >&6; } if test $ac_cv_lib_iberty_dyn_string_append = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBIBERTY 1 @@ -13320,10 +11311,10 @@ _ACEOF fi -{ $as_echo "$as_me:$LINENO: checking for bfd_openr in -lbfd" >&5 -$as_echo_n "checking for bfd_openr in -lbfd... " >&6; } +{ echo "$as_me:$LINENO: checking for bfd_openr in -lbfd" >&5 +echo $ECHO_N "checking for bfd_openr in -lbfd... $ECHO_C" >&6; } if test "${ac_cv_lib_bfd_bfd_openr+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbfd $LIBS" @@ -13355,36 +11346,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_bfd_bfd_openr=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_bfd_bfd_openr=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_bfd_bfd_openr" >&5 -$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_bfd_bfd_openr" >&5 +echo "${ECHO_T}$ac_cv_lib_bfd_bfd_openr" >&6; } if test $ac_cv_lib_bfd_bfd_openr = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBBFD 1 @@ -13394,253 +11381,6 @@ _ACEOF fi -else - -for ac_header in execinfo.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_func in backtrace -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -fi #-------------------------------------------------------------------- # These headers/functions needed by NSLog.m @@ -13648,21 +11388,20 @@ fi for ac_header in syslog.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13678,33 +11417,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13718,72 +11456,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -13793,11 +11528,11 @@ done for ac_func in syslog do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -13850,41 +11585,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -13897,21 +11626,20 @@ done for ac_header in poll.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13927,33 +11655,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13967,72 +11694,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -14042,11 +11766,11 @@ done for ac_func in poll do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -14099,41 +11823,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -14142,8 +11860,8 @@ done have_poll=no if test $ac_cv_header_poll_h = yes; then have_poll=yes - { $as_echo "$as_me:$LINENO: checking for poll emulation" >&5 -$as_echo_n "checking for poll emulation... " >&6; } + { echo "$as_me:$LINENO: checking for poll emulation" >&5 +echo $ECHO_N "checking for poll emulation... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -14159,100 +11877,39 @@ fi rm -f conftest* if test $have_poll = yes; then - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - { $as_echo "$as_me:$LINENO: checking if poll supports devices" >&5 -$as_echo_n "checking if poll supports devices... " >&6; } - if test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include "$srcdir/config/config.poll-dev.c" -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -have_poll=no -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - - if test $have_poll = yes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_POLL_F 1 _ACEOF - else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - fi else - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } fi fi #-------------------------------------------------------------------- -# Check for pthread.h +# Check for pthread.h (only when building on Darwin machines) #-------------------------------------------------------------------- for ac_header in pthread.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -14268,33 +11925,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -14308,1859 +11964,78 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done +HAVE_PTHREAD_H=no if test $ac_cv_header_pthread_h = yes ; then - # The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of pthread_mutex_t" >&5 -$as_echo_n "checking size of pthread_mutex_t... " >&6; } -if test "${ac_cv_sizeof_pthread_mutex_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_mutex_t))) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_mutex_t))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_mutex_t))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_mutex_t))) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo= ac_hi= -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_mutex_t))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr '(' $ac_mid ')' + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_pthread_mutex_t=$ac_lo;; -'') if test "$ac_cv_type_pthread_mutex_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (pthread_mutex_t) -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (pthread_mutex_t) -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_sizeof_pthread_mutex_t=0 - fi ;; -esac -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -static long int longval () { return (long int) (sizeof (pthread_mutex_t)); } -static unsigned long int ulongval () { return (long int) (sizeof (pthread_mutex_t)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (((long int) (sizeof (pthread_mutex_t))) < 0) - { - long int i = longval (); - if (i != ((long int) (sizeof (pthread_mutex_t)))) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (pthread_mutex_t)))) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_pthread_mutex_t=`cat conftest.val` -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -if test "$ac_cv_type_pthread_mutex_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (pthread_mutex_t) -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (pthread_mutex_t) -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_sizeof_pthread_mutex_t=0 - fi -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.val -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_pthread_mutex_t" >&5 -$as_echo "$ac_cv_sizeof_pthread_mutex_t" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_PTHREAD_MUTEX_T $ac_cv_sizeof_pthread_mutex_t -_ACEOF - - - GS_SIZEOF_MUTEX_T=$ac_cv_sizeof_pthread_mutex_t - if test $ac_cv_sizeof_pthread_mutex_t = 0 ; then - { { $as_echo "$as_me:$LINENO: error: Unable to find size of pthread_mutex_t (required)." >&5 -$as_echo "$as_me: error: Unable to find size of pthread_mutex_t (required)." >&2;} - { (exit 1); exit 1; }; } - fi - - # The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:$LINENO: checking size of pthread_cond_t" >&5 -$as_echo_n "checking size of pthread_cond_t... " >&6; } -if test "${ac_cv_sizeof_pthread_cond_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_cond_t))) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_cond_t))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_cond_t))) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_cond_t))) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo= ac_hi= -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -int -main () -{ -static int test_array [1 - 2 * !(((long int) (sizeof (pthread_cond_t))) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr '(' $ac_mid ')' + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_pthread_cond_t=$ac_lo;; -'') if test "$ac_cv_type_pthread_cond_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (pthread_cond_t) -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (pthread_cond_t) -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_sizeof_pthread_cond_t=0 - fi ;; -esac -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -static long int longval () { return (long int) (sizeof (pthread_cond_t)); } -static unsigned long int ulongval () { return (long int) (sizeof (pthread_cond_t)); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (((long int) (sizeof (pthread_cond_t))) < 0) - { - long int i = longval (); - if (i != ((long int) (sizeof (pthread_cond_t)))) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ((long int) (sizeof (pthread_cond_t)))) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_sizeof_pthread_cond_t=`cat conftest.val` -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -if test "$ac_cv_type_pthread_cond_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (pthread_cond_t) -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute sizeof (pthread_cond_t) -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_sizeof_pthread_cond_t=0 - fi -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.val -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_pthread_cond_t" >&5 -$as_echo "$ac_cv_sizeof_pthread_cond_t" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_PTHREAD_COND_T $ac_cv_sizeof_pthread_cond_t -_ACEOF - - - if test $ac_cv_sizeof_pthread_cond_t = 0 ; then - { { $as_echo "$as_me:$LINENO: error: Unable to find size of pthread_cond_t (required)." >&5 -$as_echo "$as_me: error: Unable to find size of pthread_cond_t (required)." >&2;} - { (exit 1); exit 1; }; } - fi - GS_SIZEOF_COND_T=$ac_cv_sizeof_pthread_cond_t - - # The cast to long int works around a bug in the HP C Compiler, -# see AC_CHECK_SIZEOF for more information. -{ $as_echo "$as_me:$LINENO: checking alignment of pthread_mutex_t" >&5 -$as_echo_n "checking alignment of pthread_mutex_t... " >&6; } -if test "${ac_cv_alignof_pthread_mutex_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_mutex_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_mutex_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_mutex_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_mutex_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo= ac_hi= -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_mutex_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr '(' $ac_mid ')' + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_alignof_pthread_mutex_t=$ac_lo;; -'') if test "$ac_cv_type_pthread_mutex_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute alignment of pthread_mutex_t -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute alignment of pthread_mutex_t -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_alignof_pthread_mutex_t=0 - fi ;; -esac -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_mutex_t y; } ac__type_alignof_; -static long int longval () { return (long int) offsetof (ac__type_alignof_, y); } -static unsigned long int ulongval () { return (long int) offsetof (ac__type_alignof_, y); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (((long int) offsetof (ac__type_alignof_, y)) < 0) - { - long int i = longval (); - if (i != ((long int) offsetof (ac__type_alignof_, y))) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ((long int) offsetof (ac__type_alignof_, y))) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_alignof_pthread_mutex_t=`cat conftest.val` -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -if test "$ac_cv_type_pthread_mutex_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute alignment of pthread_mutex_t -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute alignment of pthread_mutex_t -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_alignof_pthread_mutex_t=0 - fi -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.val -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_alignof_pthread_mutex_t" >&5 -$as_echo "$ac_cv_alignof_pthread_mutex_t" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define ALIGNOF_PTHREAD_MUTEX_T $ac_cv_alignof_pthread_mutex_t -_ACEOF - - - GS_ALIGNOF_MUTEX_T=$ac_cv_alignof_pthread_mutex_t - if test $ac_cv_alignof_pthread_mutex_t = 0 ; then - { { $as_echo "$as_me:$LINENO: error: Unable to find align of pthread_mutex_t (required)." >&5 -$as_echo "$as_me: error: Unable to find align of pthread_mutex_t (required)." >&2;} - { (exit 1); exit 1; }; } - fi - - # The cast to long int works around a bug in the HP C Compiler, -# see AC_CHECK_SIZEOF for more information. -{ $as_echo "$as_me:$LINENO: checking alignment of pthread_cond_t" >&5 -$as_echo_n "checking alignment of pthread_cond_t... " >&6; } -if test "${ac_cv_alignof_pthread_cond_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_cond_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_cond_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_cond_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_cond_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_lo=$ac_mid; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo= ac_hi= -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_cond_t y; } ac__type_alignof_; -int -main () -{ -static int test_array [1 - 2 * !(((long int) offsetof (ac__type_alignof_, y)) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_hi=$ac_mid -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_lo=`expr '(' $ac_mid ')' + 1` -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_alignof_pthread_cond_t=$ac_lo;; -'') if test "$ac_cv_type_pthread_cond_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute alignment of pthread_cond_t -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute alignment of pthread_cond_t -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_alignof_pthread_cond_t=0 - fi ;; -esac -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include - -#ifndef offsetof -# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0) -#endif -typedef struct { char x; pthread_cond_t y; } ac__type_alignof_; -static long int longval () { return (long int) offsetof (ac__type_alignof_, y); } -static unsigned long int ulongval () { return (long int) offsetof (ac__type_alignof_, y); } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (((long int) offsetof (ac__type_alignof_, y)) < 0) - { - long int i = longval (); - if (i != ((long int) offsetof (ac__type_alignof_, y))) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ((long int) offsetof (ac__type_alignof_, y))) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_alignof_pthread_cond_t=`cat conftest.val` -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -if test "$ac_cv_type_pthread_cond_t" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot compute alignment of pthread_cond_t -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute alignment of pthread_cond_t -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } - else - ac_cv_alignof_pthread_cond_t=0 - fi -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.val -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_alignof_pthread_cond_t" >&5 -$as_echo "$ac_cv_alignof_pthread_cond_t" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define ALIGNOF_PTHREAD_COND_T $ac_cv_alignof_pthread_cond_t -_ACEOF - - - if test $ac_cv_alignof_pthread_cond_t = 0 ; then - { { $as_echo "$as_me:$LINENO: error: Unable to find align of pthread_cond_t (required)." >&5 -$as_echo "$as_me: error: Unable to find align of pthread_cond_t (required)." >&2;} - { (exit 1); exit 1; }; } - fi - GS_ALIGNOF_COND_T=$ac_cv_alignof_pthread_cond_t - -else - { { $as_echo "$as_me:$LINENO: error: Unable to find pthread.h (needed for thread support)." >&5 -$as_echo "$as_me: error: Unable to find pthread.h (needed for thread support)." >&2;} - { (exit 1); exit 1; }; } -fi -{ $as_echo "$as_me:$LINENO: checking for pthread_join in -lpthread" >&5 -$as_echo_n "checking for pthread_join in -lpthread... " >&6; } -if test "${ac_cv_lib_pthread_pthread_join+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_join (); -int -main () -{ -return pthread_join (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_pthread_pthread_join=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pthread_pthread_join=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_join" >&5 -$as_echo "$ac_cv_lib_pthread_pthread_join" >&6; } -if test $ac_cv_lib_pthread_pthread_join = yes; then - pthread_ok=yes -else - pthread_ok=no -fi - -ismingw=no -case "$target_os" in - mingw*) ismingw=yes;; -esac -if test $pthread_ok = yes ; then - LIBS="$LIBS -lpthread" -else - if test $ismingw = yes ; then - { $as_echo "$as_me:$LINENO: checking for pthread_join in -lpthreadGC2" >&5 -$as_echo_n "checking for pthread_join in -lpthreadGC2... " >&6; } -if test "${ac_cv_lib_pthreadGC2_pthread_join+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthreadGC2 $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_join (); -int -main () -{ -return pthread_join (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_pthreadGC2_pthread_join=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pthreadGC2_pthread_join=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pthreadGC2_pthread_join" >&5 -$as_echo "$ac_cv_lib_pthreadGC2_pthread_join" >&6; } -if test $ac_cv_lib_pthreadGC2_pthread_join = yes; then - pthread_ok=yes -else - pthread_ok=no -fi - - if test $pthread_ok = yes ; then - LIBS="$LIBS -lpthreadGC2" - fi - fi -fi -if test $pthread_ok = no ; then - { { $as_echo "$as_me:$LINENO: error: Unable to find pthread library (needed for thread support)." >&5 -$as_echo "$as_me: error: Unable to find pthread library (needed for thread support)." >&2;} - { (exit 1); exit 1; }; } -fi - -# Typically need librt on Solaris for sched_yield - -{ $as_echo "$as_me:$LINENO: checking for sched_yield in -lrt" >&5 -$as_echo_n "checking for sched_yield in -lrt... " >&6; } -if test "${ac_cv_lib_rt_sched_yield+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lrt $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sched_yield (); -int -main () -{ -return sched_yield (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_rt_sched_yield=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_rt_sched_yield=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_rt_sched_yield" >&5 -$as_echo "$ac_cv_lib_rt_sched_yield" >&6; } -if test $ac_cv_lib_rt_sched_yield = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBRT 1 -_ACEOF - - LIBS="-lrt $LIBS" - + HAVE_PTHREAD_H=yes fi @@ -16171,11 +12046,11 @@ fi for ac_func in vsprintf vasprintf do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -16228,41 +12103,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -16286,32 +12155,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then VSPRINTF_RETURNS_LENGTH=1 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) VSPRINTF_RETURNS_LENGTH=0 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -16340,32 +12206,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then VASPRINTF_RETURNS_LENGTH=1 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) VASPRINTF_RETURNS_LENGTH=0 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -16383,11 +12246,11 @@ fi for ac_func in getcwd do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -16440,41 +12303,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -16487,11 +12344,11 @@ done ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 -$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -16517,21 +12374,20 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" @@ -16539,14 +12395,12 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break @@ -16555,10 +12409,10 @@ fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then - { $as_echo "$as_me:$LINENO: checking for library containing opendir" >&5 -$as_echo_n "checking for library containing opendir... " >&6; } + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } if test "${ac_cv_search_opendir+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF @@ -16596,30 +12450,26 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then @@ -16634,8 +12484,8 @@ fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 -$as_echo "$ac_cv_search_opendir" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" @@ -16643,10 +12493,10 @@ if test "$ac_res" != no; then fi else - { $as_echo "$as_me:$LINENO: checking for library containing opendir" >&5 -$as_echo_n "checking for library containing opendir... " >&6; } + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } if test "${ac_cv_search_opendir+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF @@ -16684,30 +12534,26 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then @@ -16722,8 +12568,8 @@ fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 -$as_echo "$ac_cv_search_opendir" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" @@ -16739,21 +12585,20 @@ fi for ac_header in getopt.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -16769,33 +12614,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -16809,72 +12653,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -16886,14 +12727,13 @@ done # This function needed by NSPage.m #-------------------------------------------------------------------- - -for ac_func in posix_memalign valloc +for ac_func in valloc do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -16946,41 +12786,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -16993,11 +12827,11 @@ done for ac_func in times do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -17050,41 +12884,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -17092,16 +12920,16 @@ done #-------------------------------------------------------------------- -# These functions needed by NSData.m and GSFFIInvocation.m +# These functions needed by NSData.m #-------------------------------------------------------------------- for ac_func in mkstemp do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -17154,41 +12982,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -17197,11 +13019,11 @@ done for ac_func in shmctl do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -17254,41 +13076,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -17297,11 +13113,11 @@ done for ac_func in mmap do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -17354,306 +13170,54 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done -for ac_func in mprotect -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -for ac_header in sys/mman.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - #-------------------------------------------------------------------- # These functions needed by NSTask.m #-------------------------------------------------------------------- - -for ac_func in killpg setpgrp setpgid setsid +for ac_func in killpg setpgrp setpgid do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -17706,55 +13270,48 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done -if test "x$ac_cv_func_setpgrp" = xyes; then - { $as_echo "$as_me:$LINENO: checking whether setpgrp takes no argument" >&5 -$as_echo_n "checking whether setpgrp takes no argument... " >&6; } +{ echo "$as_me:$LINENO: checking whether setpgrp takes no argument" >&5 +echo $ECHO_N "checking whether setpgrp takes no argument... $ECHO_C" >&6; } if test "${ac_cv_func_setpgrp_void+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: cannot check setpgrp when cross compiling" >&5 -$as_echo "$as_me: error: cannot check setpgrp when cross compiling" >&2;} + { { echo "$as_me:$LINENO: error: cannot check setpgrp when cross compiling" >&5 +echo "$as_me: error: cannot check setpgrp when cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF @@ -17781,39 +13338,36 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_setpgrp_void=no else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_setpgrp_void=yes fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_setpgrp_void" >&5 -$as_echo "$ac_cv_func_setpgrp_void" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_func_setpgrp_void" >&5 +echo "${ECHO_T}$ac_cv_func_setpgrp_void" >&6; } if test $ac_cv_func_setpgrp_void = yes; then cat >>confdefs.h <<\_ACEOF @@ -17822,7 +13376,6 @@ _ACEOF fi -fi HAVE_PTS_STREAM_MODULES=0 case "${target}" in @@ -17854,24 +13407,22 @@ _ACEOF - -for ac_header in libc.h limits.h malloc.h memory.h string.h signal.h stdlib.h sys/signal.h sys/wait.h sys/file.h sys/fcntl.h sys/ioctl.h sys/stropts.h unistd.h utime.h stdint.h inttypes.h sys/inttypes.h +for ac_header in libc.h limits.h malloc.h memory.h string.h signal.h sys/signal.h sys/wait.h sys/file.h sys/fcntl.h sys/ioctl.h sys/stropts.h unistd.h utime.h stdint.h inttypes.h sys/inttypes.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -17887,33 +13438,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -17927,72 +13477,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -18049,95 +13596,17 @@ fi #-------------------------------------------------------------------- # These used by GSFileHandle.m and distributed objects -# On some systems we need -lnsl ... so check for that first. #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for inet_ntop in -lnsl" >&5 -$as_echo_n "checking for inet_ntop in -lnsl... " >&6; } -if test "${ac_cv_lib_nsl_inet_ntop+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lnsl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char inet_ntop (); -int -main () -{ -return inet_ntop (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_nsl_inet_ntop=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_nsl_inet_ntop=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_inet_ntop" >&5 -$as_echo "$ac_cv_lib_nsl_inet_ntop" >&6; } -if test $ac_cv_lib_nsl_inet_ntop = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBNSL 1 -_ACEOF - - LIBS="-lnsl $LIBS" - -fi - - - - -for ac_func in gethostbyaddr_r inet_aton inet_pton inet_ntop sigaction +for ac_func in inet_aton inet_pton sigaction do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -18190,41 +13659,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -18234,21 +13697,20 @@ USE_ZLIB=0 for ac_header in zlib.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -18264,33 +13726,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -18304,72 +13765,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -18377,10 +13835,10 @@ fi done if test $ac_cv_header_zlib_h = yes; then - { $as_echo "$as_me:$LINENO: checking for gzseek in -lz" >&5 -$as_echo_n "checking for gzseek in -lz... " >&6; } + { echo "$as_me:$LINENO: checking for gzseek in -lz" >&5 +echo $ECHO_N "checking for gzseek in -lz... $ECHO_C" >&6; } if test "${ac_cv_lib_z_gzseek+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" @@ -18412,36 +13870,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_z_gzseek=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_z_gzseek=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzseek" >&5 -$as_echo "$ac_cv_lib_z_gzseek" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzseek" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzseek" >&6; } if test $ac_cv_lib_z_gzseek = yes; then zlib_ok=yes else @@ -18461,12 +13915,6 @@ if test $ac_cv_func_inet_pton = yes ; then fi -HAVE_INET_NTOP=no -if test $ac_cv_func_inet_ntop = yes ; then - HAVE_INET_NTOP=yes -fi - - #-------------------------------------------------------------------- # One of these function needed by NSThread.m #-------------------------------------------------------------------- @@ -18474,11 +13922,11 @@ fi for ac_func in nanosleep usleep do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -18531,41 +13979,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -18573,161 +14015,16 @@ done #-------------------------------------------------------------------- -# For setting thread stack size +# This function needed by NSDebug.m and NSProcessInfo.m #-------------------------------------------------------------------- -for ac_header in sys/resource.h +for ac_func in strerror do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_func in setrlimit -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -18780,250 +14077,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -#-------------------------------------------------------------------- -# One of these functions needed by NSDebug.m and NSProcessInfo.m -#-------------------------------------------------------------------- - - -for ac_func in strerror_r strerror -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -#-------------------------------------------------------------------- -# Needed by NSDebug.m -#-------------------------------------------------------------------- - -for ac_func in sigsetjmp -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -19033,46 +14115,11 @@ done #-------------------------------------------------------------------- # This type needed by GSFormat #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for uintmax_t" >&5 -$as_echo_n "checking for uintmax_t... " >&6; } +{ echo "$as_me:$LINENO: checking for uintmax_t" >&5 +echo $ECHO_N "checking for uintmax_t... $ECHO_C" >&6; } if test "${ac_cv_type_uintmax_t+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_type_uintmax_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof (uintmax_t)) - return 0; - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -19080,11 +14127,14 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default +typedef uintmax_t ac__type_new_; int main () { -if (sizeof ((uintmax_t))) - return 0; +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; ; return 0; } @@ -19095,38 +14145,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - : + ac_cv_type_uintmax_t=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_type_uintmax_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - + ac_cv_type_uintmax_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_uintmax_t" >&5 -$as_echo "$ac_cv_type_uintmax_t" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_type_uintmax_t" >&5 +echo "${ECHO_T}$ac_cv_type_uintmax_t" >&6; } if test $ac_cv_type_uintmax_t = yes; then cat >>confdefs.h <<_ACEOF @@ -19137,23 +14178,153 @@ _ACEOF fi +{ echo "$as_me:$LINENO: checking whether precompiler handles LONG_LONG_MAX" >&5 +echo $ECHO_N "checking whether precompiler handles LONG_LONG_MAX... $ECHO_C" >&6; } +# We need to define _GNU_SOURCE for some systems to enable LONG_LONG_MAX +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + #ifdef HAVE_STDINT_H + #include + #endif + #include + #if defined(LONG_LONG_MAX) + #if LONG_MAX == LONG_LONG_MAX + #error long max equals long long max + #endif + #else + #error long long max not defined + #endif + +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + llmax=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + llmax=no +fi + +rm -f conftest.err conftest.$ac_ext +if test $llmax = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HANDLE_LONG_LONG_MAX 1 +_ACEOF + +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + +# +# Solaris and *BSD use LLONG_MAX instead +# +{ echo "$as_me:$LINENO: checking whether we have LLONG_MAX" >&5 +echo $ECHO_N "checking whether we have LLONG_MAX... $ECHO_C" >&6; } +# We need to use the same header environment as the test above because we +# will be using one or the other set of constants. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + #ifdef HAVE_STDINT_H + #include + #endif + #include + #if defined(LLONG_MAX) + #if LONG_MAX == LLONG_MAX + #error long max equals long long max + #endif + #else + #error llong max not defined + #endif + +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + llmax=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + llmax=no +fi + +rm -f conftest.err conftest.$ac_ext + +if test $llmax = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HANDLE_LLONG_MAX 1 +_ACEOF + +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + for ac_header in wchar.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -19169,33 +14340,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -19209,72 +14379,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -19285,8 +14452,8 @@ done #-------------------------------------------------------------------- # Check if short and int values need to be word aligned #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking short/int needs to be word aligned" >&5 -$as_echo_n "checking short/int needs to be word aligned... " >&6; } +{ echo "$as_me:$LINENO: checking short/int needs to be word aligned" >&5 +echo $ECHO_N "checking short/int needs to be word aligned... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then NEED_WORD_ALIGNMENT=1 else @@ -19304,32 +14471,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then NEED_WORD_ALIGNMENT=0 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) NEED_WORD_ALIGNMENT=1 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -19340,120 +14504,20 @@ cat >>confdefs.h <<_ACEOF _ACEOF if test $NEED_WORD_ALIGNMENT = 1; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi #-------------------------------------------------------------------- -# This needed by NSString for handling of %@ printf directive. +# This function needed by NSString for handling of %@ printf directive. #-------------------------------------------------------------------- - -for ac_func in register_printf_specifier -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -{ $as_echo "$as_me:$LINENO: checking for register_printf_function" >&5 -$as_echo_n "checking for register_printf_function... " >&6; } +{ echo "$as_me:$LINENO: checking for register_printf_function" >&5 +echo $ECHO_N "checking for register_printf_function... $ECHO_C" >&6; } if test "${ac_cv_func_register_printf_function+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -19506,35 +14570,31 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_register_printf_function=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_register_printf_function=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_register_printf_function" >&5 -$as_echo "$ac_cv_func_register_printf_function" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_func_register_printf_function" >&5 +echo "${ECHO_T}$ac_cv_func_register_printf_function" >&6; } if test $ac_cv_func_register_printf_function = yes; then register_printf=1 else @@ -19559,32 +14619,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then working_register_printf=1 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) working_register_printf=0 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -19595,75 +14652,20 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_REGISTER_PRINTF_FUNCTION 1 _ACEOF - if test "$cross_compiling" = yes; then - wide_register_printf=1 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include "$srcdir/config/config.wprintf.c" -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - wide_register_printf=1 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -wide_register_printf=0 -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - - if test $wide_register_printf = 1; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_WIDE_PRINTF_FUNCTION 1 -_ACEOF - - fi fi fi - #-------------------------------------------------------------------- # This function needed by NSString. #-------------------------------------------------------------------- for ac_func in realpath do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -19716,41 +14718,35 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -19761,10 +14757,10 @@ done # Check if the C Library defines extern char *program_invocation_name # Used in critical cases by NSProcessInfo.m #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking program_invocation_name in C Library" >&5 -$as_echo_n "checking program_invocation_name in C Library... " >&6; } +{ echo "$as_me:$LINENO: checking program_invocation_name in C Library" >&5 +echo $ECHO_N "checking program_invocation_name in C Library... $ECHO_C" >&6; } if test "${program_invocation_name_worked+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then program_invocation_name_worked=no @@ -19791,32 +14787,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then program_invocation_name_worked=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) program_invocation_name_worked=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -19829,11 +14822,11 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_PROGRAM_INVOCATION_NAME 1 _ACEOF - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi #-------------------------------------------------------------------- @@ -19842,21 +14835,20 @@ fi for ac_header in sys/utsname.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -19872,33 +14864,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -19912,72 +14903,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -19985,255 +14973,6 @@ fi done -#-------------------------------------------------------------------- -# Check for sysctlbyname used by NSProcessInfo.m -#-------------------------------------------------------------------- - -for ac_header in sys/sysctl.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_func in sysctlbyname -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - #-------------------------------------------------------------------- # Defines HAVE_PROCFS if the kernel supports the /proc filesystem. # Needed by NSProcessInfo.m @@ -20241,21 +14980,20 @@ done for ac_header in procfs.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -20271,33 +15009,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -20311,72 +15048,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -20391,17 +15125,17 @@ else fi - { $as_echo "$as_me:$LINENO: checking kernel support for /proc filesystem" >&5 -$as_echo_n "checking kernel support for /proc filesystem... " >&6; } + { echo "$as_me:$LINENO: checking kernel support for /proc filesystem" >&5 +echo $ECHO_N "checking kernel support for /proc filesystem... $ECHO_C" >&6; } if test "${ac_cv_sys_procfs+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$enable_procfs" = yes; then # Suggested change for the following line was # if test -d /proc/0; then # but it doesn't work on my linux - /proc/0 does not exist, but /proc # works fine - if grep 'proc' /proc/mounts >/dev/null 2>/dev/null; then + if (mount | grep 'proc' >/dev/null 2>/dev/null); then ac_cv_sys_procfs=yes else ac_cv_sys_procfs=no @@ -20414,18 +15148,15 @@ else cygwin*) ac_cv_sys_procfs=yes;; esac elif test "$enable_procfs" = cross; then - ac_cv_sys_procfs=no + { echo "$as_me:$LINENO: WARNING: Pass --enable-procfs argument to enable use of /proc filesystem." >&5 +echo "$as_me: WARNING: Pass --enable-procfs argument to enable use of /proc filesystem." >&2;} else ac_cv_sys_procfs=no fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_procfs" >&5 -$as_echo "$ac_cv_sys_procfs" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sys_procfs" >&5 +echo "${ECHO_T}$ac_cv_sys_procfs" >&6; } - if test "$enable_procfs" = cross; then - { $as_echo "$as_me:$LINENO: WARNING: Cross-compiling: Pass --enable-procfs argument to enable use of /proc filesystem." >&5 -$as_echo "$as_me: WARNING: Cross-compiling: Pass --enable-procfs argument to enable use of /proc filesystem." >&2;} - fi if test $ac_cv_sys_procfs = yes; then cat >>confdefs.h <<\_ACEOF @@ -20443,10 +15174,10 @@ else fi - { $as_echo "$as_me:$LINENO: checking support for /proc psinfo struct" >&5 -$as_echo_n "checking support for /proc psinfo struct... " >&6; } + { echo "$as_me:$LINENO: checking support for /proc psinfo struct" >&5 +echo $ECHO_N "checking support for /proc psinfo struct... $ECHO_C" >&6; } if test "${ac_cv_sys_procfs_psinfo+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$enable_procfs_psinfo" = yes; then if test "$cross_compiling" = yes; then @@ -20466,49 +15197,43 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sys_procfs_psinfo=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_sys_procfs_psinfo=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi elif test "$enable_procfs" = cross; then - ac_cv_sys_procfs_psinfo=no + { echo "$as_me:$LINENO: WARNING: Pass --enable-procfs-psinfo argument to enable use of /proc psinfo information." >&5 +echo "$as_me: WARNING: Pass --enable-procfs-psinfo argument to enable use of /proc psinfo information." >&2;} else ac_cv_sys_procfs_psinfo=no fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_procfs_psinfo" >&5 -$as_echo "$ac_cv_sys_procfs_psinfo" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sys_procfs_psinfo" >&5 +echo "${ECHO_T}$ac_cv_sys_procfs_psinfo" >&6; } - if test "$enable_procfs" = cross; then - { $as_echo "$as_me:$LINENO: WARNING: Cross-compiling: Pass --enable-procfs-psinfo argument to enable use of /proc psinfo information." >&5 -$as_echo "$as_me: WARNING: Cross-compiling: Pass --enable-procfs-psinfo argument to enable use of /proc psinfo information." >&2;} - fi if test $ac_cv_sys_procfs_psinfo = yes; then cat >>confdefs.h <<\_ACEOF @@ -20520,10 +15245,10 @@ _ACEOF - { $as_echo "$as_me:$LINENO: checking link to exe of process in /proc" >&5 -$as_echo_n "checking link to exe of process in /proc... " >&6; } + { echo "$as_me:$LINENO: checking link to exe of process in /proc" >&5 +echo $ECHO_N "checking link to exe of process in /proc... $ECHO_C" >&6; } if test "${ac_cv_sys_procfs_exe_link+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_sys_procfs" = yes; then # Linux 2.2.x and up @@ -20539,8 +15264,8 @@ else ac_cv_sys_procfs_exe_link=no fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_procfs_exe_link" >&5 -$as_echo "$ac_cv_sys_procfs_exe_link" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_sys_procfs_exe_link" >&5 +echo "${ECHO_T}$ac_cv_sys_procfs_exe_link" >&6; } if test "$ac_cv_sys_procfs_exe_link" != no; then @@ -20554,8 +15279,8 @@ _ACEOF #-------------------------------------------------------------------- # Check if /proc/$$/cmdline terminates the last argument with a nul #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking /proc/$$/cmdline terminated by nul" >&5 -$as_echo_n "checking /proc/$$/cmdline terminated by nul... " >&6; } +{ echo "$as_me:$LINENO: checking /proc/$$/cmdline terminated by nul" >&5 +echo $ECHO_N "checking /proc/$$/cmdline terminated by nul... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then CMDLINE_TERMINATED=0 else @@ -20573,32 +15298,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then CMDLINE_TERMINATED=1 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) CMDLINE_TERMINATED=0 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -20609,11 +15331,11 @@ cat >>confdefs.h <<_ACEOF _ACEOF if test $CMDLINE_TERMINATED = 1; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi #-------------------------------------------------------------------- @@ -20622,10 +15344,10 @@ fi have_kvm_env=0 save_LIBS="$LIBS" -{ $as_echo "$as_me:$LINENO: checking for kvm_getenvv in -lkvm" >&5 -$as_echo_n "checking for kvm_getenvv in -lkvm... " >&6; } +{ echo "$as_me:$LINENO: checking for kvm_getenvv in -lkvm" >&5 +echo $ECHO_N "checking for kvm_getenvv in -lkvm... $ECHO_C" >&6; } if test "${ac_cv_lib_kvm_kvm_getenvv+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lkvm $LIBS" @@ -20657,36 +15379,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_kvm_kvm_getenvv=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_kvm_kvm_getenvv=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_kvm_kvm_getenvv" >&5 -$as_echo "$ac_cv_lib_kvm_kvm_getenvv" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_kvm_kvm_getenvv" >&5 +echo "${ECHO_T}$ac_cv_lib_kvm_kvm_getenvv" >&6; } if test $ac_cv_lib_kvm_kvm_getenvv = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBKVM 1 @@ -20697,8 +15415,8 @@ _ACEOF fi if test "$ac_cv_lib_kvm_kvm_getenvv" = yes; then - { $as_echo "$as_me:$LINENO: checking if we can access kernel memory" >&5 -$as_echo_n "checking if we can access kernel memory... " >&6; } + { echo "$as_me:$LINENO: checking if we can access kernel memory" >&5 +echo $ECHO_N "checking if we can access kernel memory... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then have_kvm_env=0 else @@ -20716,47 +15434,44 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then have_kvm_env=1 else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) have_kvm_env=0 fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi if test $have_kvm_env = 1; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_KVM_ENV 1 _ACEOF else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } # Reset LIBS since we don't need kvm LIBS="$save_LIBS" fi @@ -20772,8 +15487,8 @@ case "$target_os" in cygwin*) PASS_ARG=yes;; esac -{ $as_echo "$as_me:$LINENO: checking use of pass-through arguments" >&5 -$as_echo_n "checking use of pass-through arguments... " >&6; } +{ echo "$as_me:$LINENO: checking use of pass-through arguments" >&5 +echo $ECHO_N "checking use of pass-through arguments... $ECHO_C" >&6; } # Check whether --enable-pass-arguments was given. if test "${enable_pass_arguments+set}" = set; then enableval=$enable_pass_arguments; @@ -20788,11 +15503,11 @@ else GS_PASS_ARGUMENTS=0 fi -{ $as_echo "$as_me:$LINENO: result: $enable_pass_arguments" >&5 -$as_echo "$enable_pass_arguments" >&6; } +{ echo "$as_me:$LINENO: result: $enable_pass_arguments" >&5 +echo "${ECHO_T}$enable_pass_arguments" >&6; } -{ $as_echo "$as_me:$LINENO: checking use of fake-main definition" >&5 -$as_echo_n "checking use of fake-main definition... " >&6; } +{ echo "$as_me:$LINENO: checking use of fake-main definition" >&5 +echo $ECHO_N "checking use of fake-main definition... $ECHO_C" >&6; } # Check whether --enable-fake-main was given. if test "${enable_fake_main+set}" = set; then enableval=$enable_fake_main; @@ -20817,10 +15532,6 @@ if test "$enable_fake_main" = "yes"; then elif test "$enable_pass_arguments" = "no"; then if test "$objc_load_method_worked" = yes -a \( "$ac_cv_sys_procfs" = yes -o "$have_kvm_env" = 1 -o "$ac_cv_sys_procfs_psinfo" = yes \); then GS_FAKE_MAIN=0 - if test "$have_kvm_env" = "1"; then - echo "WARNING ... using libkvm which is known to be buggy on some systems" - echo "consider configuring with --enable-fake-main instead." - fi else GS_FAKE_MAIN=1 enable_fake_main=yes @@ -20830,8 +15541,8 @@ case "$target_os" in mingw*) enable_fake_main=no; GS_FAKE_MAIN=0;; esac -{ $as_echo "$as_me:$LINENO: result: $enable_fake_main" >&5 -$as_echo "$enable_fake_main" >&6; } +{ echo "$as_me:$LINENO: result: $enable_fake_main" >&5 +echo "${ECHO_T}$enable_fake_main" >&6; } #-------------------------------------------------------------------- # Simple way to add a bunch of paths to the flags @@ -20864,41 +15575,9 @@ fi #-------------------------------------------------------------------- # Check for FFI interface libraries for invocations -# We enable ffi by default now, as it's fixed for some previouly bad -# platforms, and it has the advantage over ffcall that it does not -# mess up the stack, so stacktraces and native exception handling -# work better with it. +# We enable ffcall by default now. #-------------------------------------------------------------------- -do_broken_libffi=no -do_broken_libffcall=no -do_enable_libffi=yes -do_enable_libffcall=no -case "$target_cpu" in - sparc64*) - case "$target_os" in - solaris*) - do_broken_libffcall=yes; - do_enable_libffi=yes; - do_enable_libffcall=no;; - *) ;; - esac ;; - *) ;; -esac - -if test "$exceptions" = "yes"; then - # ffcall will mess up native exceptions, so we must disable it. - do_broken_libffcall=yes - do_enable_libffcall=no - - if test "$have_unexpected" = "no"; then - echo - echo "Your gnustep-make is configured to use native objc exceptions, but" - echo "the objc runtime does not appear to support setting an uncaught" - echo "exception handler. This means that any uncaught exception will" - echo "cause a program to abort immediately." - echo "Consider reconfiguring gnustep-make or updating libobjc to fix this." - fi -fi +do_enable_libffi=no # Check whether --enable-libffi was given. if test "${enable_libffi+set}" = set; then @@ -20912,26 +15591,21 @@ fi if test "${enable_ffcall+set}" = set; then enableval=$enable_ffcall; else - enable_ffcall=$do_enable_libffcall + enable_ffcall=yes fi -if test $enable_ffcall = yes; then - { $as_echo "$as_me:$LINENO: WARNING: ffcall has been enabled ... this is deprecated ... please install and use a recent libffi if possible" >&5 -$as_echo "$as_me: WARNING: ffcall has been enabled ... this is deprecated ... please install and use a recent libffi if possible" >&2;} -fi - -# Check whether --enable-invocations was given. -if test "${enable_invocations+set}" = set; then - enableval=$enable_invocations; +# Check whether --enable-do was given. +if test "${enable_do+set}" = set; then + enableval=$enable_do; else - enable_invocations=yes + enable_do=yes fi # DO isn't used on apple-apple-apple if test $LIBRARY_COMBO = apple-apple-apple; then - enable_invocations=no + enable_do=no fi @@ -20968,19 +15642,18 @@ esac fi -if test "$do_broken_libffi" = "no"; then - if test "${ac_cv_header_ffi_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for ffi.h" >&5 -$as_echo_n "checking for ffi.h... " >&6; } if test "${ac_cv_header_ffi_h+set}" = set; then - $as_echo_n "(cached) " >&6 + { echo "$as_me:$LINENO: checking for ffi.h" >&5 +echo $ECHO_N "checking for ffi.h... $ECHO_C" >&6; } +if test "${ac_cv_header_ffi_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 -$as_echo "$ac_cv_header_ffi_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 +echo "${ECHO_T}$ac_cv_header_ffi_h" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking ffi.h usability" >&5 -$as_echo_n "checking ffi.h usability... " >&6; } +{ echo "$as_me:$LINENO: checking ffi.h usability" >&5 +echo $ECHO_N "checking ffi.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -20996,33 +15669,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking ffi.h presence" >&5 -$as_echo_n "checking ffi.h presence... " >&6; } +{ echo "$as_me:$LINENO: checking ffi.h presence" >&5 +echo $ECHO_N "checking ffi.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -21036,64 +15708,63 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: ffi.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: ffi.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: ffi.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: ffi.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: ffi.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: ffi.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: ffi.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: ffi.h: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: ffi.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: ffi.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: ffi.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: ffi.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: ffi.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: ffi.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: ffi.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for ffi.h" >&5 -$as_echo_n "checking for ffi.h... " >&6; } +{ echo "$as_me:$LINENO: checking for ffi.h" >&5 +echo $ECHO_N "checking for ffi.h... $ECHO_C" >&6; } if test "${ac_cv_header_ffi_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_ffi_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 -$as_echo "$ac_cv_header_ffi_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 +echo "${ECHO_T}$ac_cv_header_ffi_h" >&6; } fi if test $ac_cv_header_ffi_h = yes; then @@ -21103,28 +15774,23 @@ else fi -else - have_libffi=no -fi -if test "$do_broken_libffcall" = "no"; then for ac_header in callback.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -21140,33 +15806,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -21180,72 +15845,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF have_ffcall=yes else @@ -21254,9 +15916,6 @@ fi done -else - have_ffcall=no -fi if test $have_ffcall = no; then enable_ffcall=no # If we don't have ffcall but do have libffi, use libffi @@ -21266,58 +15925,14 @@ if test $have_ffcall = no; then fi if test $have_libffi = no; then enable_libffi=no - # If we don't have libffi but do have ffcall, use ffcall - if test $have_ffcall = yes; then - if test $enable_ffcall = no; then - { $as_echo "$as_me:$LINENO: WARNING: ffi support seems to be missing on this system ... please install a recent libffi" >&5 -$as_echo "$as_me: WARNING: ffi support seems to be missing on this system ... please install a recent libffi" >&2;} - fi - fi fi have_forward_hook=yes saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c" -{ $as_echo "$as_me:$LINENO: checking for forwarding callback in runtime" >&5 -$as_echo_n "checking for forwarding callback in runtime... " >&6; } +{ echo "$as_me:$LINENO: checking for forwarding callback in runtime" >&5 +echo $ECHO_N "checking for forwarding callback in runtime... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF -#include "$srcdir/config/config.forward2.m" -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - have_forward_hook=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - have_forward_hook=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test $have_forward_hook = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_FORWARD2 1 -_ACEOF - -else - cat >conftest.$ac_ext <<_ACEOF #include "$srcdir/config/config.forward.m" _ACEOF rm -f conftest.$ac_objext @@ -21326,38 +15941,36 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then have_forward_hook=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 have_forward_hook=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $have_forward_hook" >&5 -$as_echo "$have_forward_hook" >&6; } +{ echo "$as_me:$LINENO: result: $have_forward_hook" >&5 +echo "${ECHO_T}$have_forward_hook" >&6; } if test $have_forward_hook = no; then enable_libffi=no enable_ffcall=no fi CPPFLAGS="$saved_CPPFLAGS" -{ $as_echo "$as_me:$LINENO: checking FFI library usage" >&5 -$as_echo_n "checking FFI library usage... " >&6; } +{ echo "$as_me:$LINENO: checking FFI library usage" >&5 +echo $ECHO_N "checking FFI library usage... $ECHO_C" >&6; } WITH_FFI=none if test $enable_libffi = yes; then @@ -21367,64 +15980,52 @@ _ACEOF WITH_FFI=libffi LIBS="-lffi $LIBS" - if test "$cross_compiling" = yes; then - ffi_ok="no" -else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include "$srcdir/config/config.ffi.c" +#include +int +main () +{ + + ; + return 0; +} _ACEOF -rm -f conftest$ac_exeext +rm -f conftest.$ac_objext conftest$ac_exeext 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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ffi_ok="yes" else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -( exit $ac_status ) -ffi_ok="yes" -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext + ffi_ok="no" fi - +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext if test $ffi_ok = yes; then - { $as_echo "$as_me:$LINENO: result: libffi" >&5 -$as_echo "libffi" >&6; } - if test $do_broken_libffi = yes; then - { $as_echo "$as_me:$LINENO: WARNING: ffi may be broken on this system ... try enabling ffcall" >&5 -$as_echo "$as_me: WARNING: ffi may be broken on this system ... try enabling ffcall" >&2;} - fi - else - { { $as_echo "$as_me:$LINENO: error: The ffi library (libffi) does not appear to be working. Perhaps it's missing or you need a more recent version. Version 3.0.9 or later should work, and you can find a link to it n the list of packages for download at http://www.gnustep.org/resources/sources.html" >&5 -$as_echo "$as_me: error: The ffi library (libffi) does not appear to be working. Perhaps it's missing or you need a more recent version. Version 3.0.9 or later should work, and you can find a link to it n the list of packages for download at http://www.gnustep.org/resources/sources.html" >&2;} - { (exit 1); exit 1; }; } + { echo "$as_me:$LINENO: result: libffi" >&5 +echo "${ECHO_T}libffi" >&6; } fi elif test $enable_ffcall = yes; then @@ -21455,45 +16056,34 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ffi_ok="yes" else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ffi_ok="no" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test $ffi_ok = yes; then - { $as_echo "$as_me:$LINENO: result: ffcall" >&5 -$as_echo "ffcall" >&6; } + { echo "$as_me:$LINENO: result: ffcall" >&5 +echo "${ECHO_T}ffcall" >&6; } fi - { $as_echo "$as_me:$LINENO: WARNING: ffcall is broken on some systems and is deprecated ... try enabling ffi" >&5 -$as_echo "$as_me: WARNING: ffcall is broken on some systems and is deprecated ... try enabling ffi" >&2;} -else - ffi_ok=no -fi - -if test $enable_ffcall = yes -a $ffi_ok = yes; then - { $as_echo "$as_me:$LINENO: checking if ffcall trampolines work" >&5 -$as_echo_n "checking if ffcall trampolines work... " >&6; } + { echo "$as_me:$LINENO: checking if ffcall trampolines work" >&5 +echo $ECHO_N "checking if ffcall trampolines work... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then have_working_trampoline=yes else @@ -21506,75 +16096,74 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then have_working_trampoline=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) have_working_trampoline=no fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:$LINENO: result: $have_working_trampoline" >&5 -$as_echo "$have_working_trampoline" >&6; } + { echo "$as_me:$LINENO: result: $have_working_trampoline" >&5 +echo "${ECHO_T}$have_working_trampoline" >&6; } + if test $have_working_trampoline = no; then + ffi_ok=no + fi +else + ffi_ok=no fi if test $ffi_ok = no; then - { $as_echo "$as_me:$LINENO: result: none" >&5 -$as_echo "none" >&6; } + { echo "$as_me:$LINENO: result: none" >&5 +echo "${ECHO_T}none" >&6; } echo if test $have_forward_hook = no; then echo "You do not have an up-to-date libobjc library installed" elif test "$have_working_trampoline" = no; then echo "You have ffcall, but it does not work properly. Most likely because" - echo "your system's security policy is blocking some parts of ffcall" + echo "your're system's security policy is blocking some parts of ffcall" echo "we recommend installing libffi instead." else - echo "You do not have either ffcall or libffi installed/enabled, or configure needs" - echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them," - echo "or you have ffcall but gnustep-make is configured to use native exceptions" - echo "(native exceptions are not compatible with ffcall)." + echo "You do not have either ffcall or libffi installed, or configure needs" + echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them" fi - echo "GNUstep requires libffi (or ffcall) and proper libobjc hooks to do" + echo "GNUstep requires ffcall or libffi and proper libobjc hooks to do" echo "invocations and DO." echo "(This does not apply on apple-apple-apple systems where DO is" echo "not compatible with other GNUstep systems.)" - if test $enable_invocations = yes; then + if test $enable_do = yes; then echo - echo "You most likely do not want to build base without invocation support." - echo "Many things (including Distributed Objects and undo/redo), won't work" - echo "at all without invocations." - echo "If you really want to build -base without invocation support," - echo "add --disable-invocations to the configure arguments." + echo "You most likely do not want to build base without DO support. Many" + echo "things, including all applications, won't work at all without DO." + echo "If you really want to build -base without DO support, add --disable-do" + echo "to the configure arguments." echo "For more information, read the GNUstep build guide, ffcall section:" echo "http://gnustep.made-it.com/BuildGuide/index.html" - { { $as_echo "$as_me:$LINENO: error: Incomplete support for ffi functionality." >&5 -$as_echo "$as_me: error: Incomplete support for ffi functionality." >&2;} + { { echo "$as_me:$LINENO: error: Incomplete support for ffi functionality." >&5 +echo "$as_me: error: Incomplete support for ffi functionality." >&2;} { (exit 1); exit 1; }; } fi - { $as_echo "$as_me:$LINENO: WARNING: Incomplete support for ffi funtionality." >&5 -$as_echo "$as_me: WARNING: Incomplete support for ffi funtionality." >&2;} + { echo "$as_me:$LINENO: WARNING: Incomplete support for ffi funtionality." >&5 +echo "$as_me: WARNING: Incomplete support for ffi funtionality." >&2;} fi @@ -21593,8 +16182,8 @@ fi # # First, check if there's a working iconv in libc (ie. if the test program # compiles and links without any extra flags). -{ $as_echo "$as_me:$LINENO: checking iconv support" >&5 -$as_echo_n "checking iconv support... " >&6; } +{ echo "$as_me:$LINENO: checking iconv support" >&5 +echo $ECHO_N "checking iconv support... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF #include int main(int argc,char **argv) { iconv_open("foo","bar"); } @@ -21606,40 +16195,36 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then # libc has a working iconv. cat >>confdefs.h <<\_ACEOF #define HAVE_ICONV 1 _ACEOF - { $as_echo "$as_me:$LINENO: result: yes, in libc" >&5 -$as_echo "yes, in libc" >&6; } + { echo "$as_me:$LINENO: result: yes, in libc" >&5 +echo "${ECHO_T}yes, in libc" >&6; } found_iconv=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 found_iconv=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext @@ -21681,33 +16266,30 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then # -liconv works. cat >>confdefs.h <<\_ACEOF #define HAVE_ICONV 1 _ACEOF - { $as_echo "$as_me:$LINENO: result: yes, -liconv" >&5 -$as_echo "yes, -liconv" >&6; } + { echo "$as_me:$LINENO: result: yes, -liconv" >&5 +echo "${ECHO_T}yes, -liconv" >&6; } found_iconv=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 found_iconv=no @@ -21715,7 +16297,6 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -21736,21 +16317,18 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define HAVE_ICONV 1 @@ -21761,20 +16339,19 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_GICONV 1 _ACEOF - { $as_echo "$as_me:$LINENO: result: yes, -lgiconv" >&5 -$as_echo "yes, -lgiconv" >&6; } + { echo "$as_me:$LINENO: result: yes, -lgiconv" >&5 +echo "${ECHO_T}yes, -lgiconv" >&6; } else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } LIBS="$old_LIBS" fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -21826,10 +16403,10 @@ fi # Extract the first word of "xml2-config", so it can be a program name with args. set dummy xml2-config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_XML2_CONFIG+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else case $XML2_CONFIG in [\\/]* | ?:[\\/]*) @@ -21844,7 +16421,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_XML2_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -21857,21 +16434,21 @@ esac fi XML2_CONFIG=$ac_cv_path_XML2_CONFIG if test -n "$XML2_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: $XML2_CONFIG" >&5 -$as_echo "$XML2_CONFIG" >&6; } + { echo "$as_me:$LINENO: result: $XML2_CONFIG" >&5 +echo "${ECHO_T}$XML2_CONFIG" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi if test "$XML2_CONFIG" = "no" ; then # Extract the first word of "xml-config", so it can be a program name with args. set dummy xml-config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_XML_CONFIG+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else case $XML_CONFIG in [\\/]* | ?:[\\/]*) @@ -21886,7 +16463,7 @@ do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_XML_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -21899,11 +16476,11 @@ esac fi XML_CONFIG=$ac_cv_path_XML_CONFIG if test -n "$XML_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: $XML_CONFIG" >&5 -$as_echo "$XML_CONFIG" >&6; } + { echo "$as_me:$LINENO: result: $XML_CONFIG" >&5 +echo "${ECHO_T}$XML_CONFIG" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi @@ -21911,8 +16488,8 @@ fi XML_CONFIG=$XML2_CONFIG fi min_xml_version=2.3.0 - { $as_echo "$as_me:$LINENO: checking for libxml - version >= $min_xml_version" >&5 -$as_echo_n "checking for libxml - version >= $min_xml_version... " >&6; } + { echo "$as_me:$LINENO: checking for libxml - version >= $min_xml_version" >&5 +echo $ECHO_N "checking for libxml - version >= $min_xml_version... $ECHO_C" >&6; } no_xml="" if test "$XML_CONFIG" = "no" ; then XML_CFLAGS="" @@ -21992,32 +16569,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) no_xml=yes fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -22131,32 +16705,29 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) no_xml=yes fi -rm -rf conftest.dSYM rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -22168,12 +16739,12 @@ fi fi if test "x$no_xml" = x ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } enable_libxml=yes else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } if test "$XML_CONFIG" = "no" ; then echo "*** The xml-config script installed by libxml could not be found" echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in" @@ -22210,21 +16781,20 @@ _ACEOF for ac_header in libxml/SAX2.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -22240,33 +16810,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -22280,72 +16849,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -22364,10 +16930,10 @@ fi if test $enable_xslt = yes; then - { $as_echo "$as_me:$LINENO: checking for xsltApplyStylesheet in -lxslt" >&5 -$as_echo_n "checking for xsltApplyStylesheet in -lxslt... " >&6; } + { echo "$as_me:$LINENO: checking for xsltApplyStylesheet in -lxslt" >&5 +echo $ECHO_N "checking for xsltApplyStylesheet in -lxslt... $ECHO_C" >&6; } if test "${ac_cv_lib_xslt_xsltApplyStylesheet+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lxslt $LIBS" @@ -22399,36 +16965,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_xslt_xsltApplyStylesheet=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_xslt_xsltApplyStylesheet=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_xslt_xsltApplyStylesheet" >&5 -$as_echo "$ac_cv_lib_xslt_xsltApplyStylesheet" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_xslt_xsltApplyStylesheet" >&5 +echo "${ECHO_T}$ac_cv_lib_xslt_xsltApplyStylesheet" >&6; } if test $ac_cv_lib_xslt_xsltApplyStylesheet = yes; then xslt_ok=yes else @@ -22437,17 +16999,17 @@ fi if test "$xslt_ok" = "yes"; then if test "${ac_cv_header_libxslt_xslt_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for libxslt/xslt.h" >&5 -$as_echo_n "checking for libxslt/xslt.h... " >&6; } + { echo "$as_me:$LINENO: checking for libxslt/xslt.h" >&5 +echo $ECHO_N "checking for libxslt/xslt.h... $ECHO_C" >&6; } if test "${ac_cv_header_libxslt_xslt_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_libxslt_xslt_h" >&5 -$as_echo "$ac_cv_header_libxslt_xslt_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_libxslt_xslt_h" >&5 +echo "${ECHO_T}$ac_cv_header_libxslt_xslt_h" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking libxslt/xslt.h usability" >&5 -$as_echo_n "checking libxslt/xslt.h usability... " >&6; } +{ echo "$as_me:$LINENO: checking libxslt/xslt.h usability" >&5 +echo $ECHO_N "checking libxslt/xslt.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -22463,33 +17025,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking libxslt/xslt.h presence" >&5 -$as_echo_n "checking libxslt/xslt.h presence... " >&6; } +{ echo "$as_me:$LINENO: checking libxslt/xslt.h presence" >&5 +echo $ECHO_N "checking libxslt/xslt.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -22503,64 +17064,63 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: libxslt/xslt.h: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: libxslt/xslt.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: libxslt/xslt.h: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for libxslt/xslt.h" >&5 -$as_echo_n "checking for libxslt/xslt.h... " >&6; } +{ echo "$as_me:$LINENO: checking for libxslt/xslt.h" >&5 +echo $ECHO_N "checking for libxslt/xslt.h... $ECHO_C" >&6; } if test "${ac_cv_header_libxslt_xslt_h+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_libxslt_xslt_h=$ac_header_preproc fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_libxslt_xslt_h" >&5 -$as_echo "$ac_cv_header_libxslt_xslt_h" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_header_libxslt_xslt_h" >&5 +echo "${ECHO_T}$ac_cv_header_libxslt_xslt_h" >&6; } fi if test $ac_cv_header_libxslt_xslt_h = yes; then @@ -22584,17 +17144,16 @@ _ACEOF LIBS="-lxslt $LIBS" else echo - echo "You may not want to build base without XSLT support." - echo "Doing so will disable the XSLT extensions." + echo "You most likely do not want to build base without XSLT support." echo "If you really want to build -base without XSLT support," echo "add --disable-xslt to the configure arguments." - { $as_echo "$as_me:$LINENO: WARNING: Missing support for XSLT functionality." >&5 -$as_echo "$as_me: WARNING: Missing support for XSLT functionality." >&2;} + { echo "$as_me:$LINENO: WARNING: Missing support for XSLT functionality." >&5 +echo "$as_me: WARNING: Missing support for XSLT functionality." >&2;} fi else HAVE_LIBXSLT=0 - { $as_echo "$as_me:$LINENO: WARNING: Disabled support for XSLT funtionality." >&5 -$as_echo "$as_me: WARNING: Disabled support for XSLT funtionality." >&2;} + { echo "$as_me:$LINENO: WARNING: Disabled support for XSLT funtionality." >&5 +echo "$as_me: WARNING: Disabled support for XSLT funtionality." >&2;} fi else @@ -22603,566 +17162,42 @@ $as_echo "$as_me: WARNING: Disabled support for XSLT funtionality." >&2;} LIBS="$saved_LIBS" CFLAGS="$saved_CFLAGS" echo - echo "You may not want to build base without libxml2." - echo "Doing so will disable the XML, XPATH, and XMLRPC extensions." + echo "You most likely do not want to build base without XML support." + echo "For instance, MacOS-X compatible property lists require XML." echo "If you really want to build -base without XML support," echo "add --disable-xml to the configure arguments." - { { $as_echo "$as_me:$LINENO: error: Missing support for XML functionality." >&5 -$as_echo "$as_me: error: Missing support for XML functionality." >&2;} + { { echo "$as_me:$LINENO: error: Missing support for XML functionality." >&5 +echo "$as_me: error: Missing support for XML functionality." >&2;} { (exit 1); exit 1; }; } fi else - { $as_echo "$as_me:$LINENO: WARNING: Disabled support for XML funtionality." >&5 -$as_echo "$as_me: WARNING: Disabled support for XML funtionality." >&2;} + { echo "$as_me:$LINENO: WARNING: Disabled support for XML funtionality." >&5 +echo "$as_me: WARNING: Disabled support for XML funtionality." >&2;} HAVE_LIBXML=0 fi -#-------------------------------------------------------------------- -# Check recent libgnutls for SSL streams. -#-------------------------------------------------------------------- - -# Check whether --enable-tls was given. -if test "${enable_tls+set}" = set; then - enableval=$enable_tls; -else - enable_tls=yes -fi - - -if test $enable_tls = yes; then - # Save CFLAGS and LIBS as AM_PATH_TLS clobbers these variables regardless - # of the success of the macro. - saved_LIBS="$LIBS" - saved_CFLAGS="$CFLAGS" - -# AM_PATH_TLS(2.0.1, enable_libgnutls=yes, enable_libgnutls=no) - - -# Check whether --with-tls-prefix was given. -if test "${with_tls_prefix+set}" = set; then - withval=$with_tls_prefix; tls_config_prefix="$withval" -else - tls_config_prefix="" -fi - -# Check whether --enable-tlstest was given. -if test "${enable_tlstest+set}" = set; then - enableval=$enable_tlstest; -else - enable_tlstest=yes -fi - - - if test x$tls_config_prefix != x ; then - tls_config_args="$tls_config_args --prefix=$tls_config_prefix" - if test x${TLS_CONFIG+set} != xset ; then - TLS_CONFIG=$tls_config_prefix/bin/libgnutls-config - fi - fi - - # Extract the first word of "libgnutls-config", so it can be a program name with args. -set dummy libgnutls-config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_TLS_CONFIG+set}" = set; then - $as_echo_n "(cached) " >&6 -else - case $TLS_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_TLS_CONFIG="$TLS_CONFIG" # Let the user override the test with a path. - ;; - *) - 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_TLS_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - - test -z "$ac_cv_path_TLS_CONFIG" && ac_cv_path_TLS_CONFIG="no" - ;; -esac -fi -TLS_CONFIG=$ac_cv_path_TLS_CONFIG -if test -n "$TLS_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: $TLS_CONFIG" >&5 -$as_echo "$TLS_CONFIG" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - min_tls_version=1.4.0 - { $as_echo "$as_me:$LINENO: checking for libgnutls - version >= $min_tls_version" >&5 -$as_echo_n "checking for libgnutls - version >= $min_tls_version... " >&6; } - no_tls="" - if test "$TLS_CONFIG" = "no" ; then - TLS_CFLAGS="-I/usr/include" - TLS_LIBS="-L/usr/lib -lgnutls -lgcrypt" - - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $TLS_CFLAGS" - LIBS="$TLS_LIBS $LIBS" - rm -f conf.tlstest - if test "$cross_compiling" = yes; then - echo $ac_n "cross compiling; assumed OK... $ac_c" -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -#include -#include - -int -main() -{ - system("touch conf.tlstest"); - - if (gnutls_check_version("$min_tls_version") == 0) - { - printf("\n*** An old version of libgnutls (%s) was found.\n", - gnutls_check_version(0)); - printf("*** You need a version of libtgnuls newer than $min_tls_version.\n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n"); - printf("*** being found. You can fix this is by removing the old version\n"); - printf("*** of libgnutls.\n"); - return 1; - } - return 0; -} - -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -no_tls=yes -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - - - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - else - TLS_CFLAGS=`$TLS_CONFIG $tls_config_args --cflags` - TLS_LIBS=`$TLS_CONFIG $tls_config_args --libs` - tls_config_major_version=`$TLS_CONFIG $tls_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - tls_config_minor_version=`$TLS_CONFIG $tls_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` - tls_config_micro_version=`$TLS_CONFIG $tls_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` - # Strip '-L/usr/lib' off since this is always in the link path. - TLS_LIBS=`echo $TLS_LIBS | sed -e 's|-L/usr/lib||'` - - if test "x$enable_tlstest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $TLS_CFLAGS" - LIBS="$TLS_LIBS $LIBS" - rm -f conf.tlstest - if test "$cross_compiling" = yes; then - echo $ac_n "cross compiling; assumed OK... $ac_c" -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#include -#include -#include - -int -main() -{ - system("touch conf.tlstest"); - - if (gnutls_check_version("$min_tls_version") == 0) - { - printf("\n*** An old version of libgnutls (%s) was found.\n", - gnutls_check_version(0)); - printf("*** You need a version of libtgnuls newer than $min_tls_version.\n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the libgnutls-config shell script is\n"); - printf("*** being found. You can fix this is by removing the old version\n"); - printf("*** of libgnutls.\n"); - return 1; - } - return 0; -} - -_ACEOF -rm -f conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -no_tls=yes -fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi - - - - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - - if test "x$no_tls" = x ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } - enable_libgnutls=yes - else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } - if test "$TLS_CONFIG" = "no" ; then - echo "*** The libgnutls-config script installed by libgnutls could not be found" - echo "*** If libtgnuls was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path." - else - if test -f conf.tlstest ; then - : - else - echo "*** Could not run libtgnuls test program, checking why..." - CFLAGS="$CFLAGS $TLS_CFLAGS" - LIBS="$LIBS $TLS_LIBS" - fi - fi - - TLS_CFLAGS="" - TLS_LIBS="" - enable_libgnutls=no - fi - - - rm -f conf.tlstest - - if test $enable_libgnutls = yes; then - CPPFLAGS="$CPPFLAGS $TLS_CFLAGS" - INCLUDE_FLAGS="$INCLUDE_FLAGS $TLS_CFLAGS" - LIBS="$TLS_LIBS $LIBS" - HAVE_GNUTLS=1 - -cat >>confdefs.h <<\_ACEOF -#define HAVE_GNUTLS 1 -_ACEOF - - { $as_echo "$as_me:$LINENO: checking for gcry_control in -lgcrypt" >&5 -$as_echo_n "checking for gcry_control in -lgcrypt... " >&6; } -if test "${ac_cv_lib_gcrypt_gcry_control+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgcrypt $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gcry_control (); -int -main () -{ -return gcry_control (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_gcrypt_gcry_control=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_gcrypt_gcry_control=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_gcrypt_gcry_control" >&5 -$as_echo "$ac_cv_lib_gcrypt_gcry_control" >&6; } -if test $ac_cv_lib_gcrypt_gcry_control = yes; then - have_gcrypt=yes -else - have_gcrypt=no -fi - - if test "$have_gcrypt" = "no"; then - { $as_echo "$as_me:$LINENO: WARNING: Missing support for thread-safe operation in GNUTLS. Disabling TLS support)." >&5 -$as_echo "$as_me: WARNING: Missing support for thread-safe operation in GNUTLS. Disabling TLS support)." >&2;} - HAVE_GNUTLS=0 - else - LIBS="$TLS_LIBS -lgcrypt $LIBS" - fi - -for ac_func in gnutls_transport_set_errno -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if test `eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - if test "$ac_cv_func_gnutls_transport_set_errno" = "no"; then - { $as_echo "$as_me:$LINENO: WARNING: Missing support for thread-safe error handling in GNUTLS. Please check that you have the most recent version installed (2.0 or later chould be fine)." >&5 -$as_echo "$as_me: WARNING: Missing support for thread-safe error handling in GNUTLS. Please check that you have the most recent version installed (2.0 or later chould be fine)." >&2;} - fi - else - HAVE_GNUTLS=0 - # Restore the CFLAGS and LIBS because AM_PATH_TLS messes them - LIBS="$saved_LIBS" - CFLAGS="$saved_CFLAGS" - echo - echo "You may not want to build base without libgnutls." - echo "Doing so will disable SSL support in the NSStream class." - echo "If you really want to build -base without TLS support," - echo "add --disable-tls to the configure arguments." - { $as_echo "$as_me:$LINENO: WARNING: Missing support for TLS functionality." >&5 -$as_echo "$as_me: WARNING: Missing support for TLS functionality." >&2;} - fi -else - { $as_echo "$as_me:$LINENO: WARNING: Disabled support for TLS funtionality." >&5 -$as_echo "$as_me: WARNING: Disabled support for TLS funtionality." >&2;} - HAVE_GNUTLS=0 -fi - - #-------------------------------------------------------------------- # Check for NSNetServices #-------------------------------------------------------------------- HAVE_MDNS=0 -HAVE_AVAHI=0 -# Check whether --enable-zeroconf was given. -if test "${enable_zeroconf+set}" = set; then - enableval=$enable_zeroconf; -else - enable_zeroconf=yes -fi - - -# Check whether --with-zeroconf-api was given. -if test "${with_zeroconf_api+set}" = set; then - withval=$with_zeroconf_api; zeroconf_api="$withval" -else - zeroconf_api="any" -fi - -if test $enable_zeroconf = yes; then - if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "mdns"; then for ac_header in dns_sd.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -23178,33 +17213,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -23218,72 +17252,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF have_mdns=yes else @@ -23292,11 +17323,11 @@ fi done - if test "$have_mdns" = "yes"; then - { $as_echo "$as_me:$LINENO: checking for DNSServiceBrowse in -ldns_sd" >&5 -$as_echo_n "checking for DNSServiceBrowse in -ldns_sd... " >&6; } +if test "$have_mdns" = "yes"; then + { echo "$as_me:$LINENO: checking for DNSServiceBrowse in -ldns_sd" >&5 +echo $ECHO_N "checking for DNSServiceBrowse in -ldns_sd... $ECHO_C" >&6; } if test "${ac_cv_lib_dns_sd_DNSServiceBrowse+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldns_sd $LIBS" @@ -23328,529 +17359,41 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_dns_sd_DNSServiceBrowse=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dns_sd_DNSServiceBrowse=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dns_sd_DNSServiceBrowse" >&5 -$as_echo "$ac_cv_lib_dns_sd_DNSServiceBrowse" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dns_sd_DNSServiceBrowse" >&5 +echo "${ECHO_T}$ac_cv_lib_dns_sd_DNSServiceBrowse" >&6; } if test $ac_cv_lib_dns_sd_DNSServiceBrowse = yes; then have_mdns=yes else have_mdns=no fi - if test "$have_mdns" = "yes"; then - MDNS_LIBS="-ldns_sd" - HAVE_MDNS=1 - fi - fi - fi - if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "avahi"; then - -for ac_header in avahi-client/client.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - have_avahi=yes -else - have_avahi=no -fi - -done - - if test "$have_avahi" = "yes"; then - { $as_echo "$as_me:$LINENO: checking for avahi_client_new in -lavahi-client" >&5 -$as_echo_n "checking for avahi_client_new in -lavahi-client... " >&6; } -if test "${ac_cv_lib_avahi_client_avahi_client_new+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lavahi-client $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char avahi_client_new (); -int -main () -{ -return avahi_client_new (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_avahi_client_avahi_client_new=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_avahi_client_avahi_client_new=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_avahi_client_avahi_client_new" >&5 -$as_echo "$ac_cv_lib_avahi_client_avahi_client_new" >&6; } -if test $ac_cv_lib_avahi_client_avahi_client_new = yes; then - have_avahi=yes -else - have_avahi=no -fi - - if test "$have_avahi" = "yes"; then - AVAHI_LIBS="-lavahi-common -lavahi-client" - HAVE_AVAHI=1 - fi - fi - fi - # If we have both APIs, perfer Avahi, because the mDNS API is most certainly the compatability one - if test "$have_avahi" = "yes" && test "$have_mdns" = "yes"; then - LIBS="$AVAHI_LIBS $LIBS" - HAVE_MDNS=0 - else - # One of those will be empty. - LIBS="$AVAHI_LIBS $MDNS_LIBS $LIBS" - fi -fi - - -#-------------------------------------------------------------------- -# Check for International Components for Unicode -#-------------------------------------------------------------------- -HAVE_ICU=0 -# Check whether --enable-icu was given. -if test "${enable_icu+set}" = set; then - enableval=$enable_icu; -else - enable_icu=yes -fi - - -if test $enable_icu = yes; then - - ok=no - - if test -z "$ICU_CONFIG"; then - # Extract the first word of "icu-config", so it can be a program name with args. -set dummy icu-config; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ICU_CONFIG+set}" = set; then - $as_echo_n "(cached) " >&6 -else - case $ICU_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ICU_CONFIG="$ICU_CONFIG" # Let the user override the test with a path. - ;; - *) - 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_ICU_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - - test -z "$ac_cv_path_ICU_CONFIG" && ac_cv_path_ICU_CONFIG="no" - ;; -esac -fi -ICU_CONFIG=$ac_cv_path_ICU_CONFIG -if test -n "$ICU_CONFIG"; then - { $as_echo "$as_me:$LINENO: result: $ICU_CONFIG" >&5 -$as_echo "$ICU_CONFIG" >&6; } -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi - - if test "$ICU_CONFIG" = "no" ; then - echo "Could not find the icu-config script." - echo "Please ensure that it is in your path." - echo "See http://site.icu-project.org/ for help." - else - ICU_VERSION=`$ICU_CONFIG --version` - { $as_echo "$as_me:$LINENO: checking for ICU >= 4.0" >&5 -$as_echo_n "checking for ICU >= 4.0... " >&6; } - found=`expr $ICU_VERSION \>= 4.0` - if test "$found" = "1" ; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } - ok=yes - - { $as_echo "$as_me:$LINENO: checking ICU_LIBS" >&5 -$as_echo_n "checking ICU_LIBS... " >&6; } - ICU_LIBS=`$ICU_CONFIG --ldflags-libsonly` - { $as_echo "$as_me:$LINENO: result: $ICU_LIBS" >&5 -$as_echo "$ICU_LIBS" >&6; } - else - ICU_LIBS="" - ## Either perform custom action or print error message - - fi - - - fi - - if test $ok = yes; then - have_icu=yes - else - have_icu=no - fi - - if test "$have_icu" = "yes"; then - - - -for ac_header in unicode/uloc.h unicode/ulocdata.h unicode/ucurr.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - LIBS="$LIBS $ICU_LIBS" - HAVE_ICU=1 + if test "$have_mdns" = "yes"; then + LIBS="-ldns_sd $LIBS" + HAVE_MDNS=1 fi fi @@ -23899,21 +17442,20 @@ USE_GMP=0 for ac_header in gmp.h do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -23929,33 +17471,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -23969,72 +17510,69 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } fi -if test `eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` = yes; then +if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -24042,10 +17580,10 @@ fi done if test $ac_cv_header_gmp_h = yes; then - { $as_echo "$as_me:$LINENO: checking for mpf_abs in -lgmp" >&5 -$as_echo_n "checking for mpf_abs in -lgmp... " >&6; } + { echo "$as_me:$LINENO: checking for mpf_abs in -lgmp" >&5 +echo $ECHO_N "checking for mpf_abs in -lgmp... $ECHO_C" >&6; } if test "${ac_cv_lib_gmp_mpf_abs+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgmp $LIBS" @@ -24077,36 +17615,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_gmp_mpf_abs=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_gmp_mpf_abs=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_gmp_mpf_abs" >&5 -$as_echo "$ac_cv_lib_gmp_mpf_abs" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_gmp_mpf_abs" >&5 +echo "${ECHO_T}$ac_cv_lib_gmp_mpf_abs" >&6; } if test $ac_cv_lib_gmp_mpf_abs = yes; then gmp_ok=yes else @@ -24114,10 +17648,10 @@ else fi if test "$gmp_ok" = no; then - { $as_echo "$as_me:$LINENO: checking for __gmpf_abs in -lgmp" >&5 -$as_echo_n "checking for __gmpf_abs in -lgmp... " >&6; } + { echo "$as_me:$LINENO: checking for __gmpf_abs in -lgmp" >&5 +echo $ECHO_N "checking for __gmpf_abs in -lgmp... $ECHO_C" >&6; } if test "${ac_cv_lib_gmp___gmpf_abs+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgmp $LIBS" @@ -24149,36 +17683,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_gmp___gmpf_abs=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_gmp___gmpf_abs=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_gmp___gmpf_abs" >&5 -$as_echo "$ac_cv_lib_gmp___gmpf_abs" >&6; } +{ echo "$as_me:$LINENO: result: $ac_cv_lib_gmp___gmpf_abs" >&5 +echo "${ECHO_T}$ac_cv_lib_gmp___gmpf_abs" >&6; } if test $ac_cv_lib_gmp___gmpf_abs = yes; then gmp_ok=yes else @@ -24198,10 +17728,10 @@ fi # Check whether nl_langinfo(CODESET) is supported, needed by Unicode.m. #-------------------------------------------------------------------- - { $as_echo "$as_me:$LINENO: checking for nl_langinfo and CODESET" >&5 -$as_echo_n "checking for nl_langinfo and CODESET... " >&6; } + { echo "$as_me:$LINENO: checking for nl_langinfo and CODESET" >&5 +echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6; } if test "${am_cv_langinfo_codeset+set}" = set; then - $as_echo_n "(cached) " >&6 + echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -24224,36 +17754,32 @@ case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then am_cv_langinfo_codeset=yes else - $as_echo "$as_me: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 am_cv_langinfo_codeset=no fi -rm -rf conftest.dSYM rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_langinfo_codeset" >&5 -$as_echo "$am_cv_langinfo_codeset" >&6; } +{ echo "$as_me:$LINENO: result: $am_cv_langinfo_codeset" >&5 +echo "${ECHO_T}$am_cv_langinfo_codeset" >&6; } if test $am_cv_langinfo_codeset = yes; then cat >>confdefs.h <<\_ACEOF @@ -24267,94 +17793,6 @@ _ACEOF -#-------------------------------------------------------------------- -# Check for -Wdeclaration-after-statement -#-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking whether the compiler supports -Wdeclaration-after-statement" >&5 -$as_echo_n "checking whether the compiler supports -Wdeclaration-after-statement... " >&6; } - -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wdeclaration-after-statement" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -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:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - HAS_W_DECL_AFTER_STATEMENT=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - HAS_W_DECL_AFTER_STATEMENT=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -CFLAGS="$saved_CFLAGS" - -{ $as_echo "$as_me:$LINENO: result: $HAS_W_DECL_AFTER_STATEMENT" >&5 -$as_echo "$HAS_W_DECL_AFTER_STATEMENT" >&6; } - -if test x"$HAS_W_DECL_AFTER_STATEMENT" = x"yes"; then - WARN_FLAGS="-Wall -Wdeclaration-after-statement" -else - WARN_FLAGS=-Wall -fi - - - -#-------------------------------------------------------------------- -# Check if we should install gdomap as setuid -#-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking if we should install gdomap as setuid" >&5 -$as_echo_n "checking if we should install gdomap as setuid... " >&6; } -# Check whether --enable-setuid-gdomap was given. -if test "${enable_setuid_gdomap+set}" = set; then - enableval=$enable_setuid_gdomap; ac_cv_setuid_gdomap=$enableval -else - ac_cv_setuid_gdomap="no" -fi - - -if test "$ac_cv_setuid_gdomap" = "yes"; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; - GNUSTEP_INSTALL_GDOMAP_AS_SETUID="yes" -else - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; }; - GNUSTEP_INSTALL_GDOMAP_AS_SETUID="no" -fi - - - #-------------------------------------------------------------------- # Configure flags from sub-configure runs, so they show up in our # help file. @@ -24383,21 +17821,19 @@ else fi - - -subdirs="$subdirs SSL" +subdirs="$subdirs Source/mframe SSL" #-------------------------------------------------------------------- # Record the version #-------------------------------------------------------------------- -{ $as_echo "$as_me:$LINENO: checking for the version of gnustep-base we are compiling" >&5 -$as_echo_n "checking for the version of gnustep-base we are compiling... " >&6; } +{ echo "$as_me:$LINENO: checking for the version of gnustep-base we are compiling" >&5 +echo $ECHO_N "checking for the version of gnustep-base we are compiling... $ECHO_C" >&6; } if test -f "Version"; then . ./Version fi -{ $as_echo "$as_me:$LINENO: result: $VERSION" >&5 -$as_echo "$VERSION" >&6; } +{ echo "$as_me:$LINENO: result: $VERSION" >&5 +echo "${ECHO_T}$VERSION" >&6; } @@ -24436,12 +17872,11 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 -$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +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= ;; #( *) $as_unset $ac_var ;; esac ;; esac @@ -24474,12 +17909,12 @@ $as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -24495,7 +17930,7 @@ ac_ltlibobjs= 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"` + ac_i=`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. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" @@ -24508,12 +17943,11 @@ 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:$LINENO: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -24526,7 +17960,7 @@ ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## @@ -24536,7 +17970,7 @@ 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 + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST @@ -24558,45 +17992,17 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits -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 -if (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=';' - } + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi # Support unset when possible. @@ -24612,6 +18018,8 @@ fi # 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.) +as_nl=' +' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. @@ -24634,7 +18042,7 @@ 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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi @@ -24647,10 +18055,17 @@ PS2='> ' PS4='+ ' # NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && @@ -24672,7 +18087,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | +echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -24723,7 +18138,7 @@ $as_unset CDPATH 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 + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems @@ -24751,6 +18166,7 @@ case `echo -n x` in *) ECHO_N='-n';; esac + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -24763,22 +18179,19 @@ if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null + mkdir conf$$.dir 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 -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln else as_ln_s='cp -p' fi @@ -24803,10 +18216,10 @@ else as_test_x=' eval sh -c '\'' if test -d "$1"; then - test -d "$1/."; + test -d "$1/."; else case $1 in - -*)set "./$1";; + -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi @@ -24829,7 +18242,7 @@ exec 6>&1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.62. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -24842,14 +18255,14 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q` _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. @@ -24862,9 +18275,9 @@ Usage: $0 [OPTIONS] [FILE]... -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 + instantiate the configuration file FILE --header=FILE[:TEMPLATE] - instantiate the configuration header FILE + instantiate the configuration header FILE Configuration files: $config_files @@ -24875,23 +18288,23 @@ $config_headers Report bugs to ." _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.62, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2006 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. +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do @@ -24913,36 +18326,30 @@ do -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 ;; + echo "$ac_cs_version"; 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"` ;; - esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 + { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; + 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_echo "$as_me: error: unrecognized option: $1 + -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; @@ -24961,32 +18368,30 @@ if $ac_cs_silent; then fi _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<_ACEOF 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' + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL export CONFIG_SHELL - exec "\$@" + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX - $as_echo "$ac_log" + echo "$ac_log" } >&5 _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<_ACEOF _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets @@ -24998,8 +18403,8 @@ do "Headers/Additions/GNUstepBase/GSConfig.h") CONFIG_FILES="$CONFIG_FILES Headers/Additions/GNUstepBase/GSConfig.h" ;; "Headers/Additions/GNUstepBase/preface.h") CONFIG_FILES="$CONFIG_FILES Headers/Additions/GNUstepBase/preface.h" ;; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done @@ -25039,142 +18444,232 @@ $debug || (umask 077 && mkdir "$tmp") } || { - $as_echo "$as_me: cannot create a temporary directory in ." >&2 + echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -# 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'. +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then - -ac_cr=' ' -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 {' >"$tmp/subs1.awk" && _ACEOF -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } -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_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +CPP!$CPP$ac_delim +WHOAMI!$WHOAMI$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +GS_WORDS_BIGENDIAN!$GS_WORDS_BIGENDIAN$ac_delim +GS_SINT8!$GS_SINT8$ac_delim +GS_UINT8!$GS_UINT8$ac_delim +ac_cv_sizeof_short!$ac_cv_sizeof_short$ac_delim +ac_cv_sizeof_int!$ac_cv_sizeof_int$ac_delim +ac_cv_sizeof_long!$ac_cv_sizeof_long$ac_delim +ac_cv_sizeof_long_long!$ac_cv_sizeof_long_long$ac_delim +ac_cv_sizeof_float!$ac_cv_sizeof_float$ac_delim +ac_cv_sizeof_double!$ac_cv_sizeof_double$ac_delim +ac_cv_sizeof_voidp!$ac_cv_sizeof_voidp$ac_delim +GS_SADDR!$GS_SADDR$ac_delim +GS_UADDR!$GS_UADDR$ac_delim +GS_SINT16!$GS_SINT16$ac_delim +GS_UINT16!$GS_UINT16$ac_delim +GS_SINT32!$GS_SINT32$ac_delim +GS_UINT32!$GS_UINT32$ac_delim +GS_SINT64!$GS_SINT64$ac_delim +GS_UINT64!$GS_UINT64$ac_delim +GS_HAVE_I64!$GS_HAVE_I64$ac_delim +GS_SINT128!$GS_SINT128$ac_delim +GS_UINT128!$GS_UINT128$ac_delim +GS_HAVE_I128!$GS_HAVE_I128$ac_delim +GS_FLT32!$GS_FLT32$ac_delim +GS_FLT64!$GS_FLT64$ac_delim +_GSC_S_SHT!$_GSC_S_SHT$ac_delim +_GSC_S_INT!$_GSC_S_INT$ac_delim +_GSC_S_LNG!$_GSC_S_LNG$ac_delim +_GSC_S_LNG_LNG!$_GSC_S_LNG_LNG$ac_delim +DYNAMIC_LINKER!$DYNAMIC_LINKER$ac_delim +NX_CONST_STRING_OBJCFLAGS!$NX_CONST_STRING_OBJCFLAGS$ac_delim +NX_CONST_STRING_CLASS!$NX_CONST_STRING_CLASS$ac_delim +HAVE_PTHREAD_H!$HAVE_PTHREAD_H$ac_delim +HAVE_PTS_STREAM_MODULES!$HAVE_PTS_STREAM_MODULES$ac_delim +INCLUDE_STDINT!$INCLUDE_STDINT$ac_delim +DEFINE_INT8_T!$DEFINE_INT8_T$ac_delim +DEFINE_UINT8_T!$DEFINE_UINT8_T$ac_delim +DEFINE_INT16_T!$DEFINE_INT16_T$ac_delim +_ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` = $ac_delim_num; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } 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 >>"\$tmp/subs1.awk" <<\\_ACAWK && +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b _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 >>"\$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 +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +CEOF$ac_eof _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 < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +DEFINE_UINT16_T!$DEFINE_UINT16_T$ac_delim +DEFINE_INT32_T!$DEFINE_INT32_T$ac_delim +DEFINE_UINT32_T!$DEFINE_UINT32_T$ac_delim +DEFINE_INT64_T!$DEFINE_INT64_T$ac_delim +DEFINE_UINT64_T!$DEFINE_UINT64_T$ac_delim +DEFINE_INTPTR_T!$DEFINE_INTPTR_T$ac_delim +DEFINE_UINTPTR_T!$DEFINE_UINTPTR_T$ac_delim +USE_ZLIB!$USE_ZLIB$ac_delim +HAVE_INET_PTON!$HAVE_INET_PTON$ac_delim +GS_PASS_ARGUMENTS!$GS_PASS_ARGUMENTS$ac_delim +GS_FAKE_MAIN!$GS_FAKE_MAIN$ac_delim +WITH_FFI!$WITH_FFI$ac_delim +XML2_CONFIG!$XML2_CONFIG$ac_delim +XML_CONFIG!$XML_CONFIG$ac_delim +XML_CFLAGS!$XML_CFLAGS$ac_delim +XML_LIBS!$XML_LIBS$ac_delim +HAVE_LIBXSLT!$HAVE_LIBXSLT$ac_delim +HAVE_LIBXML!$HAVE_LIBXML$ac_delim +HAVE_MDNS!$HAVE_MDNS$ac_delim +USE_GMP!$USE_GMP$ac_delim +INCLUDE_FLAGS!$INCLUDE_FLAGS$ac_delim +LDIR_FLAGS!$LDIR_FLAGS$ac_delim +subdirs!$subdirs$ac_delim +VERSION!$VERSION$ac_delim +MAJOR_VERSION!$MAJOR_VERSION$ac_delim +MINOR_VERSION!$MINOR_VERSION$ac_delim +SUBMINOR_VERSION!$SUBMINOR_VERSION$ac_delim +GCC_VERSION!$GCC_VERSION$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 30; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and @@ -25191,133 +18686,19 @@ s/^[^=]*=[ ]*$// }' fi -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then - break - elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - prefix = substr(line, 1, index(line, defundef) - 1) - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", line, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " -shift -for ac_tag +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 -$as_echo "$as_me: error: Invalid tag $ac_tag." >&2;} + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; @@ -25346,38 +18727,26 @@ $as_echo "$as_me: error: Invalid tag $ac_tag." >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" + ac_file_inputs="$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.' + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} + { echo "$as_me:$LINENO: creating $ac_file" >&5 +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 >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; + *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac @@ -25387,7 +18756,7 @@ $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" | +echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -25413,7 +18782,7 @@ $as_echo X"$ac_file" | as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -25422,7 +18791,7 @@ $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" | +echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -25443,17 +18812,17 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } 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|^\.[\\/]||'` + ac_dir_suffix=/`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|/||'` + ac_top_builddir_sub=`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/ ;; @@ -25489,13 +18858,12 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF # 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/ { +case `sed -n '/datarootdir/ { p q } @@ -25504,14 +18872,13 @@ ac_sed_dataroot=' /@infodir@/p /@localedir@/p /@mandir@/p -' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$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;} + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<_ACEOF ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g @@ -25525,16 +18892,15 @@ _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 +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub $extrasub _ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t +s&@configure_input@&$configure_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 @@ -25543,58 +18909,119 @@ 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 "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { echo "$as_me:$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' +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 "$tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; - esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac ;; :H) # # CONFIG_HEADER # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} else - rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + rm -f $ac_file + mv "$tmp/config.h" $ac_file fi else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } + echo "/* $configure_input */" + cat "$ac_result" fi + rm -f "$tmp/out12" ;; @@ -25608,11 +19035,6 @@ _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save -test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } - # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. @@ -25640,8 +19062,7 @@ fi # if test "$no_recursion" != yes; then - # Remove --cache-file, --srcdir, and --disable-option-checking arguments - # so they do not pile up. + # Remove --cache-file and --srcdir arguments so they do not pile up. ac_sub_configure_args= ac_prev= eval "set x $ac_configure_args" @@ -25670,11 +19091,9 @@ if test "$no_recursion" != yes; then ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ;; - --disable-option-checking) - ;; *) case $ac_arg in - *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;; esac @@ -25684,7 +19103,7 @@ if test "$no_recursion" != yes; then # in subdir configurations. ac_arg="--prefix=$prefix" case $ac_arg in - *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args" @@ -25693,10 +19112,6 @@ if test "$no_recursion" != yes; then ac_sub_configure_args="--silent $ac_sub_configure_args" fi - # Always prepend --disable-option-checking to silence warnings, since - # different subdirs can have different --enable and --with options. - ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args" - ac_popdir=`pwd` for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue @@ -25705,8 +19120,8 @@ if test "$no_recursion" != yes; then test -d "$srcdir/$ac_dir" || continue ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)" - $as_echo "$as_me:$LINENO: $ac_msg" >&5 - $as_echo "$ac_msg" >&6 + echo "$as_me:$LINENO: $ac_msg" >&5 + echo "$ac_msg" >&6 { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; @@ -25715,7 +19130,7 @@ if test "$no_recursion" != yes; then as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -25724,7 +19139,7 @@ $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" | +echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -25745,17 +19160,17 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } 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|^\.[\\/]||'` + ac_dir_suffix=/`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|/||'` + ac_top_builddir_sub=`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/ ;; @@ -25794,8 +19209,8 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else - { $as_echo "$as_me:$LINENO: WARNING: no configuration information is in $ac_dir" >&5 -$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} + { echo "$as_me:$LINENO: WARNING: no configuration information is in $ac_dir" >&5 +echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_configure= fi @@ -25808,21 +19223,17 @@ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_cache_file=$ac_top_build_prefix$cache_file ;; esac - { $as_echo "$as_me:$LINENO: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 -$as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} + { echo "$as_me:$LINENO: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 +echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || - { { $as_echo "$as_me:$LINENO: error: $ac_sub_configure failed for $ac_dir" >&5 -$as_echo "$as_me: error: $ac_sub_configure failed for $ac_dir" >&2;} + { { echo "$as_me:$LINENO: error: $ac_sub_configure failed for $ac_dir" >&5 +echo "$as_me: error: $ac_sub_configure failed for $ac_dir" >&2;} { (exit 1); exit 1; }; } fi cd "$ac_popdir" done fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;} -fi diff --git a/configure.ac b/configure.ac index c976e7752..96fffa5db 100644 --- a/configure.ac +++ b/configure.ac @@ -27,13 +27,10 @@ builtin(include, config/objc-sys-dynamic.m4)dnl builtin(include, config/procfs-exe-link.m4)dnl builtin(include, config/procfs.m4)dnl builtin(include, config/pathxml.m4)dnl -builtin(include, config/pathtls.m4)dnl builtin(include, config/codeset.m4)dnl builtin(include, config/addlibrarypath.m4)dnl -builtin(include, config/icu.m4)dnl AC_INIT -AC_PREREQ([2.60]) AC_CONFIG_SRCDIR([Source/NSArray.m]) # If GNUSTEP_MAKEFILES is undefined, try to use gnustep-config to determine it. @@ -45,31 +42,6 @@ if test -z "$GNUSTEP_MAKEFILES"; then AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!]) fi -# If LIBRARY_COMBO is undefined, try to use gnustep-config to determine it. -if test -z "$LIBRARY_COMBO"; then - LIBRARY_COMBO=`gnustep-config --variable=LIBRARY_COMBO 2>&5` -fi - -exceptions=`gnustep-config --objc-flags | grep _NATIVE_OBJC_EXCEPTIONS 2>&5` -if test -z "$exceptions"; then - exceptions=no - BASE_NATIVE_OBJC_EXCEPTIONS=0 -else - exceptions=yes - BASE_NATIVE_OBJC_EXCEPTIONS=1 -fi -AC_SUBST(BASE_NATIVE_OBJC_EXCEPTIONS) - -nonfragile=`gnustep-config --objc-flags | grep _NONFRAGILE_ABI 2>&5` -if test -z "$nonfragile"; then - nonfragile=no - BASE_NONFRAGILE_ABI=0 -else - nonfragile=yes - BASE_NONFRAGILE_ABI=1 -fi -AC_SUBST(BASE_NONFRAGILE_ABI) - # We shouldn't be loading GNUstep.sh here. It would load in a lot of # variables which might get confused with the ones that will be used # at runtime. We will load it later once we have determined (and @@ -217,6 +189,7 @@ case "$target_os" in GNUSTEP_SYSTEM_ROOT=/usr/GNUstep/System GNUSTEP_LOCAL_ROOT=/usr/GNUstep/Local GNUSTEP_NETWORK_ROOT=/usr/GNUstep/Local + GNUSTEP_USER_DIR=GNUstep GNUSTEP_USER_DEFAULTS_DIR=GNUstep/Defaults GNUSTEP_USER_CONFIG_FILE=.GNUstep.conf ;; @@ -370,75 +343,18 @@ if test x"$GNUSTEP_USER_DIR_DOC" = x""; then GNUSTEP_USER_DIR_DOC=$GNUSTEP_USER_ if test x"$GNUSTEP_USER_DIR_DOC_MAN" = x""; then GNUSTEP_USER_DIR_DOC_MAN=$GNUSTEP_USER_DIR/Documentation/man; fi if test x"$GNUSTEP_USER_DIR_DOC_INFO" = x""; then GNUSTEP_USER_DIR_DOC_INFO=$GNUSTEP_USER_DIR/Documentation/info; fi -AC_MSG_CHECKING([for GNUstep-base installation domain]) -AC_ARG_WITH(installation-domain, -[ --with-installation-domain=DOMAIN - Specify the domain (SYSTEM, LOCAL, - NETWORK or USER) into which - gnustep-base will be installed. - Whenever relative paths are hardcoded - into gnustep-base (at the moment, this - happens only on MinGW) this option - must be used and must match the domain - where you will be installing - gnustep-base. - If this is not specified, the output of - gnustep-config --installation-domain-for=gnustep-base - (which should normally be LOCAL) is used.], - result="$withval", - result="no" -) -if test "$result" = "no" -then - # Check if gnustep-config supports the option - # --installation-domain-for, and use it if available. That option - # will automatically use the shell variable GNUSTEP_INSTALLATION_DOMAIN or - # the installation-domains.conf files (or the LOCAL default) as appropriate. - # Otherwise, if that option is not available just fall back to - # using GNUSTEP_INSTALLATION_DOMAIN or (if that was not defiend) LOCAL. - if (gnustep-config --help | grep installation-domain) >&5 2>&5 - then - result=`gnustep-config --installation-domain-for=gnustep-base 2>&5` - else - AC_MSG_WARN([The 'gnustep-config' script was not found or out of date.]) - result=$GNUSTEP_INSTALLATION_DOMAIN - if test "$result" = "" - then - # This case was added on December 2008 and is only for backwards - # compatibility with older versions of gnustep-make. - result=LOCAL - fi - fi -fi -case "$result" in - SYSTEM) - AC_MSG_RESULT([SYSTEM]) - GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS";; - LOCAL) - AC_MSG_RESULT([LOCAL]) - GNUSTEP_BASE_PATH="$GNUSTEP_LOCAL_TOOLS";; - NETWORK) - AC_MSG_RESULT([NETWORK]) - GNUSTEP_BASE_PATH="$GNUSTEP_NETWORK_TOOLS";; - USER) - AC_MSG_RESULT([USER]) - GNUSTEP_BASE_PATH="$GNUSTEP_USER_TOOLS";; - *) - AC_MSG_ERROR([Unknown installation domain '$result' (it should be SYSTEM, LOCAL, NETWORK or USER). Please run configure again with the option --with-installation-domain=LOCAL (or whatever domain you want to install into).]) - exit 1;; -esac -# We store GNUSTEP_BASE_DOMAIN in config.mak so that we can check -# at runtime and make sure it is consistent with the -# GNUSTEP_INSTALLATION_DOMAIN that is used at runtime. -GNUSTEP_BASE_DOMAIN=$result -AC_SUBST(GNUSTEP_BASE_DOMAIN) - # # If we are on mingw, we now want to convert the paths to relative # paths (relative to libgnustep-base.dll). # +# TODO: To do it properly, we ought to allow the user to configure +# the installation domain at configure time! This assumes we always +# install into System. +# case "$target_os" in mingw*) + GNUSTEP_BASE_PATH="$GNUSTEP_SYSTEM_TOOLS" + # TODO: Improve this hack. # According to Wikipedia, this is the default for Windows 2000, # Windows XP and Windows Server 2003. For Windows Vista this will @@ -448,15 +364,6 @@ case "$target_os" in GNUSTEP_NETWORK_USERS_DIR="C:\Documents and Settings" GNUSTEP_LOCAL_USERS_DIR="C:\Documents and Settings" - # TODO: It would be nice to use the 'short' output of - # relative_path.sh, but older versions of relative_path.sh - # did not support specifying the type of output and - # would abort if they were given more than 2 parameters, - # so we can not use the 'short' option if we want gnustep-base - # to work with older versions of gnustep-make. - # Once everyone has upgraded to gnustep-make >= 2.0.5 (I'd say - # two years after it has been released ?), we could switch to the - # 'short' output though. GNUSTEP_SYSTEM_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_APPS` GNUSTEP_SYSTEM_ADMIN_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_ADMIN_APPS` GNUSTEP_SYSTEM_WEB_APPS=`$GNUSTEP_MAKEFILES/relative_path.sh $GNUSTEP_BASE_PATH $GNUSTEP_SYSTEM_WEB_APPS` @@ -497,32 +404,6 @@ case "$target_os" in ;; esac -GNUSTEP_BASE_RELATIVE_PATHS=no - -# Now, check if any of the paths is a relative path. -for path in \ - "$GNUSTEP_SYSTEM_APPS" "$GNUSTEP_SYSTEM_ADMIN_APPS" "$GNUSTEP_SYSTEM_WEB_APPS" \ - "$GNUSTEP_SYSTEM_TOOLS" "$GNUSTEP_SYSTEM_ADMIN_TOOLS" \ - "$GNUSTEP_SYSTEM_LIBRARY" "$GNUSTEP_SYSTEM_LIBRARIES" "$GNUSTEP_SYSTEM_HEADERS" \ - "$GNUSTEP_SYSTEM_DOC" "$GNUSTEP_SYSTEM_DOC_MAN" "$GNUSTEP_SYSTEM_DOC_INFO" \ - "$GNUSTEP_NETWORK_APPS" "$GNUSTEP_NETWORK_ADMIN_APPS" "$GNUSTEP_NETWORK_WEB_APPS" \ - "$GNUSTEP_NETWORK_TOOLS" "$GNUSTEP_NETWORK_ADMIN_TOOLS" \ - "$GNUSTEP_NETWORK_LIBRARY" "$GNUSTEP_NETWORK_LIBRARIES" "$GNUSTEP_NETWORK_HEADERS" \ - "$GNUSTEP_NETWORK_DOC" "$GNUSTEP_NETWORK_DOC_MAN" "$GNUSTEP_NETWORK_DOC_INFO" \ - "$GNUSTEP_LOCAL_APPS" "$GNUSTEP_LOCAL_ADMIN_APPS" "$GNUSTEP_LOCAL_WEB_APPS" \ - "$GNUSTEP_LOCAL_TOOLS" "$GNUSTEP_LOCAL_ADMIN_TOOLS" \ - "$GNUSTEP_LOCAL_LIBRARY" "$GNUSTEP_LOCAL_LIBRARIES" "$GNUSTEP_LOCAL_HEADERS" \ - "$GNUSTEP_LOCAL_DOC" "$GNUSTEP_LOCAL_DOC_MAN" "$GNUSTEP_LOCAL_DOC_INFO"; do -case "$path" in - ./*) GNUSTEP_BASE_RELATIVE_PATHS=yes ;; - ../*) GNUSTEP_BASE_RELATIVE_PATHS=yes ;; -esac -done - -AC_MSG_CHECKING([if we are hardcoding any relative paths in gnustep-base]) -AC_MSG_RESULT($GNUSTEP_BASE_RELATIVE_PATHS) -AC_SUBST(GNUSTEP_BASE_RELATIVE_PATHS) - # # Now, we want to print out the paths that we're going to hardcode # into gnustep-base. This is to help users in finding @@ -531,6 +412,8 @@ AC_SUBST(GNUSTEP_BASE_RELATIVE_PATHS) AC_MSG_NOTICE([We store the following filesystem layout into gnustep-base, to be used when no config file is found]) AC_MSG_CHECKING([for Makefiles directory]) AC_MSG_RESULT($GNUSTEP_MAKEFILES) +AC_MSG_CHECKING([for user directory]) +AC_MSG_RESULT($GNUSTEP_USER_DIR) AC_MSG_CHECKING([for user defaults directory]) AC_MSG_RESULT($GNUSTEP_USER_DEFAULTS_DIR) AC_MSG_CHECKING([for user config file]) @@ -643,6 +526,10 @@ GNUSTEP_MAKEFILES=`echo $GNUSTEP_MAKEFILES|sed -e 's/\\\\/\\\\\\\\/g'` AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_MAKEFILES, "$GNUSTEP_MAKEFILES", [Built in default value for GNUstep Makefiles]) +GNUSTEP_USER_DIR=`echo $GNUSTEP_USER_DIR|sed -e 's/\\\\/\\\\\\\\/g'` +AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DIR, + "$GNUSTEP_USER_DIR", + [Built in default value for GNUstep user directory]) GNUSTEP_USER_DEFAULTS_DIR=`echo $GNUSTEP_USER_DEFAULTS_DIR|sed -e 's/\\\\/\\\\\\\\/g'` AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_USER_DEFAULTS_DIR, "$GNUSTEP_USER_DEFAULTS_DIR", @@ -901,6 +788,12 @@ AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_USERS_DIR, "$GNUSTEP_TARGET_LOCAL_USERS_DIR", [Built in default value for GNUstep Local Users directory]) + +#------------------------------------------------------------------------------ +# Now we have finished configuring the default GNUstep filesystem setup of +# the target. All GNUstep variables from now on are the ones used to build +#------------------------------------------------------------------------------ + # # Now load the values to be used in locating libraries etc used when # building the base library ... as supplied by the gnustep-make package @@ -909,16 +802,11 @@ AC_DEFINE_UNQUOTED(GNUSTEP_TARGET_LOCAL_USERS_DIR, # ask it to output all variables! That way we have access to (eg) # GNUSTEP_SYSTEM_HEADERS below. # -# We need to unset any values that we really need, or existing settings +# We need to unles any values that we really need, or existing settings # would be used by GNUstep.sh # unset GNUSTEP_SYSTEM_HEADERS unset GNUSTEP_SYSTEM_LIBRARIES -unset GNUSTEP_NETWORK_HEADERS -unset GNUSTEP_NETWORK_LIBRARIES -unset GNUSTEP_LOCAL_HEADERS -unset GNUSTEP_LOCAL_LIBRARIES -GNUSTEP_MAKEFILES="$CURRENT_GNUSTEP_MAKEFILES" GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes . "$CURRENT_GNUSTEP_MAKEFILES/GNUstep.sh" unset GNUSTEP_SH_EXPORT_ALL_VARIABLES @@ -933,54 +821,19 @@ if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries" fi -if test x"$GNUSTEP_NETWORK_HEADERS" = x""; then - GNUSTEP_NETWORK_HEADERS="$GNUSTEP_NETWORK_ROOT/Library/Headers" -fi - -if test x"$GNUSTEP_NETWORK_LIBRARIES" = x""; then - GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_ROOT/Library/Libraries" -fi - -if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then - GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_ROOT/Library/Headers" -fi - -if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then - GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_ROOT/Library/Libraries" -fi - -if test x"$GNUSTEP_IS_FLATTENED" = x"no"; then - GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO" - GNUSTEP_NETWORK_HEADERS="$GNUSTEP_NETWORK_HEADERS/$LIBRARY_COMBO" - GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_HEADERS/$LIBRARY_COMBO" - # FIXME: Cross-compiling should read the target from the configure - # options and use it. GNUSTEP_TARGET_* variables do not exist in - # this context (so "$GNUSTEP_TARGET_CPU" will always be "") - if test x"$GNUSTEP_TARGET_CPU" = x""; then - GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_LIBRARIES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" - GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_LIBRARIES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" - GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_LIBRARIES/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO" - else - GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_LIBRARIES/$GNUSTEP_TARGET_CPU/$GNUSTEP_TARGET_OS/$LIBRARY_COMBO" - GNUSTEP_NETWORK_LIBRARIES="$GNUSTEP_NETWORK_LIBRARIES/$GNUSTEP_TARGET_CPU/$GNUSTEP_TARGET_OS/$LIBRARY_COMBO" - GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_LIBRARIES/$GNUSTEP_TARGET_CPU/$GNUSTEP_TARGET_OS/$LIBRARY_COMBO" - fi -fi - # # Add standard library and header directories for configure to use to locate # plain C developer headers/libraries which haver been installed in the # GNUstep hierarchy. # -CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS -I$GNUSTEP_NETWORK_HEADERS -I$GNUSTEP_LOCAL_HEADERS" -LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES -L$GNUSTEP_NETWORK_LIBRARIES -L$GNUSTEP_LOCAL_LIBRARIES" +CPPFLAGS="$CPPFLAGS -I$GNUSTEP_SYSTEM_HEADERS" +LDFLAGS="$LDFLAGS -L$GNUSTEP_SYSTEM_LIBRARIES" #-------------------------------------------------------------------- # Find the compiler #-------------------------------------------------------------------- AC_PROG_CC AC_PROG_CPP -AC_USE_SYSTEM_EXTENSIONS AC_PATH_PROG(WHOAMI, whoami, echo, $PATH:/usr/ucb) @@ -999,21 +852,29 @@ case "$target_os" in LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";; esac +#---------------------------------------------------------------- +# Find out if nested functions work on this machine +#---------------------------------------------------------------- +AC_MSG_CHECKING(whether nested functions work) +AC_TRY_RUN([#include "$srcdir/config/config.nested.c"], + gcc_nested=1, gcc_nested=0, gcc_nested=1) +if test $gcc_nested = 0; then + AC_MSG_RESULT(no) + AC_DEFINE(BROKEN_NESTED_FUNCTIONS,1, + [Define if nested functions are broken on this compiler]) +else + AC_MSG_RESULT(yes) +fi + #-------------------------------------------------------------------- # Set Apple/Darwin/OSX/NeXT information for other tests #-------------------------------------------------------------------- -OBJC_WITH_GC=no OBJC_RUNTIME_LIB=`echo $LIBRARY_COMBO | tr '-' ' ' | awk '{print $1}'` AC_MSG_CHECKING(the Objective-C runtime) if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then AC_MSG_RESULT(NeXT) LIBOBJC='-lobjc' OBJCFLAGS="-fnext-runtime -DNeXT_RUNTIME" -elif test "$OBJC_RUNTIME_LIB" = "gnugc"; then - AC_MSG_RESULT(GNU) - LIBOBJC='-lobjc_gc -ldl -lgc' - OBJCFLAGS="-fgnu-runtime" - OBJC_WITH_GC=yes else AC_MSG_RESULT(GNU) LIBOBJC='-lobjc' @@ -1023,82 +884,31 @@ fi #-------------------------------------------------------------------- # Miscellaneous flags #-------------------------------------------------------------------- - -# Check to see if the libobjc library is in our GNUSTEP_SYSTEM_LIBRARIES. -# If so, there are probably other libraries that we want there also, so -# leave the proper includes in CPPFLAGS and LDFLAGS -AC_MSG_CHECKING(for custom shared objc library) -AC_CACHE_VAL(gs_cv_objc_libdir, -[dnl -gs_cv_objc_libdir=NONE -gs_cv_objc_incdir=NONE -# Try GNUSTEP_SYSTEM_LIBRARIES first -if test "$GNUSTEP_IS_FLATTENED" = yes; then - GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES" - GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS" -else +# Set location of GNUstep dirs for later use +if test "$GNUSTEP_IS_FLATTENED" = no; then + clean_target_os=`$CURRENT_GNUSTEP_MAKEFILES/clean_os.sh $target_os` + clean_target_cpu=`$CURRENT_GNUSTEP_MAKEFILES/clean_cpu.sh $target_cpu` + obj_dir=$clean_target_cpu/$clean_target_os + lobj_dir=$clean_target_cpu/$clean_target_os/$LIBRARY_COMBO GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES/$obj_dir" GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO" -fi - -if test -f "$GNUSTEP_HDIR/objc/objc.h"; then - if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then - gs_cv_objc_libdir="$GNUSTEP_LDIR" - gs_cv_objc_incdir="$GNUSTEP_HDIR" - fi -fi - -# Try GNUSTEP_NETWORK_LIBRARIES second (override GNUSTEP_SYSTEM if -# found) -if test "$GNUSTEP_IS_FLATTENED" = yes; then - GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES" - GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS" else - GNUSTEP_LDIR="$GNUSTEP_NETWORK_LIBRARIES/$obj_dir" - GNUSTEP_HDIR="$GNUSTEP_NETWORK_HEADERS/$LIBRARY_COMBO" + obj_dir= + lobj_dir= + GNUSTEP_LDIR="$GNUSTEP_SYSTEM_LIBRARIES" + GNUSTEP_HDIR="$GNUSTEP_SYSTEM_HEADERS" fi -if test -f "$GNUSTEP_HDIR/objc/objc.h"; then - if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then - gs_cv_objc_libdir="$GNUSTEP_LDIR" - gs_cv_objc_incdir="$GNUSTEP_HDIR" - fi -fi - -# Try GNUSTEP_LOCAL_LIBRARIES third (override GNUSTEP_SYSTEM and -# GNUSTEP_NETWORK if found) -if test "$GNUSTEP_IS_FLATTENED" = yes; then - GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES" - GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS" -else - GNUSTEP_LDIR="$GNUSTEP_LOCAL_LIBRARIES/$obj_dir" - GNUSTEP_HDIR="$GNUSTEP_LOCAL_HEADERS/$LIBRARY_COMBO" -fi - -if test -f "$GNUSTEP_HDIR/objc/objc.h"; then - if test -f "$GNUSTEP_LDIR/libobjc.a" -o -f "$GNUSTEP_LDIR/libobjc.so" -o -f "$GNUSTEP_LDIR/libobjc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc-gnu.dylib" -o -f "$GNUSTEP_LDIR/libobjc_gc.a" -o -f "$GNUSTEP_LDIR/libobjc_gc.so" -o -f "$GNUSTEP_LDIR/libobjc_gc.dll.a" -o -f "$GNUSTEP_LDIR/libobjc_gc-gnu.dylib"; then - gs_cv_objc_libdir="$GNUSTEP_LDIR" - gs_cv_objc_incdir="$GNUSTEP_HDIR" - fi -fi -]) -AC_MSG_RESULT($gs_cv_objc_libdir) - -if test "$gs_cv_objc_libdir" != "NONE"; then - # - # The following one is so that headers of custom libraries into - # $GNUSTEP_HDIR are used before the standard ones - # - INCLUDE_FLAGS="$INCLUDE_FLAGS -I$gs_cv_objc_incdir" - LDIR_FLAGS="$LDIR_FLAGS -L$gs_cv_objc_libdir/$LIBRARY_COMBO -L$gs_cv_objc_libdir" - CPPFLAGS="$CPPFLAGS -I$gs_cv_objc_incdir" - LDFLAGS="$LDFLAGS -L$gs_cv_objc_libdir" -fi +# +# The following one is so that headers of custom libraries into +# $GNUSTEP_HDIR are used before the standard ones +# +INCLUDE_FLAGS="$INCLUDE_FLAGS -I$GNUSTEP_HDIR" +LDIR_FLAGS="$LDIR_FLAGS -L$GNUSTEP_LDIR/$LIBRARY_COMBO -L$GNUSTEP_LDIR" #-------------------------------------------------------------------- # Check if Objective-C is installed #-------------------------------------------------------------------- -AC_CHECK_HEADERS(objc/runtime.h) AC_CHECK_HEADERS(objc/objc.h) if test $ac_cv_header_objc_objc_h = no; then echo "Check to make sure you have a full installation of the GCC" @@ -1106,36 +916,6 @@ if test $ac_cv_header_objc_objc_h = no; then AC_MSG_ERROR(Could not find Objective-C headers) fi -if test $OBJC_WITH_GC = yes; then - AC_CHECK_HEADERS(gc.h, gc_ok=yes, gc_ok=no) - if test "$gc_ok" = no; then - AC_MSG_ERROR([Garbage collection was required, but the gc.h header couldn't be found.]) - fi - saved_LIBS="$LIBS" - LIBS+=" -lgc" - AC_CHECK_FUNC(GC_malloc, gc_ok=yes, gc_ok=no) - if test "$gc_ok" = no; then - AC_MSG_ERROR([Garbage collection was required, but the gc library couldn't be found.]) - fi - AC_CHECK_FUNC(GC_register_my_thread) - if test "$ac_cv_func_GC_register_my_thread" = yes; then - AC_DEFINE(HAVE_GC_REGISTER_MY_THREAD,1, - [Define if GC_register_my_thread function is available]) - fi - AC_CHECK_FUNC(GC_allow_register_threads) - if test "$ac_cv_func_GC_allow_register_threads" = yes; then - AC_DEFINE(HAVE_GC_ALLOW_REGISTER_THREADS,1, - [Define if GC_allow_register_threads function is available]) - fi - LIBS="-lobjc_gc -ldl" - AC_CHECK_FUNC(class_ivar_set_gcinvisible, gc_ok=yes, gc_ok=no) - if test "$gc_ok" = no; then - AC_MSG_ERROR([Garbage collection was required, but the gc runtime couldn't be found.]) - fi - LIBS="$saved_LIBS" - AC_SUBST(OBJC_WITH_GC) -fi - #-------------------------------------------------------------------- # Check for strange network stuff used by gdomap #-------------------------------------------------------------------- @@ -1340,8 +1120,8 @@ else else # 128-bit ints not supported - but we need a dummy type for byte-swapping # of 128-bit values arriving from another system. - GS_SINT128="struct { gsu8 a[[16]]; }" - GS_UINT128="struct { gsu8 a[[16]]; }" + GS_SINT128="struct { gsu8 a[16]; }" + GS_UINT128="struct { gsu8 a[16]; }" GS_HAVE_I128=0 fi fi @@ -1459,45 +1239,29 @@ fi # Don't revert any Objective-C flags as they are used in the next test #--------------------------------------------------------------------- -# See if we are using a compiler which allows us to change the class +# Guess if we are using a compiler which allows us to change the class # to be used for constant strings by using the -fconstant-string-class # option. If that is the case, we change it to NSConstantString. -# Unless we are building for the apple runtime (ie only building base -# additions library and not implementing a constant string class). #--------------------------------------------------------------------- -if test "$OBJC_RUNTIME_LIB" = "nx" -o "$OBJC_RUNTIME_LIB" = "apple"; then +strclass_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString" +AC_MSG_CHECKING(if the compiler supports -fconstant-string-class) +AC_CACHE_VAL(objc_compiler_supports_constant_string_class, + AC_TRY_RUN([#include "$srcdir/config/config.constant-string-class.m"], + objc_compiler_supports_constant_string_class=yes, + objc_compiler_supports_constant_string_class=no, + objc_compiler_supports_constant_string_class=no) +) +if test $objc_compiler_supports_constant_string_class = yes; then + NX_CONST_STRING_OBJCFLAGS="-fconstant-string-class=NSConstantString" + NX_CONST_STRING_CLASS=NSConstantString + AC_MSG_RESULT(yes) +else NX_CONST_STRING_OBJCFLAGS="" NX_CONST_STRING_CLASS=NXConstantString -else - strclass_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -fconstant-string-class=FooConstantString" - AC_MSG_CHECKING(if the compiler supports -fconstant-string-class) - AC_CACHE_VAL(objc_compiler_supports_constant_string_class, - AC_TRY_RUN([#include "$srcdir/config/config.constant-string-class.m"], - objc_compiler_supports_constant_string_class=yes, - objc_compiler_supports_constant_string_class=no, - objc_compiler_supports_constant_string_class=no) - ) - if test $objc_compiler_supports_constant_string_class = yes; then - NX_CONST_STRING_OBJCFLAGS="-fconstant-string-class=NSConstantString" - NX_CONST_STRING_CLASS=NSConstantString - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - AC_ARG_ENABLE(nxconstantstring, - [ --enable-nxconstantstring - Enables the use of the NXConstantString class for old compilers.],, - enable_nxconstantstring=no) - if test $enable_nxconstantstring = yes; then - NX_CONST_STRING_OBJCFLAGS="" - NX_CONST_STRING_CLASS=NXConstantString - AC_MSG_WARN([You have enabled the use of NXConstantString as the string class in gnustep-base. The objective-c runtime library typically implements its own class of the same name, so you must either enforce a link order which ensures that the gnustep-base implementation is used, or (better) you must remove the class from the runtime library!]) - else - AC_MSG_ERROR([Your compiler does not appear to implement the -fconstant-string-class option needed for support of strings. Please check for a more recent version or consider using --enable-nxconstantstring]) - fi - fi - CPPFLAGS="$strclass_CPPFLAGS" + AC_MSG_RESULT(no) fi +CPPFLAGS="$strclass_CPPFLAGS" AC_SUBST(NX_CONST_STRING_OBJCFLAGS) AC_SUBST(NX_CONST_STRING_CLASS) @@ -1528,113 +1292,16 @@ fi # Don't revert any Objective-C flags as they are used in the next test #-------------------------------------------------------------------- -# Check for ability to add a thread in runtime -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(objc_thread_add) - -#-------------------------------------------------------------------- -# Check for thread synchronisation support in runtime -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(objc_sync_enter) -if test $ac_cv_func_objc_sync_enter = yes ; then - OBJCSYNC=1 -else - OBJCSYNC=0 -fi -AC_SUBST(OBJCSYNC) - -#-------------------------------------------------------------------- -# Check for ObjC2 support in runtime -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(objc_setProperty) -if test $ac_cv_func_objc_setProperty = yes ; then - OBJC2RUNTIME=1 -else - OBJC2RUNTIME=0 -fi -AC_SUBST(OBJC2RUNTIME) - -GS_NONFRAGILE=0 -GS_MIXEDABI=0 -if test "$nonfragile" = "yes"; then - saved_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $OBJCFLAGS -fobjc-nonfragile-abi -x objective-c" - AC_MSG_CHECKING(for non-fragile-abi support) - AC_RUN_IFELSE([#include "$srcdir/config/config.non-fragile-ivars.m"], - non_fragile=yes, non_fragile=no) - CPPFLAGS="$saved_CPPFLAGS" - if test $non_fragile = yes; then - OBJCFLAGS="$OBJCFLAGS -fobjc-nonfragile-abi" - AC_SUBST(OBJCFLAGS) - GS_NONFRAGILE=1 - AC_ARG_ENABLE(mixedabi, - [ --disable-mixedabi - Disables the combined use of fragile and nonfragile ABI so that base - can be built taking full advantage of the nonfragile ABI.],, - enable_mixedabi=yes) - if test $enable_mixedabi = yes; then - GS_MIXEDABI=1 - fi - fi - AC_MSG_RESULT($non_fragile) -fi -AC_SUBST(GS_NONFRAGILE) -AC_SUBST(GS_MIXEDABI) - - -# Don't revert any Objective-C flags as they are used in the next test - -#-------------------------------------------------------------------- +# This function needed by NSLock.m for conditioned wait # get_uninstalled_dtable used by behavior.m and objc-load.m +# Thread functions used by NSThread #-------------------------------------------------------------------- +AC_CHECK_FUNCS(objc_condition_timedwait objc_thread_add) + AC_EGREP_HEADER(objc_get_uninstalled_dtable, objc/objc-api.h, AC_DEFINE(HAVE_OBJC_GET_UNINSTALLED_DTABLE,1, [ Define if objc-api.h defines this function]),) -# Don't revert any Objective-C flags as they are used in the next test - -#-------------------------------------------------------------------- -# One of these is needed by for handling uncaught exceptions -#-------------------------------------------------------------------- -AC_MSG_CHECKING(for objc_set_unexpected() in runtime) -AC_LINK_IFELSE([#include "$srcdir/config/config.set_unexpected.m"], - have_set_unexpected=yes, have_set_unexpected=no) -if test $have_set_unexpected = yes; then - AC_DEFINE(HAVE_SET_UNEXPECTED,1, - [Define if libobjc has the objc_set_unexpected() function]) -fi -AC_MSG_RESULT($have_set_unexpected) - -AC_MSG_CHECKING(for _objc_unexpected_exception in runtime) -AC_RUN_IFELSE([#include "$srcdir/config/config.unexpected.m"], - have_unexpected=yes, have_unexpected=no) -if test $have_unexpected = yes; then - AC_DEFINE(HAVE_UNEXPECTED,1, - [Define if libobjc has the _objc_unexpected_exception callback]) -fi -AC_MSG_RESULT($have_unexpected) - -if test "$exceptions" = "yes"; then - if test $have_set_unexpected = no; then - if test $have_unexpected = no; then - AC_MSG_ERROR([Your objective-c runtime library does not appear to support any mechanism to set a handler for uncaught native exceptions. Please upgrade your runtime or re-install gnustep-make without native-objc-exceptions!]) - fi - fi -fi - -# Don't revert any Objective-C flags as they are used in the next test - -#-------------------------------------------------------------------- -# Function needed by @synchronize directive -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(objc_sync_enter) - -HAVE_OBJC_SYNC_ENTER=no -if test $ac_cv_func_objc_sync_enter = yes ; then - HAVE_OBJC_SYNC_ENTER=yes -fi -AC_SUBST(HAVE_OBJC_SYNC_ENTER) - LIBS="$saved_LIBS" CPPFLAGS="$saved_CPPFLAGS" @@ -1648,7 +1315,7 @@ AC_C_INLINE # Following header checks needed for bzero in Storage.m and other places #-------------------------------------------------------------------- AC_HEADER_STDC -AC_CHECK_HEADERS(string.h memory.h alloca.h) +AC_CHECK_HEADERS(string.h memory.h) #-------------------------------------------------------------------- # Following header check needed NSConnection.h @@ -1659,27 +1326,10 @@ AC_CHECK_HEADERS(float.h) # Header files and functions for files and filesystems #-------------------------------------------------------------------- AC_CHECK_HEADERS(sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h) -AC_CHECK_HEADERS(sys/cdefs.h sys/syslimits.h sys/param.h) -# Twisted header checks for some BSDs with stupid interdependencies -AC_CHECK_HEADERS([sys/syslimits.h], [], [], - [#if HAVE_SYS_CDEFS_H - #include - #endif - #include - ]) -AC_CHECK_HEADERS([sys/param.h], [], [], - [#if HAVE_SYS_CDEFS_H - #include - #endif - #if HAVE_SYS_SYSLIMITS_H - #include - #endif - ]) +AC_CHECK_HEADERS(sys/syslimits.h sys/param.h) +# Twisted header check for NetBSD AC_CHECK_HEADERS([sys/mount.h], [], [], - [#if HAVE_SYS_CDEFS_H - #include - #endif - #if HAVE_SYS_SYSLIMITS_H + [#if HAVE_SYS_SYSLIMITS_H #include #endif #if HAVE_SYS_PARAM_H @@ -1689,7 +1339,7 @@ AC_CHECK_HEADERS([sys/mount.h], [], [], AC_CHECK_HEADERS(sys/types.h windows.h locale.h langinfo.h) saved_LIBS="$LIBS" AC_CHECK_LIB(m, main) -AC_CHECK_FUNCS(statvfs link symlink readlink geteuid getlogin getpwnam getpwnam_r getpwuid getpwuid_r getgrgid getgrgid_r getgrnam getgrnam_r rint getopt) +AC_CHECK_FUNCS(statvfs link symlink readlink geteuid getlogin getpwnam getpwuid getgrgid rint getopt) LIBS="$saved_LIBS" #-------------------------------------------------------------------- @@ -1711,31 +1361,14 @@ fi # These headers/functions needed by GSTcpPort.m #-------------------------------------------------------------------- AC_CHECK_HEADERS(sys/socket.h netinet/in.h) -AC_CHECK_TYPES([socklen_t]) dnl AC_REPLACE_FUNCS(recvfrom) #-------------------------------------------------------------------- # These headers/functions needed for stacktrace in NSException.m #-------------------------------------------------------------------- -PASS_ARG=no -AC_ARG_ENABLE(bfd, - [ --enable-bfd - Enables the use of libbfd to provide symbolic stack traces. - Enabling this option provides support for symbolic stack traces - on platforms where the backtrace_symbols() function is not - available or does not work properly. - Enabling this option also has the effect of changing the license - of gnustep-base from LGPL to GPL since libbfd uses the GPL license],, - enable_bfd=$PASS_ARG) - -if test $enable_bfd = yes; then - AC_CHECK_HEADERS(bfd.h) - AC_CHECK_LIB(iberty, dyn_string_append) - AC_CHECK_LIB(bfd, bfd_openr) -else - AC_CHECK_HEADERS(execinfo.h) - AC_CHECK_FUNCS(backtrace) -fi +AC_CHECK_HEADERS(bfd.h) +AC_CHECK_LIB(iberty, dyn_string_append) +AC_CHECK_LIB(bfd, bfd_openr) #-------------------------------------------------------------------- # These headers/functions needed by NSLog.m @@ -1756,76 +1389,21 @@ if test $ac_cv_header_poll_h = yes; then have_poll=no,) if test $have_poll = yes; then AC_MSG_RESULT(no) - AC_MSG_CHECKING([if poll supports devices]) - AC_TRY_RUN([#include "$srcdir/config/config.poll-dev.c"], ,have_poll=no, ) - if test $have_poll = yes; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_POLL_F,1, [ Define if poll is NOT emulated via select]) - else - AC_MSG_RESULT(no) - fi + AC_DEFINE(HAVE_POLL_F,1, [ Define if poll is NOT emulated via select]) else AC_MSG_RESULT(yes) fi fi #-------------------------------------------------------------------- -# Check for pthread.h +# Check for pthread.h (only when building on Darwin machines) #-------------------------------------------------------------------- AC_CHECK_HEADERS(pthread.h) +HAVE_PTHREAD_H=no if test $ac_cv_header_pthread_h = yes ; then - AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT -#include ]) - GS_SIZEOF_MUTEX_T=$ac_cv_sizeof_pthread_mutex_t - if test $ac_cv_sizeof_pthread_mutex_t = 0 ; then - AC_MSG_ERROR([Unable to find size of pthread_mutex_t (required).]) - fi - AC_SUBST(GS_SIZEOF_MUTEX_T) - AC_CHECK_SIZEOF(pthread_cond_t,,[AC_INCLUDES_DEFAULT -#include ]) - if test $ac_cv_sizeof_pthread_cond_t = 0 ; then - AC_MSG_ERROR([Unable to find size of pthread_cond_t (required).]) - fi - GS_SIZEOF_COND_T=$ac_cv_sizeof_pthread_cond_t - AC_SUBST(GS_SIZEOF_COND_T) - AC_CHECK_ALIGNOF(pthread_mutex_t,[AC_INCLUDES_DEFAULT -#include ]) - GS_ALIGNOF_MUTEX_T=$ac_cv_alignof_pthread_mutex_t - if test $ac_cv_alignof_pthread_mutex_t = 0 ; then - AC_MSG_ERROR([Unable to find align of pthread_mutex_t (required).]) - fi - AC_SUBST(GS_ALIGNOF_MUTEX_T) - AC_CHECK_ALIGNOF(pthread_cond_t,[AC_INCLUDES_DEFAULT -#include ]) - if test $ac_cv_alignof_pthread_cond_t = 0 ; then - AC_MSG_ERROR([Unable to find align of pthread_cond_t (required).]) - fi - GS_ALIGNOF_COND_T=$ac_cv_alignof_pthread_cond_t - AC_SUBST(GS_ALIGNOF_COND_T) -else - AC_MSG_ERROR([Unable to find pthread.h (needed for thread support).]) + HAVE_PTHREAD_H=yes fi -AC_CHECK_LIB(pthread, pthread_join, pthread_ok=yes, pthread_ok=no) -ismingw=no -case "$target_os" in - mingw*) ismingw=yes;; -esac -if test $pthread_ok = yes ; then - LIBS="$LIBS -lpthread" -else - if test $ismingw = yes ; then - AC_CHECK_LIB(pthreadGC2, pthread_join, pthread_ok=yes, pthread_ok=no) - if test $pthread_ok = yes ; then - LIBS="$LIBS -lpthreadGC2" - fi - fi -fi -if test $pthread_ok = no ; then - AC_MSG_ERROR([Unable to find pthread library (needed for thread support).]) -fi - -# Typically need librt on Solaris for sched_yield -AC_CHECK_LIB(rt, sched_yield) +AC_SUBST(HAVE_PTHREAD_H) #-------------------------------------------------------------------- # This function needed by StdioStream.m @@ -1862,7 +1440,7 @@ AC_CHECK_HEADERS(getopt.h) #-------------------------------------------------------------------- # This function needed by NSPage.m #-------------------------------------------------------------------- -AC_CHECK_FUNCS(posix_memalign valloc) +AC_CHECK_FUNCS(valloc) #-------------------------------------------------------------------- # This function needed by Time.m @@ -1870,21 +1448,17 @@ AC_CHECK_FUNCS(posix_memalign valloc) AC_CHECK_FUNCS(times) #-------------------------------------------------------------------- -# These functions needed by NSData.m and GSFFIInvocation.m +# These functions needed by NSData.m #-------------------------------------------------------------------- AC_CHECK_FUNCS(mkstemp) AC_CHECK_FUNCS(shmctl) AC_CHECK_FUNCS(mmap) -AC_CHECK_FUNCS(mprotect) -AC_CHECK_HEADERS(sys/mman.h) #-------------------------------------------------------------------- # These functions needed by NSTask.m #-------------------------------------------------------------------- -AC_CHECK_FUNCS(killpg setpgrp setpgid setsid) -if test "x$ac_cv_func_setpgrp" = xyes; then - AC_FUNC_SETPGRP -fi +AC_CHECK_FUNCS(killpg setpgrp setpgid) +AC_FUNC_SETPGRP HAVE_PTS_STREAM_MODULES=0 case "${target}" in @@ -1897,7 +1471,6 @@ AC_DEFINE_UNQUOTED(HAVE_PTS_STREAM_MODULES, $HAVE_PTS_STREAM_MODULES, AC_SUBST(HAVE_PTS_STREAM_MODULES) AC_CHECK_HEADERS(libc.h limits.h malloc.h memory.h string.h signal.h dnl - stdlib.h dnl sys/signal.h sys/wait.h sys/file.h sys/fcntl.h sys/ioctl.h dnl sys/stropts.h unistd.h utime.h stdint.h inttypes.h sys/inttypes.h) @@ -1950,10 +1523,8 @@ AC_SUBST(DEFINE_UINTPTR_T) #-------------------------------------------------------------------- # These used by GSFileHandle.m and distributed objects -# On some systems we need -lnsl ... so check for that first. #-------------------------------------------------------------------- -AC_CHECK_LIB(nsl, inet_ntop) -AC_CHECK_FUNCS(gethostbyaddr_r inet_aton inet_pton inet_ntop sigaction) +AC_CHECK_FUNCS(inet_aton inet_pton sigaction) USE_ZLIB=0 AC_CHECK_HEADERS(zlib.h) if test $ac_cv_header_zlib_h = yes; then @@ -1971,37 +1542,75 @@ if test $ac_cv_func_inet_pton = yes ; then fi AC_SUBST(HAVE_INET_PTON) -HAVE_INET_NTOP=no -if test $ac_cv_func_inet_ntop = yes ; then - HAVE_INET_NTOP=yes -fi -AC_SUBST(HAVE_INET_NTOP) - #-------------------------------------------------------------------- # One of these function needed by NSThread.m #-------------------------------------------------------------------- AC_CHECK_FUNCS(nanosleep usleep) #-------------------------------------------------------------------- -# For setting thread stack size +# This function needed by NSDebug.m and NSProcessInfo.m #-------------------------------------------------------------------- -AC_CHECK_HEADERS(sys/resource.h) -AC_CHECK_FUNCS(setrlimit) - -#-------------------------------------------------------------------- -# One of these functions needed by NSDebug.m and NSProcessInfo.m -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(strerror_r strerror) - -#-------------------------------------------------------------------- -# Needed by NSDebug.m -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(sigsetjmp) +AC_CHECK_FUNCS(strerror) #-------------------------------------------------------------------- # This type needed by GSFormat #-------------------------------------------------------------------- AC_CHECK_TYPES([uintmax_t]) + +AC_MSG_CHECKING([whether precompiler handles LONG_LONG_MAX]) +# We need to define _GNU_SOURCE for some systems to enable LONG_LONG_MAX +AC_TRY_CPP([#ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + #ifdef HAVE_STDINT_H + #include + #endif + #include + #if defined(LONG_LONG_MAX) + #if LONG_MAX == LONG_LONG_MAX + #error long max equals long long max + #endif + #else + #error long long max not defined + #endif + ], llmax=yes, llmax=no) +if test $llmax = yes; then + AC_MSG_RESULT(yes) + AC_DEFINE(HANDLE_LONG_LONG_MAX,1, + [Define if this constant is defined]) +else + AC_MSG_RESULT(no) +fi + +# +# Solaris and *BSD use LLONG_MAX instead +# +AC_MSG_CHECKING([whether we have LLONG_MAX]) +# We need to use the same header environment as the test above because we +# will be using one or the other set of constants. +AC_TRY_CPP([#ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + #ifdef HAVE_STDINT_H + #include + #endif + #include + #if defined(LLONG_MAX) + #if LONG_MAX == LLONG_MAX + #error long max equals long long max + #endif + #else + #error llong max not defined + #endif + ], llmax=yes, llmax=no) + +if test $llmax = yes; then + AC_MSG_RESULT(yes) + AC_DEFINE(HANDLE_LLONG_MAX,1, + [Define if this constant is defined]) +else + AC_MSG_RESULT(no) +fi AC_CHECK_HEADERS(wchar.h) #-------------------------------------------------------------------- @@ -2021,9 +1630,8 @@ else fi #-------------------------------------------------------------------- -# This needed by NSString for handling of %@ printf directive. +# This function needed by NSString for handling of %@ printf directive. #-------------------------------------------------------------------- -AC_CHECK_FUNCS(register_printf_specifier) AC_CHECK_FUNC(register_printf_function, register_printf=1, register_printf=0) if test $register_printf = 1; then @@ -2033,17 +1641,9 @@ if test $register_printf = 1; then if test $working_register_printf = 1; then AC_DEFINE(HAVE_REGISTER_PRINTF_FUNCTION,1, [Define if you have the register_printf_function function]) - AC_TRY_RUN([#include "$srcdir/config/config.wprintf.c"], - wide_register_printf=1, wide_register_printf=0, - wide_register_printf=1) - if test $wide_register_printf = 1; then - AC_DEFINE(HAVE_WIDE_PRINTF_FUNCTION,1, - [Define if register_printf_function supports wide characters]) - fi fi fi - #-------------------------------------------------------------------- # This function needed by NSString. #-------------------------------------------------------------------- @@ -2077,12 +1677,6 @@ fi #-------------------------------------------------------------------- AC_CHECK_HEADERS(sys/utsname.h) -#-------------------------------------------------------------------- -# Check for sysctlbyname used by NSProcessInfo.m -#-------------------------------------------------------------------- -AC_CHECK_HEADERS(sys/sysctl.h) -AC_CHECK_FUNCS(sysctlbyname) - #-------------------------------------------------------------------- # Defines HAVE_PROCFS if the kernel supports the /proc filesystem. # Needed by NSProcessInfo.m @@ -2175,10 +1769,6 @@ if test "$enable_fake_main" = "yes"; then elif test "$enable_pass_arguments" = "no"; then if test "$objc_load_method_worked" = yes -a \( "$ac_cv_sys_procfs" = yes -o "$have_kvm_env" = 1 -o "$ac_cv_sys_procfs_psinfo" = yes \); then GS_FAKE_MAIN=0 - if test "$have_kvm_env" = "1"; then - echo "WARNING ... using libkvm which is known to be buggy on some systems" - echo "consider configuring with --enable-fake-main instead." - fi else GS_FAKE_MAIN=1 enable_fake_main=yes @@ -2211,65 +1801,29 @@ fi #-------------------------------------------------------------------- # Check for FFI interface libraries for invocations -# We enable ffi by default now, as it's fixed for some previouly bad -# platforms, and it has the advantage over ffcall that it does not -# mess up the stack, so stacktraces and native exception handling -# work better with it. +# We enable ffcall by default now. #-------------------------------------------------------------------- -do_broken_libffi=no -do_broken_libffcall=no -do_enable_libffi=yes -do_enable_libffcall=no -case "$target_cpu" in - sparc64*) - case "$target_os" in - solaris*) - do_broken_libffcall=yes; - do_enable_libffi=yes; - do_enable_libffcall=no;; - *) ;; - esac ;; - *) ;; -esac - -if test "$exceptions" = "yes"; then - # ffcall will mess up native exceptions, so we must disable it. - do_broken_libffcall=yes - do_enable_libffcall=no - - if test "$have_unexpected" = "no"; then - echo - echo "Your gnustep-make is configured to use native objc exceptions, but" - echo "the objc runtime does not appear to support setting an uncaught" - echo "exception handler. This means that any uncaught exception will" - echo "cause a program to abort immediately." - echo "Consider reconfiguring gnustep-make or updating libobjc to fix this." - fi -fi +do_enable_libffi=no AC_ARG_ENABLE(libffi, - [ --disable-libffi Disable use of libffi library],, + [ --enable-libffi Enable use of libffi library],, enable_libffi=$do_enable_libffi) AC_ARG_ENABLE(ffcall, - [ --enable-ffcall Enable use of the deprecated ffcall library],, - enable_ffcall=$do_enable_libffcall) + [ --enable-ffcall Enable use of ffcall library],, + enable_ffcall=yes) -if test $enable_ffcall = yes; then - AC_MSG_WARN([ffcall has been enabled ... this is deprecated ... please install and use a recent libffi if possible]) -fi - -AC_ARG_ENABLE(invocations, - [ --disable-invocations Compile even if invocation-dependencies are not met],, - enable_invocations=yes) +AC_ARG_ENABLE(do, + [ --disable-do Compile even if DO-dependencies are not met],, + enable_do=yes) # DO isn't used on apple-apple-apple if test $LIBRARY_COMBO = apple-apple-apple; then - enable_invocations=no + enable_do=no fi AC_ARG_WITH(ffi-include, -[ --with-ffi-include=PATH Include path for ffi headers], +[ --with-ffi-include=PATH Include path for ffi (ffcall/libffi) headers], ffi_incdir="$withval", ffi_incdir="no") if test ${ffi_incdir} != "no"; then CPPFLAGS="$CPPFLAGS -I${ffi_incdir}" @@ -2277,22 +1831,14 @@ if test ${ffi_incdir} != "no"; then fi AC_ARG_WITH(ffi-library, -[ --with-ffi-library=PATH Library path for ffi libs], +[ --with-ffi-library=PATH Library path for ffi (ffcall/libffi) libs], ffi_libdir="$withval", ffi_libdir="no") if test ${ffi_libdir} != "no"; then GS_ADD_LIBRARY_PATH([${ffi_libdir}]) fi -if test "$do_broken_libffi" = "no"; then - AC_CHECK_HEADER(ffi.h, have_libffi=yes, have_libffi=no) -else - have_libffi=no -fi -if test "$do_broken_libffcall" = "no"; then - AC_CHECK_HEADERS(callback.h, have_ffcall=yes, have_ffcall=no) -else - have_ffcall=no -fi +AC_CHECK_HEADER(ffi.h, have_libffi=yes, have_libffi=no) +AC_CHECK_HEADERS(callback.h, have_ffcall=yes, have_ffcall=no) if test $have_ffcall = no; then enable_ffcall=no # If we don't have ffcall but do have libffi, use libffi @@ -2302,27 +1848,14 @@ if test $have_ffcall = no; then fi if test $have_libffi = no; then enable_libffi=no - # If we don't have libffi but do have ffcall, use ffcall - if test $have_ffcall = yes; then - if test $enable_ffcall = no; then - AC_MSG_WARN([ffi support seems to be missing on this system ... please install a recent libffi]) - fi - fi fi have_forward_hook=yes saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c" AC_MSG_CHECKING(for forwarding callback in runtime) -AC_COMPILE_IFELSE([#include "$srcdir/config/config.forward2.m"], +AC_COMPILE_IFELSE([#include "$srcdir/config/config.forward.m"], have_forward_hook=yes, have_forward_hook=no) -if test $have_forward_hook = yes; then - AC_DEFINE(HAVE_FORWARD2,1, - [Define if libobjc has the __objc_msg_forward2 function]) -else - AC_COMPILE_IFELSE([#include "$srcdir/config/config.forward.m"], - have_forward_hook=yes, have_forward_hook=no) -fi AC_MSG_RESULT($have_forward_hook) if test $have_forward_hook = no; then enable_libffi=no @@ -2337,14 +1870,9 @@ if test $enable_libffi = yes; then [Define if using the libffi library for invocations]) WITH_FFI=libffi LIBS="-lffi $LIBS" - AC_TRY_RUN([#include "$srcdir/config/config.ffi.c"],,ffi_ok="yes",ffi_ok="no") + AC_TRY_LINK([#include ], ,ffi_ok="yes", ffi_ok="no") if test $ffi_ok = yes; then AC_MSG_RESULT(libffi) - if test $do_broken_libffi = yes; then - AC_MSG_WARN([ffi may be broken on this system ... try enabling ffcall]) - fi - else - AC_MSG_ERROR([The ffi library (libffi) does not appear to be working. Perhaps it's missing or you need a more recent version. Version 3.0.9 or later should work, and you can find a link to it n the list of packages for download at http://www.gnustep.org/resources/sources.html]) fi elif test $enable_ffcall = yes; then AC_DEFINE(USE_FFCALL,1, @@ -2355,17 +1883,16 @@ elif test $enable_ffcall = yes; then if test $ffi_ok = yes; then AC_MSG_RESULT(ffcall) fi - AC_MSG_WARN([ffcall is broken on some systems and is deprecated ... try enabling ffi]) -else - ffi_ok=no -fi - -if test $enable_ffcall = yes -a $ffi_ok = yes; then AC_MSG_CHECKING(if ffcall trampolines work) AC_RUN_IFELSE([#include "$srcdir/config/config.trampoline.c"], have_working_trampoline=yes, have_working_trampoline=no, have_working_trampoline=yes) AC_MSG_RESULT($have_working_trampoline) + if test $have_working_trampoline = no; then + ffi_ok=no + fi +else + ffi_ok=no fi if test $ffi_ok = no; then @@ -2375,25 +1902,22 @@ if test $ffi_ok = no; then echo "You do not have an up-to-date libobjc library installed" elif test "$have_working_trampoline" = no; then echo "You have ffcall, but it does not work properly. Most likely because" - echo "your system's security policy is blocking some parts of ffcall" + echo "your're system's security policy is blocking some parts of ffcall" echo "we recommend installing libffi instead." else - echo "You do not have either ffcall or libffi installed/enabled, or configure needs" - echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them," - echo "or you have ffcall but gnustep-make is configured to use native exceptions" - echo "(native exceptions are not compatible with ffcall)." + echo "You do not have either ffcall or libffi installed, or configure needs" + echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them" fi - echo "GNUstep requires libffi (or ffcall) and proper libobjc hooks to do" + echo "GNUstep requires ffcall or libffi and proper libobjc hooks to do" echo "invocations and DO." echo "(This does not apply on apple-apple-apple systems where DO is" echo "not compatible with other GNUstep systems.)" - if test $enable_invocations = yes; then + if test $enable_do = yes; then echo - echo "You most likely do not want to build base without invocation support." - echo "Many things (including Distributed Objects and undo/redo), won't work" - echo "at all without invocations." - echo "If you really want to build -base without invocation support," - echo "add --disable-invocations to the configure arguments." + echo "You most likely do not want to build base without DO support. Many" + echo "things, including all applications, won't work at all without DO." + echo "If you really want to build -base without DO support, add --disable-do" + echo "to the configure arguments." echo "For more information, read the GNUstep build guide, ffcall section:" echo "http://gnustep.made-it.com/BuildGuide/index.html" AC_MSG_ERROR([Incomplete support for ffi functionality.]) @@ -2515,8 +2039,7 @@ if test $enable_xml = yes; then LIBS="-lxslt $LIBS" else echo - echo "You may not want to build base without XSLT support." - echo "Doing so will disable the XSLT extensions." + echo "You most likely do not want to build base without XSLT support." echo "If you really want to build -base without XSLT support," echo "add --disable-xslt to the configure arguments." AC_MSG_WARN([Missing support for XSLT functionality.]) @@ -2532,8 +2055,8 @@ if test $enable_xml = yes; then LIBS="$saved_LIBS" CFLAGS="$saved_CFLAGS" echo - echo "You may not want to build base without libxml2." - echo "Doing so will disable the XML, XPATH, and XMLRPC extensions." + echo "You most likely do not want to build base without XML support." + echo "For instance, MacOS-X compatible property lists require XML." echo "If you really want to build -base without XML support," echo "add --disable-xml to the configure arguments." AC_MSG_ERROR([Missing support for XML functionality.]) @@ -2544,117 +2067,19 @@ else fi AC_SUBST(HAVE_LIBXML) -#-------------------------------------------------------------------- -# Check recent libgnutls for SSL streams. -#-------------------------------------------------------------------- - -AC_ARG_ENABLE(tls, - [ --disable-tls Disable use of GNUTLS],, - enable_tls=yes) - -if test $enable_tls = yes; then - # Save CFLAGS and LIBS as AM_PATH_TLS clobbers these variables regardless - # of the success of the macro. - saved_LIBS="$LIBS" - saved_CFLAGS="$CFLAGS" - -# AM_PATH_TLS(2.0.1, enable_libgnutls=yes, enable_libgnutls=no) - AM_PATH_TLS(1.4.0, enable_libgnutls=yes, enable_libgnutls=no) - if test $enable_libgnutls = yes; then - CPPFLAGS="$CPPFLAGS $TLS_CFLAGS" - INCLUDE_FLAGS="$INCLUDE_FLAGS $TLS_CFLAGS" - LIBS="$TLS_LIBS $LIBS" - HAVE_GNUTLS=1 - AC_DEFINE(HAVE_GNUTLS,1,[Define if libgnutls available]) - AC_CHECK_LIB(gcrypt, gcry_control, have_gcrypt=yes, have_gcrypt=no) - if test "$have_gcrypt" = "no"; then - AC_MSG_WARN([Missing support for thread-safe operation in GNUTLS. Disabling TLS support).]) - HAVE_GNUTLS=0 - else - LIBS="$TLS_LIBS -lgcrypt $LIBS" - fi - AC_CHECK_FUNCS(gnutls_transport_set_errno) - if test "$ac_cv_func_gnutls_transport_set_errno" = "no"; then - AC_MSG_WARN([Missing support for thread-safe error handling in GNUTLS. Please check that you have the most recent version installed (2.0 or later chould be fine).]) - fi - else - HAVE_GNUTLS=0 - # Restore the CFLAGS and LIBS because AM_PATH_TLS messes them - LIBS="$saved_LIBS" - CFLAGS="$saved_CFLAGS" - echo - echo "You may not want to build base without libgnutls." - echo "Doing so will disable SSL support in the NSStream class." - echo "If you really want to build -base without TLS support," - echo "add --disable-tls to the configure arguments." - AC_MSG_WARN([Missing support for TLS functionality.]) - fi -else - AC_MSG_WARN([Disabled support for TLS funtionality.]) - HAVE_GNUTLS=0 -fi -AC_SUBST(HAVE_GNUTLS) - #-------------------------------------------------------------------- # Check for NSNetServices #-------------------------------------------------------------------- HAVE_MDNS=0 -HAVE_AVAHI=0 -AC_ARG_ENABLE(zeroconf, - [ --disable-zeroconf Disable NSNetServices support],, - enable_zeroconf=yes) -AC_ARG_WITH(zeroconf-api, - [ --with-zeroconf-api=API force use of a specific zeroconf API (mdns or avahi)], - zeroconf_api="$withval", zeroconf_api="any") -if test $enable_zeroconf = yes; then - if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "mdns"; then - AC_CHECK_HEADERS(dns_sd.h, have_mdns=yes, have_mdns=no) - if test "$have_mdns" = "yes"; then - AC_CHECK_LIB(dns_sd, DNSServiceBrowse, have_mdns=yes, have_mdns=no) - if test "$have_mdns" = "yes"; then - MDNS_LIBS="-ldns_sd" - HAVE_MDNS=1 - fi - fi - fi - if test "$zeroconf_api" = "any" || test "$zeroconf_api" = "avahi"; then - AC_CHECK_HEADERS(avahi-client/client.h, have_avahi=yes, have_avahi=no) - if test "$have_avahi" = "yes"; then - AC_CHECK_LIB(avahi-client, avahi_client_new, have_avahi=yes, have_avahi=no) - if test "$have_avahi" = "yes"; then - AVAHI_LIBS="-lavahi-common -lavahi-client" - HAVE_AVAHI=1 - fi - fi - fi - # If we have both APIs, perfer Avahi, because the mDNS API is most certainly the compatability one - if test "$have_avahi" = "yes" && test "$have_mdns" = "yes"; then - LIBS="$AVAHI_LIBS $LIBS" - HAVE_MDNS=0 - else - # One of those will be empty. - LIBS="$AVAHI_LIBS $MDNS_LIBS $LIBS" +AC_CHECK_HEADERS(dns_sd.h, have_mdns=yes, have_mdns=no) +if test "$have_mdns" = "yes"; then + AC_CHECK_LIB(dns_sd, DNSServiceBrowse, have_mdns=yes, have_mdns=no) + if test "$have_mdns" = "yes"; then + LIBS="-ldns_sd $LIBS" + HAVE_MDNS=1 fi fi AC_SUBST(HAVE_MDNS) -AC_SUBST(HAVE_AVAHI) -#-------------------------------------------------------------------- -# Check for International Components for Unicode -#-------------------------------------------------------------------- -HAVE_ICU=0 -AC_ARG_ENABLE(icu, - [ --disable-icu Disable International Components for Unicode],, - enable_icu=yes) - -if test $enable_icu = yes; then - AC_CHECK_ICU(4.0, have_icu=yes, have_icu=no) - if test "$have_icu" = "yes"; then - AC_CHECK_HEADERS(unicode/uloc.h unicode/ulocdata.h unicode/ucurr.h) - LIBS="$LIBS $ICU_LIBS" - HAVE_ICU=1 - fi -fi -AC_SUBST(HAVE_ICU) #-------------------------------------------------------------------- # Check GMP for NSDecimal @@ -2701,53 +2126,6 @@ AM_LANGINFO_CODESET AC_SUBST(INCLUDE_FLAGS) AC_SUBST(LDIR_FLAGS) -#-------------------------------------------------------------------- -# Check for -Wdeclaration-after-statement -#-------------------------------------------------------------------- -AC_MSG_CHECKING(whether the compiler supports -Wdeclaration-after-statement) - -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -Wdeclaration-after-statement" -AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],HAS_W_DECL_AFTER_STATEMENT=yes,HAS_W_DECL_AFTER_STATEMENT=no) -CFLAGS="$saved_CFLAGS" - -AC_MSG_RESULT($HAS_W_DECL_AFTER_STATEMENT) - -if test x"$HAS_W_DECL_AFTER_STATEMENT" = x"yes"; then - WARN_FLAGS="-Wall -Wdeclaration-after-statement" -else - WARN_FLAGS=-Wall -fi - -AC_SUBST(WARN_FLAGS) - -#-------------------------------------------------------------------- -# Check if we should install gdomap as setuid -#-------------------------------------------------------------------- -AC_MSG_CHECKING([if we should install gdomap as setuid]) -AC_ARG_ENABLE(setuid-gdomap,[ - --enable-setuid-gdomap Enable installing gdomap as a setuid - executable. By default, it is installed - as a normal program intended to be started - by root at system boot time, but it can - also be started up automatically - by any user at any time. Use this - option if you are happy having the program - started automatically on demand. -], - ac_cv_setuid_gdomap=$enableval, - ac_cv_setuid_gdomap="no") - -if test "$ac_cv_setuid_gdomap" = "yes"; then - AC_MSG_RESULT(yes); - GNUSTEP_INSTALL_GDOMAP_AS_SETUID="yes" -else - AC_MSG_RESULT(no); - GNUSTEP_INSTALL_GDOMAP_AS_SETUID="no" -fi - -AC_SUBST(GNUSTEP_INSTALL_GDOMAP_AS_SETUID) - #-------------------------------------------------------------------- # Configure flags from sub-configure runs, so they show up in our # help file. @@ -2762,7 +2140,7 @@ AC_ARG_WITH(openssl-library, [ --with-openssl-library=PATH library path for openssl libraries], openssl_libdir="$withval", openssl_libdir="no") -AC_CONFIG_SUBDIRS(SSL) +AC_CONFIG_SUBDIRS(Source/mframe SSL) #-------------------------------------------------------------------- # Record the version diff --git a/gnustep-base-debug.spec.in b/gnustep-base-debug.spec.in new file mode 100644 index 000000000..6cf937168 --- /dev/null +++ b/gnustep-base-debug.spec.in @@ -0,0 +1,14 @@ +Release: 1 +Source: ftp://ftp.gnustep.org/pub/gnustep/core/%{gs_name}-%{gs_version}.tar.gz +Copyright: GPL +Group: Development/Libraries +Summary: GNUstep Base library package - debugging version +Packager: Adam Fedor +Vendor: The GNUstep Project +URL: http://www.gnustep.org/ +Requires: gnustep-make >= 0.9.0 + +%description +This package contains the debuggable version of the GNUstep Base +Library. You probably only need it if you want to compile debuggable +GNUstep programs. diff --git a/gnustep-base.spec.in b/gnustep-base.spec.in index f991a574a..110a43eb8 100644 --- a/gnustep-base.spec.in +++ b/gnustep-base.spec.in @@ -1,12 +1,12 @@ Release: 1 Source: ftp://ftp.gnustep.org/pub/gnustep/core/%{gs_name}-%{gs_version}.tar.gz -License: LGPL +Copyright: LGPL Group: Development/Libraries Summary: GNUstep Base library package Packager: GNUstep Development Vendor: The GNUstep Project URL: http://www.gnustep.org/ -Requires: gnustep-make >= 2.0.0 +Requires: gnustep-make >= 1.11.0 %description The GNUstep Base Library is a powerful fast library of general-purpose, diff --git a/install.sh b/install.sh deleted file mode 100755 index f9c813bb0..000000000 --- a/install.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh - -PREFIX=$1 -MAKE=${2-make} - -. $PREFIX/System/Library/Makefiles/GNUstep.sh - -$MAKE GNUSTEP_INSTALLATION_DOMAIN=SYSTEM install - -exit 0 diff --git a/macosx/GNUstepBase/preface.h b/macosx/GNUstepBase/preface.h index 81381d451..1e3c797c5 100644 --- a/macosx/GNUstepBase/preface.h +++ b/macosx/GNUstepBase/preface.h @@ -7,16 +7,16 @@ This file is part of the GNUstep Base Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. + version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ @@ -119,19 +119,19 @@ extern const char o_NeXT_cc_version[]; #ifndef MAX #define MAX(a,b) \ - ({__typeof__(a) _MAX_a = (a); __typeof__(b) _MAX_b = (b); \ + ({typeof(a) _MAX_a = (a); typeof(b) _MAX_b = (b); \ _MAX_a > _MAX_b ? _MAX_a : _MAX_b; }) #endif #ifndef MIN #define MIN(a,b) \ - ({__typeof__(a) _MIN_a = (a); __typeof__(b) _MIN_b = (b); \ + ({typeof(a) _MIN_a = (a); typeof(b) _MIN_b = (b); \ _MIN_a < _MIN_b ? _MIN_a : _MIN_b; }) #endif #ifndef ABS #define ABS(a) \ - ({__typeof__(a) _ABS_a = (a); \ + ({typeof(a) _ABS_a = (a); \ _ABS_a < 0 ? -_ABS_a : _ABS_a; }) #endif diff --git a/macosx/config.h b/macosx/config.h index 9d6c2b8ff..29def34c9 100644 --- a/macosx/config.h +++ b/macosx/config.h @@ -9,7 +9,7 @@ This file is part of the GNUstep Database Library. This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public + modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.