Revision: 7475 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7475 Author: zmatsuo Date: 2019-03-10 23:34:42 +0900 (Sun, 10 Mar 2019) Log Message: ----------- Merge branch 'trunk' r7467 into cmake # Conflicts: # CMakeLists.txt # TTProxy/CMakeLists.txt # TTXKanjiMenu/CMakeLists.txt # TTXSamples/TTXAdditionalTitle/CMakeLists.txt # TTXSamples/TTXAlwaysOnTop/CMakeLists.txt # TTXSamples/TTXCallSysMenu/CMakeLists.txt # TTXSamples/TTXCommandLineOpt/CMakeLists.txt # TTXSamples/TTXCopyIniFile/CMakeLists.txt # TTXSamples/TTXFixedWinSize/CMakeLists.txt # TTXSamples/TTXKcodeChange/CMakeLists.txt # TTXSamples/TTXOutputBuffering/CMakeLists.txt # TTXSamples/TTXRecurringCommand/CMakeLists.txt # TTXSamples/TTXResizeMenu/CMakeLists.txt # TTXSamples/TTXResizeWin/CMakeLists.txt # TTXSamples/TTXShowCommandLine/CMakeLists.txt # TTXSamples/TTXViewMode/CMakeLists.txt # TTXSamples/ttxtest/CMakeLists.txt # libs/build_library_with_cmake.md # libs/buildall_cmake.bat # libs/openssl.cmake # teraterm/CMakeLists.txt # teraterm/common/compat_win.cpp # teraterm/common/compat_win.h # teraterm/keycode/CMakeLists.txt # teraterm/teraterm/CMakeLists.txt # teraterm/teraterm/teraterm.cpp # teraterm/teraterm/ttime.h # teraterm/teraterm/vtdisp.c # teraterm/teraterm/vtterm.c # teraterm/teraterm/vtwin.cpp # teraterm/teraterm/vtwin.h # teraterm/ttpcmn/CMakeLists.txt # teraterm/ttpcmn/language.c # teraterm/ttpcmn/language.h # teraterm/ttpdlg/CMakeLists.txt # teraterm/ttpfile/CMakeLists.txt # teraterm/ttpmacro/CMakeLists.txt # teraterm/ttpset/CMakeLists.txt # teraterm/ttptek/CMakeLists.txt # ttpmenu/CMakeLists.txt # ttssh2/matcher/CMakeLists.txt # ttssh2/ttxssh/CMakeLists.txt Revision Links: -------------- http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7467 Modified Paths: -------------- branches/cmake/CMakeLists.txt branches/cmake/TTProxy/CMakeLists.txt branches/cmake/doc/convtext.bat branches/cmake/doc/en/html/about/history.html branches/cmake/doc/ja/html/about/history.html branches/cmake/libs/build_library_with_cmake.md branches/cmake/libs/buildall_cmake.bat branches/cmake/libs/openssl.cmake branches/cmake/teraterm/common/compat_win.cpp branches/cmake/teraterm/common/compat_win.h branches/cmake/teraterm/keycode/CMakeLists.txt branches/cmake/teraterm/teraterm/CMakeLists.txt branches/cmake/teraterm/teraterm/buffer.c branches/cmake/teraterm/teraterm/teraterm.cpp branches/cmake/teraterm/teraterm/ttdialog.c branches/cmake/teraterm/teraterm/ttermpro.vcproj branches/cmake/teraterm/teraterm/vtdisp.c branches/cmake/teraterm/teraterm/vtdisp.h branches/cmake/teraterm/teraterm/vtterm.c branches/cmake/teraterm/teraterm/vtwin.cpp branches/cmake/teraterm/teraterm/vtwin.h branches/cmake/teraterm/ttpcmn/CMakeLists.txt branches/cmake/teraterm/ttpdlg/CMakeLists.txt branches/cmake/teraterm/ttpfile/CMakeLists.txt branches/cmake/teraterm/ttpmacro/CMakeLists.txt branches/cmake/teraterm/ttpset/CMakeLists.txt branches/cmake/teraterm/ttptek/CMakeLists.txt branches/cmake/ttssh2/matcher/CMakeLists.txt Added Paths: ----------- branches/cmake/doc/Markdown_1.0.1/ branches/cmake/doc/Markdown_1.0.1/License.text branches/cmake/doc/Markdown_1.0.1/Markdown Readme.text branches/cmake/doc/Markdown_1.0.1/Markdown.pl branches/cmake/doc/ja/html/reference/build_with_cmake.md branches/cmake/teraterm/common/dllutil.cpp branches/cmake/teraterm/common/dllutil.h branches/cmake/teraterm/ttpdlg/svnversion.h.in -------------- next part -------------- Modified: branches/cmake/CMakeLists.txt =================================================================== --- branches/cmake/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -13,9 +13,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -# _WIN32_WINNT_WIN10 0x0A00 +# _WIN32_WINNT_WIN10 0x0a00 set(_WIN32_WINNT "0x0a00") if(MSVC) + # https://www.leeholmes.com/blog/2017/02/27/differences-between-visual-studio-2012-2013-and-2015/ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN32_WINNT=${_WIN32_WINNT}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_WIN32_WINNT=${_WIN32_WINNT}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) @@ -24,9 +25,11 @@ string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /W3") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /W3") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GF /Gy") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GF /Gy") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /ZI") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") @@ -35,8 +38,10 @@ elseif(MINGW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=${_WIN32_WINNT}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WIN32_WINNT=${_WIN32_WINNT}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -ffunction-sections -fdata-sections ${C_ONLY_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -ffunction-sections -fdata-sections") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra " + "-Wno-unused-parameter -static -ffunction-sections -fdata-sections ${C_ONLY_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra " + "-Wno-unused-parameter -static -ffunction-sections -fdata-sections") if (CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") Modified: branches/cmake/TTProxy/CMakeLists.txt =================================================================== --- branches/cmake/TTProxy/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/TTProxy/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -15,6 +15,7 @@ set(COMMON_SRC ../teraterm/common/ttlib.h + ../teraterm/common/ttlib.c ../teraterm/common/i18n.h ../teraterm/common/ttplugin.h ../teraterm/common/tttypes.h @@ -96,12 +97,14 @@ ${YCL_SRC} ) -set_target_properties( - ttproxy - PROPERTIES - PREFIX "" - OUTPUT_NAME "TTXProxy" - ) +if(MINGW) + set_target_properties( + ttproxy + PROPERTIES + PREFIX "" + OUTPUT_NAME "TTXProxy" + ) +endif() target_link_libraries( ttproxy @@ -112,5 +115,3 @@ gdi32 comdlg32 ) - - Added: branches/cmake/doc/Markdown_1.0.1/License.text =================================================================== --- branches/cmake/doc/Markdown_1.0.1/License.text (rev 0) +++ branches/cmake/doc/Markdown_1.0.1/License.text 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1,30 @@ +Copyright (c) 2004, John Gruber +<http://daringfireball.net/> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name "Markdown" nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as +is" and any express or implied warranties, including, but not limited +to, the implied warranties of merchantability and fitness for a +particular purpose are disclaimed. In no event shall the copyright owner +or contributors be liable for any direct, indirect, incidental, special, +exemplary, or consequential damages (including, but not limited to, +procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. Added: branches/cmake/doc/Markdown_1.0.1/Markdown Readme.text =================================================================== --- branches/cmake/doc/Markdown_1.0.1/Markdown Readme.text (rev 0) +++ branches/cmake/doc/Markdown_1.0.1/Markdown Readme.text 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1,341 @@ +Markdown +======== + +Version 1.0.1 - Tue 14 Dec 2004 + +by John Gruber +<http://daringfireball.net/> + + +Introduction +------------ + +Markdown is a text-to-HTML conversion tool for web writers. Markdown +allows you to write using an easy-to-read, easy-to-write plain text +format, then convert it to structurally valid XHTML (or HTML). + +Thus, "Markdown" is two things: a plain text markup syntax, and a +software tool, written in Perl, that converts the plain text markup +to HTML. + +Markdown works both as a Movable Type plug-in and as a standalone Perl +script -- which means it can also be used as a text filter in BBEdit +(or any other application that supporst filters written in Perl). + +Full documentation of Markdown's syntax and configuration options is +available on the web: <http://daringfireball.net/projects/markdown/>. +(Note: this readme file is formatted in Markdown.) + + + +Installation and Requirements +----------------------------- + +Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century. +Markdown also requires the standard Perl library module `Digest::MD5`. + + +### Movable Type ### + +Markdown works with Movable Type version 2.6 or later (including +MT 3.0 or later). + +1. Copy the "Markdown.pl" file into your Movable Type "plugins" + directory. The "plugins" directory should be in the same directory + as "mt.cgi"; if the "plugins" directory doesn't already exist, use + your FTP program to create it. Your installation should look like + this: + + (mt home)/plugins/Markdown.pl + +2. Once installed, Markdown will appear as an option in Movable Type's + Text Formatting pop-up menu. This is selectable on a per-post basis. + Markdown translates your posts to HTML when you publish; the posts + themselves are stored in your MT database in Markdown format. + +3. If you also install SmartyPants 1.5 (or later), Markdown will offer + a second text formatting option: "Markdown with SmartyPants". This + option is the same as the regular "Markdown" formatter, except that + automatically uses SmartyPants to create typographically correct + curly quotes, em-dashes, and ellipses. See the SmartyPants web page + for more information: <http://daringfireball.net/projects/smartypants/> + +4. To make Markdown (or "Markdown with SmartyPants") your default + text formatting option for new posts, go to Weblog Config -> + Preferences. + +Note that by default, Markdown produces XHTML output. To configure +Markdown to produce HTML 4 output, see "Configuration", below. + + +### Blosxom ### + +Markdown works with Blosxom version 2.x. + +1. Rename the "Markdown.pl" plug-in to "Markdown" (case is + important). Movable Type requires plug-ins to have a ".pl" + extension; Blosxom forbids it. + +2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder. + If you're not sure where your Blosxom plug-ins folder is, see the + Blosxom documentation for information. + +3. That's it. The entries in your weblog will now automatically be + processed by Markdown. + +4. If you'd like to apply Markdown formatting only to certain posts, + rather than all of them, see Jason Clark's instructions for using + Markdown in conjunction with Blosxom's Meta plugin: + + <http://jclark.org/weblog/WebDev/Blosxom/Markdown.html> + + +### BBEdit ### + +Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works +with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.) + +1. Copy the "Markdown.pl" file to appropriate filters folder in your + "BBEdit Support" folder. On Mac OS X, this should be: + + BBEdit Support/Unix Support/Unix Filters/ + + See the BBEdit documentation for more details on the location of + these folders. + + You can rename "Markdown.pl" to whatever you wish. + +2. That's it. To use Markdown, select some text in a BBEdit document, + then choose Markdown from the Filters sub-menu in the "#!" menu, or + the Filters floating palette + + + +Configuration +------------- + +By default, Markdown produces XHTML output for tags with empty elements. +E.g.: + + <br /> + +Markdown can be configured to produce HTML-style tags; e.g.: + + <br> + + +### Movable Type ### + +You need to use a special `MTMarkdownOptions` container tag in each +Movable Type template where you want HTML 4-style output: + + <MTMarkdownOptions output='html4'> + ... put your entry content here ... + </MTMarkdownOptions> + +The easiest way to use MTMarkdownOptions is probably to put the +opening tag right after your `<body>` tag, and the closing tag right +before `</body>`. + +To suppress Markdown processing in a particular template, i.e. to +publish the raw Markdown-formatted text without translation into +(X)HTML, set the `output` attribute to 'raw': + + <MTMarkdownOptions output='raw'> + ... put your entry content here ... + </MTMarkdownOptions> + + +### Command-Line ### + +Use the `--html4tags` command-line switch to produce HTML output from a +Unix-style command line. E.g.: + + % perl Markdown.pl --html4tags foo.text + +Type `perldoc Markdown.pl`, or read the POD documentation within the +Markdown.pl source code for more information. + + + +Bugs +---- + +To file bug reports or feature requests please send email to: +<markd****@darin*****>. + + + +Version History +--------------- + +1.0.1 (14 Dec 2004): + ++ Changed the syntax rules for code blocks and spans. Previously, + backslash escapes for special Markdown characters were processed + everywhere other than within inline HTML tags. Now, the contents + of code blocks and spans are no longer processed for backslash + escapes. This means that code blocks and spans are now treated + literally, with no special rules to worry about regarding + backslashes. + + **NOTE**: This changes the syntax from all previous versions of + Markdown. Code blocks and spans involving backslash characters + will now generate different output than before. + ++ Tweaked the rules for link definitions so that they must occur + within three spaces of the left margin. Thus if you indent a link + definition by four spaces or a tab, it will now be a code block. + + [a]: /url/ "Indented 3 spaces, this is a link def" + + [b]: /url/ "Indented 4 spaces, this is a code block" + + **IMPORTANT**: This may affect existing Markdown content if it + contains link definitions indented by 4 or more spaces. + ++ Added `>`, `+`, and `-` to the list of backslash-escapable + characters. These should have been done when these characters + were added as unordered list item markers. + ++ Trailing spaces and tabs following HTML comments and `<hr/>` tags + are now ignored. + ++ Inline links using `<` and `>` URL delimiters weren't working: + + like [this](<http://example.com/>) + ++ Added a bit of tolerance for trailing spaces and tabs after + Markdown hr's. + ++ Fixed bug where auto-links were being processed within code spans: + + like this: `<http://example.com/>` + ++ Sort-of fixed a bug where lines in the middle of hard-wrapped + paragraphs, which lines look like the start of a list item, + would accidentally trigger the creation of a list. E.g. a + paragraph that looked like this: + + I recommend upgrading to version + 8. Oops, now this line is treated + as a sub-list. + + This is fixed for top-level lists, but it can still happen for + sub-lists. E.g., the following list item will not be parsed + properly: + + + I recommend upgrading to version + 8. Oops, now this line is treated + as a sub-list. + + Given Markdown's list-creation rules, I'm not sure this can + be fixed. + ++ Standalone HTML comments are now handled; previously, they'd get + wrapped in a spurious `<p>` tag. + ++ Fix for horizontal rules preceded by 2 or 3 spaces. + ++ `<hr>` HTML tags in must occur within three spaces of left + margin. (With 4 spaces or a tab, they should be code blocks, but + weren't before this fix.) + ++ Capitalized "With" in "Markdown With SmartyPants" for + consistency with the same string label in SmartyPants.pl. + (This fix is specific to the MT plug-in interface.) + ++ Auto-linked email address can now optionally contain + a 'mailto:' protocol. I.e. these are equivalent: + + <mailto:user****@examp*****> + <user****@examp*****> + ++ Fixed annoying bug where nested lists would wind up with + spurious (and invalid) `<p>` tags. + ++ You can now write empty links: + + [like this]() + + and they'll be turned into anchor tags with empty href attributes. + This should have worked before, but didn't. + ++ `***this***` and `___this___` are now turned into + + <strong><em>this</em></strong> + + Instead of + + <strong><em>this</strong></em> + + which isn't valid. (Thanks to Michel Fortin for the fix.) + ++ Added a new substitution in `_EncodeCode()`: s/\$/$/g; This + is only for the benefit of Blosxom users, because Blosxom + (sometimes?) interpolates Perl scalars in your article bodies. + ++ Fixed problem for links defined with urls that include parens, e.g.: + + [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky) + + "Chomsky" was being erroneously treated as the URL's title. + ++ At some point during 1.0's beta cycle, I changed every sub's + argument fetching from this idiom: + + my $text = shift; + + to: + + my $text = shift || return ''; + + The idea was to keep Markdown from doing any work in a sub + if the input was empty. This introduced a bug, though: + if the input to any function was the single-character string + "0", it would also evaluate as false and return immediately. + How silly. Now fixed. + + + +Donations +--------- + +Donations to support Markdown's development are happily accepted. See: +<http://daringfireball.net/projects/markdown/> for details. + + + +Copyright and License +--------------------- + +Copyright (c) 2003-2004 John Gruber +<http://daringfireball.net/> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name "Markdown" nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as +is" and any express or implied warranties, including, but not limited +to, the implied warranties of merchantability and fitness for a +particular purpose are disclaimed. In no event shall the copyright owner +or contributors be liable for any direct, indirect, incidental, special, +exemplary, or consequential damages (including, but not limited to, +procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. Added: branches/cmake/doc/Markdown_1.0.1/Markdown.pl =================================================================== --- branches/cmake/doc/Markdown_1.0.1/Markdown.pl (rev 0) +++ branches/cmake/doc/Markdown_1.0.1/Markdown.pl 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1,1450 @@ +#!/usr/bin/perl + +# +# Markdown -- A text-to-HTML conversion tool for web writers +# +# Copyright (c) 2004 John Gruber +# <http://daringfireball.net/projects/markdown/> +# + + +package Markdown; +require 5.006_000; +use strict; +use warnings; + +use Digest::MD5 qw(md5_hex); +use vars qw($VERSION); +$VERSION = '1.0.1'; +# Tue 14 Dec 2004 + +## Disabled; causes problems under Perl 5.6.1: +use utf8; +#binmode( STDOUT, ":utf8" ); # c.f.: http://acis.openlib.org/dev/perl-unicode-struggle.html + + +# +# Global default settings: +# +my $g_empty_element_suffix = " />"; # Change to ">" for HTML output +my $g_tab_width = 4; + + +# +# Globals: +# + +# Regex to match balanced [brackets]. See Friedl's +# "Mastering Regular Expressions", 2nd Ed., pp. 328-331. +my $g_nested_brackets; +$g_nested_brackets = qr{ + (?> # Atomic matching + [^\[\]]+ # Anything other than brackets + | + \[ + (??{ $g_nested_brackets }) # Recursive set of nested brackets + \] + )* +}x; + + +# Table of hash values for escaped characters: +my %g_escape_table; +foreach my $char (split //, '\\`*_{}[]()>#+-.!') { + $g_escape_table{$char} = md5_hex($char); +} + + +# Global hashes, used by various utility routines +my %g_urls; +my %g_titles; +my %g_html_blocks; + +# Used to track when we're inside an ordered or unordered list +# (see _ProcessListItems() for details): +my $g_list_level = 0; + + +#### Blosxom plug-in interface ########################################## + +# Set $g_blosxom_use_meta to 1 to use Blosxom's meta plug-in to determine +# which posts Markdown should process, using a "meta-markup: markdown" +# header. If it's set to 0 (the default), Markdown will process all +# entries. +my $g_blosxom_use_meta = 0; + +sub start { 1; } +sub story { + my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; + + if ( (! $g_blosxom_use_meta) or + (defined($meta::markup) and ($meta::markup =~ /^\s*markdown\s*$/i)) + ){ + $$body_ref = Markdown($$body_ref); + } + 1; +} + + +#### Movable Type plug-in interface ##################################### +eval {require MT}; # Test to see if we're running in MT. +unless ($@) { + require MT; + import MT; + require MT::Template::Context; + import MT::Template::Context; + + eval {require MT::Plugin}; # Test to see if we're running >= MT 3.0. + unless ($@) { + require MT::Plugin; + import MT::Plugin; + my $plugin = new MT::Plugin({ + name => "Markdown", + description => "A plain-text-to-HTML formatting plugin. (Version: $VERSION)", + doc_link => 'http://daringfireball.net/projects/markdown/' + }); + MT->add_plugin( $plugin ); + } + + MT::Template::Context->add_container_tag(MarkdownOptions => sub { + my $ctx = shift; + my $args = shift; + my $builder = $ctx->stash('builder'); + my $tokens = $ctx->stash('tokens'); + + if (defined ($args->{'output'}) ) { + $ctx->stash('markdown_output', lc $args->{'output'}); + } + + defined (my $str = $builder->build($ctx, $tokens) ) + or return $ctx->error($builder->errstr); + $str; # return value + }); + + MT->add_text_filter('markdown' => { + label => 'Markdown', + docs => 'http://daringfireball.net/projects/markdown/', + on_format => sub { + my $text = shift; + my $ctx = shift; + my $raw = 0; + if (defined $ctx) { + my $output = $ctx->stash('markdown_output'); + if (defined $output && $output =~ m/^html/i) { + $g_empty_element_suffix = ">"; + $ctx->stash('markdown_output', ''); + } + elsif (defined $output && $output eq 'raw') { + $raw = 1; + $ctx->stash('markdown_output', ''); + } + else { + $raw = 0; + $g_empty_element_suffix = " />"; + } + } + $text = $raw ? $text : Markdown($text); + $text; + }, + }); + + # If SmartyPants is loaded, add a combo Markdown/SmartyPants text filter: + my $smartypants; + + { + no warnings "once"; + $smartypants = $MT::Template::Context::Global_filters{'smarty_pants'}; + } + + if ($smartypants) { + MT->add_text_filter('markdown_with_smartypants' => { + label => 'Markdown With SmartyPants', + docs => 'http://daringfireball.net/projects/markdown/', + on_format => sub { + my $text = shift; + my $ctx = shift; + if (defined $ctx) { + my $output = $ctx->stash('markdown_output'); + if (defined $output && $output eq 'html') { + $g_empty_element_suffix = ">"; + } + else { + $g_empty_element_suffix = " />"; + } + } + $text = Markdown($text); + $text = $smartypants->($text, '1'); + }, + }); + } +} +else { +#### BBEdit/command-line text filter interface ########################## +# Needs to be hidden from MT (and Blosxom when running in static mode). + + # We're only using $blosxom::version once; tell Perl not to warn us: + no warnings 'once'; + unless ( defined($blosxom::version) ) { + use warnings; + + #### Check for command-line switches: ################# + my %cli_opts; + use Getopt::Long; + Getopt::Long::Configure('pass_through'); + GetOptions(\%cli_opts, + 'version', + 'shortversion', + 'html4tags', + ); + if ($cli_opts{'version'}) { # Version info + print "\nThis is Markdown, version $VERSION.\n"; + print "Copyright 2004 John Gruber\n"; + print "http://daringfireball.net/projects/markdown/\n\n"; + exit 0; + } + if ($cli_opts{'shortversion'}) { # Just the version number string. + print $VERSION; + exit 0; + } + if ($cli_opts{'html4tags'}) { # Use HTML tag style instead of XHTML + $g_empty_element_suffix = ">"; + } + + + #### Process incoming text: ########################### + my $text; + { + local $/; # Slurp the whole file + $text = <>; + } + print Markdown($text); + } +} + + + +sub Markdown { +# +# Main function. The order in which other subs are called here is +# essential. Link and image substitutions need to happen before +# _EscapeSpecialChars(), so that any *'s or _'s in the <a> +# and <img> tags get encoded. +# + my $text = shift; + + # Clear the global hashes. If we don't clear these, you get conflicts + # from other articles when generating a page which contains more than + # one article (e.g. an index page that shows the N most recent + # articles): + %g_urls = (); + %g_titles = (); + %g_html_blocks = (); + + + # Standardize line endings: + $text =~ s{\r\n}{\n}g; # DOS to Unix + $text =~ s{\r}{\n}g; # Mac to Unix + + # Make sure $text ends with a couple of newlines: + $text .= "\n\n"; + + # Convert all tabs to spaces. + $text = _Detab($text); + + # Strip any lines consisting only of spaces and tabs. + # This makes subsequent regexen easier to write, because we can + # match consecutive blank lines with /\n+/ instead of something + # contorted like /[ \t]*\n+/ . + $text =~ s/^[ \t]+$//mg; + + # Turn block-level HTML blocks into hash entries + $text = _HashHTMLBlocks($text); + + # Strip link definitions, store in hashes. + $text = _StripLinkDefinitions($text); + + $text = _RunBlockGamut($text); + + $text = _UnescapeSpecialChars($text); + + return $text . "\n"; +} + + +sub _StripLinkDefinitions { +# +# Strips link definitions from text, stores the URLs and titles in +# hash references. +# + my $text = shift; + my $less_than_tab = $g_tab_width - 1; + + # Link defs are in the form: ^[id]: url "optional title" + while ($text =~ s{ + ^[ ]{0,$less_than_tab}\[(.+)\]: # id = $1 + [ \t]* + \n? # maybe *one* newline + [ \t]* + <?(\S+?)>? # url = $2 + [ \t]* + \n? # maybe one newline + [ \t]* + (?: + (?<=\s) # lookbehind for whitespace + ["(] + (.+?) # title = $3 + [")] + [ \t]* + )? # title is optional + (?:\n+|\Z) + } + {}mx) { + $g_urls{lc $1} = _EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive + if ($3) { + $g_titles{lc $1} = $3; + $g_titles{lc $1} =~ s/"/"/g; + } + } + + return $text; +} + + +sub _HashHTMLBlocks { + my $text = shift; + my $less_than_tab = $g_tab_width - 1; + + # Hashify HTML blocks: + # We only want to do this for block-level HTML tags, such as headers, + # lists, and tables. That's because we still want to wrap <p>s around + # "paragraphs" that are wrapped in non-block-level tags, such as anchors, + # phrase emphasis, and spans. The list of tags we're looking for is + # hard-coded: + my $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/; + my $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/; + + # First, look for nested blocks, e.g.: + # <div> + # <div> + # tags for inner block must be indented. + # </div> + # </div> + # + # The outermost tags must start at the left margin for this to match, and + # the inner nested divs must be indented. + # We need to do this before the next, more liberal match, because the next + # match will start at the first `<div>` and stop at the first `</div>`. + $text =~ s{ + ( # save in $1 + ^ # start of line (with /m) + <($block_tags_a) # start tag = $2 + \b # word break + (.*\n)*? # any number of lines, minimally matching + </\2> # the matching end tag + [ \t]* # trailing spaces/tabs + (?=\n+|\Z) # followed by a newline or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egmx; + + + # + # Now match more liberally, simply from `\n<tag>` to `</tag>\n` + # + $text =~ s{ + ( # save in $1 + ^ # start of line (with /m) + <($block_tags_b) # start tag = $2 + \b # word break + (.*\n)*? # any number of lines, minimally matching + .*</\2> # the matching end tag + [ \t]* # trailing spaces/tabs + (?=\n+|\Z) # followed by a newline or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egmx; + # Special case just for <hr />. It was easier to make a special case than + # to make the other regex more complicated. + $text =~ s{ + (?: + (?<=\n\n) # Starting after a blank line + | # or + \A\n? # the beginning of the doc + ) + ( # save in $1 + [ ]{0,$less_than_tab} + <(hr) # start tag = $2 + \b # word break + ([^<>])*? # + /?> # the matching end tag + [ \t]* + (?=\n{2,}|\Z) # followed by a blank line or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egx; + + # Special case for standalone HTML comments: + $text =~ s{ + (?: + (?<=\n\n) # Starting after a blank line + | # or + \A\n? # the beginning of the doc + ) + ( # save in $1 + [ ]{0,$less_than_tab} + (?s: + <! + (--.*?--\s*)+ + > + ) + [ \t]* + (?=\n{2,}|\Z) # followed by a blank line or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egx; + + + return $text; +} + + +sub _RunBlockGamut { +# +# These are all the transformations that form block-level +# tags like paragraphs, headers, and list items. +# + my $text = shift; + + $text = _DoHeaders($text); + + # Do Horizontal Rules: + $text =~ s{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx; + $text =~ s{^[ ]{0,2}([ ]? -[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx; + $text =~ s{^[ ]{0,2}([ ]? _[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx; + + $text = _DoLists($text); + + $text = _DoCodeBlocks($text); + + $text = _DoBlockQuotes($text); + + # We already ran _HashHTMLBlocks() before, in Markdown(), but that + # was to escape raw HTML in the original Markdown source. This time, + # we're escaping the markup we've just created, so that we don't wrap + # <p> tags around block-level tags. + $text = _HashHTMLBlocks($text); + + $text = _FormParagraphs($text); + + return $text; +} + + +sub _RunSpanGamut { +# +# These are all the transformations that occur *within* block-level +# tags like paragraphs, headers, and list items. +# + my $text = shift; + + $text = _DoCodeSpans($text); + + $text = _EscapeSpecialChars($text); + + # Process anchor and image tags. Images must come first, + # because ![foo][f] looks like an anchor. + $text = _DoImages($text); + $text = _DoAnchors($text); + + # Make links out of things like `<http://example.com/>` + # Must come after _DoAnchors(), because you can use < and > + # delimiters in inline links like [this](<url>). + $text = _DoAutoLinks($text); + + $text = _EncodeAmpsAndAngles($text); + + $text = _DoItalicsAndBold($text); + + # Do hard breaks: + $text =~ s/ {2,}\n/ <br$g_empty_element_suffix\n/g; + + return $text; +} + + +sub _EscapeSpecialChars { + my $text = shift; + my $tokens ||= _TokenizeHTML($text); + + $text = ''; # rebuild $text from the tokens +# my $in_pre = 0; # Keep track of when we're inside <pre> or <code> tags. +# my $tags_to_skip = qr!<(/?)(?:pre|code|kbd|script|math)[\s>]!; + + foreach my $cur_token (@$tokens) { + if ($cur_token->[0] eq "tag") { + # Within tags, encode * and _ so they don't conflict + # with their use in Markdown for italics and strong. + # We're replacing each such character with its + # corresponding MD5 checksum value; this is likely + # overkill, but it should prevent us from colliding + # with the escape values by accident. + $cur_token->[1] =~ s! \* !$g_escape_table{'*'}!gx; + $cur_token->[1] =~ s! _ !$g_escape_table{'_'}!gx; + $text .= $cur_token->[1]; + } else { + my $t = $cur_token->[1]; + $t = _EncodeBackslashEscapes($t); + $text .= $t; + } + } + return $text; +} + + +sub _DoAnchors { +# +# Turn Markdown link shortcuts into XHTML <a> tags. +# + my $text = shift; + + # + # First, handle reference-style links: [link text] [id] + # + $text =~ s{ + ( # wrap whole match in $1 + \[ + ($g_nested_brackets) # link text = $2 + \] + + [ ]? # one optional space + (?:\n[ ]*)? # one optional newline followed by spaces + + \[ + (.*?) # id = $3 + \] + ) + }{ + my $result; + my $whole_match = $1; + my $link_text = $2; + my $link_id = lc $3; + + if ($link_id eq "") { + $link_id = lc $link_text; # for shortcut links like [this][]. + } + + if (defined $g_urls{$link_id}) { + my $url = $g_urls{$link_id}; + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<a href=\"$url\""; + if ( defined $g_titles{$link_id} ) { + my $title = $g_titles{$link_id}; + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + $result .= ">$link_text</a>"; + } + else { + $result = $whole_match; + } + $result; + }xsge; + + # + # Next, inline-style links: [link text](url "optional title") + # + $text =~ s{ + ( # wrap whole match in $1 + \[ + ($g_nested_brackets) # link text = $2 + \] + \( # literal paren + [ \t]* + <?(.*?)>? # href = $3 + [ \t]* + ( # $4 + (['"]) # quote char = $5 + (.*?) # Title = $6 + \5 # matching quote + )? # title is optional + \) + ) + }{ + my $result; + my $whole_match = $1; + my $link_text = $2; + my $url = $3; + my $title = $6; + + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<a href=\"$url\""; + + if (defined $title) { + $title =~ s/"/"/g; + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + + $result .= ">$link_text</a>"; + + $result; + }xsge; + + return $text; +} + + +sub _DoImages { +# +# Turn Markdown image shortcuts into <img> tags. +# + my $text = shift; + + # + # First, handle reference-style labeled images: ![alt text][id] + # + $text =~ s{ + ( # wrap whole match in $1 + !\[ + (.*?) # alt text = $2 + \] + + [ ]? # one optional space + (?:\n[ ]*)? # one optional newline followed by spaces + + \[ + (.*?) # id = $3 + \] + + ) + }{ + my $result; + my $whole_match = $1; + my $alt_text = $2; + my $link_id = lc $3; + + if ($link_id eq "") { + $link_id = lc $alt_text; # for shortcut links like ![this][]. + } + + $alt_text =~ s/"/"/g; + if (defined $g_urls{$link_id}) { + my $url = $g_urls{$link_id}; + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<img src=\"$url\" alt=\"$alt_text\""; + if (defined $g_titles{$link_id}) { + my $title = $g_titles{$link_id}; + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + $result .= $g_empty_element_suffix; + } + else { + # If there's no such link ID, leave intact: + $result = $whole_match; + } + + $result; + }xsge; + + # + # Next, handle inline images: ![alt text](url "optional title") + # Don't forget: encode * and _ + + $text =~ s{ + ( # wrap whole match in $1 + !\[ + (.*?) # alt text = $2 + \] + \( # literal paren + [ \t]* + <?(\S+?)>? # src url = $3 + [ \t]* + ( # $4 + (['"]) # quote char = $5 + (.*?) # title = $6 + \5 # matching quote + [ \t]* + )? # title is optional + \) + ) + }{ + my $result; + my $whole_match = $1; + my $alt_text = $2; + my $url = $3; + my $title = ''; + if (defined($6)) { + $title = $6; + } + + $alt_text =~ s/"/"/g; + $title =~ s/"/"/g; + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<img src=\"$url\" alt=\"$alt_text\""; + if (defined $title) { + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + $result .= $g_empty_element_suffix; + + $result; + }xsge; + + return $text; +} + + +sub _DoHeaders { + my $text = shift; + + # Setext-style headers: + # Header 1 + # ======== + # + # Header 2 + # -------- + # + $text =~ s{ ^(.+)[ \t]*\n=+[ \t]*\n+ }{ + "<h1>" . _RunSpanGamut($1) . "</h1>\n\n"; + }egmx; + + $text =~ s{ ^(.+)[ \t]*\n-+[ \t]*\n+ }{ + "<h2>" . _RunSpanGamut($1) . "</h2>\n\n"; + }egmx; + + + # atx-style headers: + # # Header 1 + # ## Header 2 + # ## Header 2 with closing hashes ## + # ... + # ###### Header 6 + # + $text =~ s{ + ^(\#{1,6}) # $1 = string of #'s + [ \t]* + (.+?) # $2 = Header text + [ \t]* + \#* # optional closing #'s (not counted) + \n+ + }{ + my $h_level = length($1); + "<h$h_level>" . _RunSpanGamut($2) . "</h$h_level>\n\n"; + }egmx; + + return $text; +} + + +sub _DoLists { +# +# Form HTML ordered (numbered) and unordered (bulleted) lists. +# + my $text = shift; + my $less_than_tab = $g_tab_width - 1; + + # Re-usable patterns to match list item bullets and number markers: + my $marker_ul = qr/[*+-]/; + my $marker_ol = qr/\d+[.]/; + my $marker_any = qr/(?:$marker_ul|$marker_ol)/; + + # Re-usable pattern to match any entirel ul or ol list: + my $whole_list = qr{ + ( # $1 = whole list + ( # $2 + [ ]{0,$less_than_tab} + (${marker_any}) # $3 = first list item marker + [ \t]+ + ) + (?s:.+?) + ( # $4 + \z + | + \n{2,} + (?=\S) + (?! # Negative lookahead for another list item marker + [ \t]* + ${marker_any}[ \t]+ + ) + ) + ) + }mx; + + # We use a different prefix before nested lists than top-level lists. + # See extended comment in _ProcessListItems(). + # + # Note: There's a bit of duplication here. My original implementation + # created a scalar regex pattern as the conditional result of the test on + # $g_list_level, and then only ran the $text =~ s{...}{...}egmx + # substitution once, using the scalar as the pattern. This worked, + # everywhere except when running under MT on my hosting account at Pair + # Networks. There, this caused all rebuilds to be killed by the reaper (or + # perhaps they crashed, but that seems incredibly unlikely given that the + # same script on the same server ran fine *except* under MT. I've spent + # more time trying to figure out why this is happening than I'd like to + # admit. My only guess, backed up by the fact that this workaround works, + # is that Perl optimizes the substition when it can figure out that the + # pattern will never change, and when this optimization isn't on, we run + # afoul of the reaper. Thus, the slightly redundant code to that uses two + # static s/// patterns rather than one conditional pattern. + + if ($g_list_level) { + $text =~ s{ + ^ + $whole_list + }{ + my $list = $1; + my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol"; + # Turn double returns into triple returns, so that we can make a + # paragraph for the last item in a list, if necessary: + $list =~ s/\n{2,}/\n\n\n/g; + my $result = _ProcessListItems($list, $marker_any); + $result = "<$list_type>\n" . $result . "</$list_type>\n"; + $result; + }egmx; + } + else { + $text =~ s{ + (?:(?<=\n\n)|\A\n?) + $whole_list + }{ + my $list = $1; + my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol"; + # Turn double returns into triple returns, so that we can make a + # paragraph for the last item in a list, if necessary: + $list =~ s/\n{2,}/\n\n\n/g; + my $result = _ProcessListItems($list, $marker_any); + $result = "<$list_type>\n" . $result . "</$list_type>\n"; + $result; + }egmx; + } + + + return $text; +} + + +sub _ProcessListItems { +# +# Process the contents of a single ordered or unordered list, splitting it +# into individual list items. +# + + my $list_str = shift; + my $marker_any = shift; + + + # The $g_list_level global keeps track of when we're inside a list. + # Each time we enter a list, we increment it; when we leave a list, + # we decrement. If it's zero, we're not in a list anymore. + # + # We do this because when we're not inside a list, we want to treat + # something like this: + # + # I recommend upgrading to version + # 8. Oops, now this line is treated + # as a sub-list. + # + # As a single paragraph, despite the fact that the second line starts + # with a digit-period-space sequence. + # + # Whereas when we're inside a list (or sub-list), that line will be + # treated as the start of a sub-list. What a kludge, huh? This is + # an aspect of Markdown's syntax that's hard to parse perfectly + # without resorting to mind-reading. Perhaps the solution is to + # change the syntax rules such that sub-lists must start with a + # starting cardinal number; e.g. "1." or "a.". + + $g_list_level++; + + # trim trailing blank lines: + $list_str =~ s/\n{2,}\z/\n/; + + + $list_str =~ s{ + (\n)? # leading line = $1 + (^[ \t]*) # leading whitespace = $2 + ($marker_any) [ \t]+ # list marker = $3 + ((?s:.+?) # list item text = $4 + (\n{1,2})) + (?= \n* (\z | \2 ($marker_any) [ \t]+)) + }{ + my $item = $4; + my $leading_line = $1; + my $leading_space = $2; + + if ($leading_line or ($item =~ m/\n{2,}/)) { + $item = _RunBlockGamut(_Outdent($item)); + } + else { + # Recursion for sub-lists: + $item = _DoLists(_Outdent($item)); + chomp $item; + $item = _RunSpanGamut($item); + } + + "<li>" . $item . "</li>\n"; + }egmx; + + $g_list_level--; + return $list_str; +} + + + +sub _DoCodeBlocks { +# +# Process Markdown `<pre><code>` blocks. +# + + my $text = shift; + + $text =~ s{ + (?:\n\n|\A) + ( # $1 = the code block -- one or more lines, starting with a space/tab + (?: + (?:[ ]{$g_tab_width} | \t) # Lines must start with a tab or a tab-width of spaces + .*\n+ + )+ + ) + ((?=^[ ]{0,$g_tab_width}\S)|\Z) # Lookahead for non-space at line-start, or end of doc + }{ + my $codeblock = $1; + my $result; # return value + + $codeblock = _EncodeCode(_Outdent($codeblock)); + $codeblock = _Detab($codeblock); + $codeblock =~ s/\A\n+//; # trim leading newlines + $codeblock =~ s/\s+\z//; # trim trailing whitespace + + $result = "\n\n<pre><code>" . $codeblock . "\n</code></pre>\n\n"; + + $result; + }egmx; + + return $text; +} + + +sub _DoCodeSpans { +# +# * Backtick quotes are used for <code></code> spans. +# +# * You can use multiple backticks as the delimiters if you want to +# include literal backticks in the code span. So, this input: +# +# Just type ``foo `bar` baz`` at the prompt. +# +# Will translate to: +# +# <p>Just type <code>foo `bar` baz</code> at the prompt.</p> +# +# There's no arbitrary limit to the number of backticks you +# can use as delimters. If you need three consecutive backticks +# in your code, use four for delimiters, etc. +# +# * You can use spaces to get literal backticks at the edges: +# +# ... type `` `bar` `` ... +# +# Turns to: +# +# ... type <code>`bar`</code> ... +# + + my $text = shift; + + $text =~ s@ + (`+) # $1 = Opening run of ` + (.+?) # $2 = The code block + (?<!`) + \1 # Matching closer + (?!`) + @ + my $c = "$2"; + $c =~ s/^[ \t]*//g; # leading whitespace + $c =~ s/[ \t]*$//g; # trailing whitespace + $c = _EncodeCode($c); + "<code>$c</code>"; + @egsx; + + return $text; +} + + +sub _EncodeCode { +# +# Encode/escape certain characters inside Markdown code runs. +# The point is that in code, these characters are literals, +# and lose their special Markdown meanings. +# + local $_ = shift; + + # Encode all ampersands; HTML entities are not + # entities within a Markdown code span. + s/&/&/g; + + # Encode $'s, but only if we're running under Blosxom. + # (Blosxom interpolates Perl variables in article bodies.) + { + no warnings 'once'; + if (defined($blosxom::version)) { + s/\$/$/g; + } + } + + + # Do the angle bracket song and dance: + s! < !<!gx; + s! > !>!gx; + + # Now, escape characters that are magic in Markdown: + s! \* !$g_escape_table{'*'}!gx; + s! _ !$g_escape_table{'_'}!gx; + s! { !$g_escape_table{'{'}!gx; + s! } !$g_escape_table{'}'}!gx; + s! \[ !$g_escape_table{'['}!gx; + s! \] !$g_escape_table{']'}!gx; + s! \\ !$g_escape_table{'\\'}!gx; + + return $_; +} + + +sub _DoItalicsAndBold { + my $text = shift; + + # <strong> must go first: + $text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 } + {<strong>$2</strong>}gsx; + + $text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 } + {<em>$2</em>}gsx; + + return $text; +} + + +sub _DoBlockQuotes { + my $text = shift; + + $text =~ s{ + ( # Wrap whole match in $1 + ( + ^[ \t]*>[ \t]? # '>' at the start of a line + .+\n # rest of the first line + (.+\n)* # subsequent consecutive lines + \n* # blanks + )+ + ) + }{ + my $bq = $1; + $bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting + $bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines + $bq = _RunBlockGamut($bq); # recurse + + $bq =~ s/^/ /g; + # These leading spaces screw with <pre> content, so we need to fix that: + $bq =~ s{ + (\s*<pre>.+?</pre>) + }{ + my $pre = $1; + $pre =~ s/^ //mg; + $pre; + }egsx; + + "<blockquote>\n$bq\n</blockquote>\n\n"; + }egmx; + + + return $text; +} + + +sub _FormParagraphs { +# +# Params: +# $text - string to process with html <p> tags +# + my $text = shift; + + # Strip leading and trailing lines: + $text =~ s/\A\n+//; + $text =~ s/\n+\z//; + + my @grafs = split(/\n{2,}/, $text); + + # + # Wrap <p> tags. + # + foreach (@grafs) { + unless (defined( $g_html_blocks{$_} )) { + $_ = _RunSpanGamut($_); + s/^([ \t]*)/<p>/; + $_ .= "</p>"; + } + } + + # + # Unhashify HTML blocks + # + foreach (@grafs) { + if (defined( $g_html_blocks{$_} )) { + $_ = $g_html_blocks{$_}; + } + } + + return join "\n\n", @grafs; +} + + +sub _EncodeAmpsAndAngles { +# Smart processing for ampersands and angle brackets that need to be encoded. + + my $text = shift; + + # Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: + # http://bumppo.net/projects/amputator/ + $text =~ s/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/&/g; + + # Encode naked <'s + $text =~ s{<(?![a-z/?\$!])}{<}gi; + + return $text; +} + + +sub _EncodeBackslashEscapes { +# +# Parameter: String. +# Returns: The string, with after processing the following backslash +# escape sequences. +# + local $_ = shift; + + s! \\\\ !$g_escape_table{'\\'}!gx; # Must process escaped backslashes first. + s! \\` !$g_escape_table{'`'}!gx; + s! \\\* !$g_escape_table{'*'}!gx; + s! \\_ !$g_escape_table{'_'}!gx; + s! \\\{ !$g_escape_table{'{'}!gx; + s! \\\} !$g_escape_table{'}'}!gx; + s! \\\[ !$g_escape_table{'['}!gx; + s! \\\] !$g_escape_table{']'}!gx; + s! \\\( !$g_escape_table{'('}!gx; + s! \\\) !$g_escape_table{')'}!gx; + s! \\> !$g_escape_table{'>'}!gx; + s! \\\# !$g_escape_table{'#'}!gx; + s! \\\+ !$g_escape_table{'+'}!gx; + s! \\\- !$g_escape_table{'-'}!gx; + s! \\\. !$g_escape_table{'.'}!gx; + s{ \\! }{$g_escape_table{'!'}}gx; + + return $_; +} + + +sub _DoAutoLinks { + my $text = shift; + + $text =~ s{<((https?|ftp):[^'">\s]+)>}{<a href="$1">$1</a>}gi; + + # Email addresses: <addre****@domai*****> + $text =~ s{ + < + (?:mailto:)? + ( + [-.\w]+ + \@ + [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ + ) + > + }{ + _EncodeEmailAddress( _UnescapeSpecialChars($1) ); + }egix; + + return $text; +} + + +sub _EncodeEmailAddress { +# +# Input: an email address, e.g. "foo****@examp*****" +# +# Output: the email address as a mailto link, with each character +# of the address encoded as either a decimal or hex entity, in +# the hopes of foiling most address harvesting spam bots. E.g.: +# +# <a href="mailto:foo@e +# xample.com">foo +# @example.com</a> +# +# Based on a filter by Matthew Wickline, posted to the BBEdit-Talk +# mailing list: <http://tinyurl.com/yu7ue> +# + + my $addr = shift; + + srand; + my @encode = ( + sub { '&#' . ord(shift) . ';' }, + sub { '&#x' . sprintf( "%X", ord(shift) ) . ';' }, + sub { shift }, + ); + + $addr = "mailto:" . $addr; + + $addr =~ s{(.)}{ + my $char = $1; + if ( $char eq '@' ) { + # this *must* be encoded. I insist. + $char = $encode[int rand 1]->($char); + } elsif ( $char ne ':' ) { + # leave ':' alone (to spot mailto: later) + my $r = rand; + # roughly 10% raw, 45% hex, 45% dec + $char = ( + $r > .9 ? $encode[2]->($char) : + $r < .45 ? $encode[1]->($char) : + $encode[0]->($char) + ); + } + $char; + }gex; + + $addr = qq{<a href="$addr">$addr</a>}; + $addr =~ s{">.+?:}{">}; # strip the mailto: from the visible part + + return $addr; +} + + +sub _UnescapeSpecialChars { +# +# Swap back in all the special characters we've hidden. +# + my $text = shift; + + while( my($char, $hash) = each(%g_escape_table) ) { + $text =~ s/$hash/$char/g; + } + return $text; +} + + +sub _TokenizeHTML { +# +# Parameter: String containing HTML markup. +# Returns: Reference to an array of the tokens comprising the input +# string. Each token is either a tag (possibly with nested, +# tags contained therein, such as <a href="<MTFoo>">, or a +# run of text between tags. Each element of the array is a +# two-element array; the first is either 'tag' or 'text'; +# the second is the actual value. +# +# +# Derived from the _tokenize() subroutine from Brad Choate's MTRegex plugin. +# <http://www.bradchoate.com/past/mtregex.php> +# + + my $str = shift; + my $pos = 0; + my $len = length $str; + my @tokens; + + my $depth = 6; + my $nested_tags = join('|', ('(?:<[a-z/!$](?:[^<>]') x $depth) . (')*>)' x $depth); + my $match = qr/(?s: <! ( -- .*? -- \s* )+ > ) | # comment + (?s: <\? .*? \?> ) | # processing instruction + $nested_tags/ix; # nested tags + + while ($str =~ m/($match)/g) { + my $whole_tag = $1; + my $sec_start = pos $str; + my $tag_start = $sec_start - length $whole_tag; + if ($pos < $tag_start) { + push @tokens, ['text', substr($str, $pos, $tag_start - $pos)]; + } + push @tokens, ['tag', $whole_tag]; + $pos = pos $str; + } + push @tokens, ['text', substr($str, $pos, $len - $pos)] if $pos < $len; + \@tokens; +} + + +sub _Outdent { +# +# Remove one level of line-leading tabs or spaces +# + my $text = shift; + + $text =~ s/^(\t|[ ]{1,$g_tab_width})//gm; + return $text; +} + + +sub _Detab { +# +# Cribbed from a post by Bart Lateur: +# <http://www.nntp.perl.org/group/perl.macperl.anyperl/154> +# + my $text = shift; + + $text =~ s{(.*?)\t}{$1.(' ' x ($g_tab_width - length($1) % $g_tab_width))}ge; + return $text; +} + + +1; + +__END__ + + +=pod + +=head1 NAME + +B<Markdown> + + +=head1 SYNOPSIS + +B<Markdown.pl> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ] + [ I<file> ... ] + + +=head1 DESCRIPTION + +Markdown is a text-to-HTML filter; it translates an easy-to-read / +easy-to-write structured text format into HTML. Markdown's text format +is most similar to that of plain text email, and supports features such +as headers, *emphasis*, code blocks, blockquotes, and links. + +Markdown's syntax is designed not as a generic markup language, but +specifically to serve as a front-end to (X)HTML. You can use span-level +HTML tags anywhere in a Markdown document, and you can use block level +HTML tags (like <div> and <table> as well). + +For more information about Markdown's syntax, see: + + http://daringfireball.net/projects/markdown/ + + +=head1 OPTIONS + +Use "--" to end switch parsing. For example, to open a file named "-z", use: + + Markdown.pl -- -z + +=over 4 + + +=item B<--html4tags> + +Use HTML 4 style for empty element tags, e.g.: + + <br> + +instead of Markdown's default XHTML style tags, e.g.: + + <br /> + + +=item B<-v>, B<--version> + +Display Markdown's version number and copyright information. + + +=item B<-s>, B<--shortversion> + +Display the short-form version number. + + +=back + + + +=head1 BUGS + +To file bug reports or feature requests (other than topics listed in the +Caveats section above) please send email to: + + suppo****@darin***** + +Please include with your report: (1) the example input; (2) the output +you expected; (3) the output Markdown actually produced. + + +=head1 VERSION HISTORY + +See the readme file for detailed release notes for this version. + +1.0.1 - 14 Dec 2004 + +1.0 - 28 Aug 2004 + + +=head1 AUTHOR + + John Gruber + http://daringfireball.net + + PHP port and other contributions by Michel Fortin + http://michelf.com + + +=head1 COPYRIGHT AND LICENSE + +Copyright (c) 2003-2004 John Gruber +<http://daringfireball.net/> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name "Markdown" nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as +is" and any express or implied warranties, including, but not limited +to, the implied warranties of merchantability and fitness for a +particular purpose are disclaimed. In no event shall the copyright owner +or contributors be liable for any direct, indirect, incidental, special, +exemplary, or consequential damages (including, but not limited to, +procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. + +=cut Modified: branches/cmake/doc/convtext.bat =================================================================== --- branches/cmake/doc/convtext.bat 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/doc/convtext.bat 2019-03-10 14:34:42 UTC (rev 7475) @@ -16,3 +16,7 @@ %TOSJIS% -i ..\cygterm\COPYING -o %REF_J%\CygTerm+-LICENSE.txt -l unix %ZLIBCP% -i ..\libs\zlib\README -o %REF_E%\zlib-LICENSE.txt -l unix %ZLIBCP% -i ..\libs\zlib\README -o %REF_J%\zlib-LICENSE.txt -l unix + +sed -e '1s/^\xef\xbb\xbf//' < ja/html/reference/build_with_cmake.md > ja/html/reference/build_with_cmake_without_bom.md +perl Markdown_1.0.1/Markdown.pl ja/html/reference/build_with_cmake_without_bom.md > ja/html/reference/build_with_cmake_utf8.html +%TOSJIS% -i ja/html/reference/build_with_cmake_utf8.html -o ja/html/reference/build_with_cmake.html -c utf8 Modified: branches/cmake/doc/en/html/about/history.html =================================================================== --- branches/cmake/doc/en/html/about/history.html 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/doc/en/html/about/history.html 2019-03-10 14:34:42 UTC (rev 7475) @@ -33,6 +33,12 @@ <h3 id="teraterm_4.103">2019.xx.xx (Ver 4.103)</h3> <ul class="history"> + <li>Bug fixes + <ul> + <li><!--IME\x82̕ϊ\xB7\x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x88ʒu\x82\xAA\x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɒǏ]\x82\xB5\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B-->This bus was introduced in 4.102.</li> + </ul> + </li> + <li>Misc <ul> <li>upgraded TTSSH to <a href="#ttssh_2.89">2.89</a>.</li> Modified: branches/cmake/doc/ja/html/about/history.html =================================================================== --- branches/cmake/doc/ja/html/about/history.html 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/doc/ja/html/about/history.html 2019-03-10 14:34:42 UTC (rev 7475) @@ -33,6 +33,12 @@ <h3 id="teraterm_4.103">2019.xx.xx (Ver 4.103)</h3> <ul class="history"> + <li>\x83o\x83O\x8FC\x90\xB3 + <ul> + <li>IME\x82̕ϊ\xB7\x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x88ʒu\x82\xAA\x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɒǏ]\x82\xB5\x82Ȃ\xA2\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.102\x82ł̃G\x83\x93\x83o\x83O\x81B</li> + </ul> + </li> + <li>\x82\xBB\x82̑\xBC <ul> <li><a href="#ttssh_2.89">TTSSH(2.89)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li> Added: branches/cmake/doc/ja/html/reference/build_with_cmake.md =================================================================== --- branches/cmake/doc/ja/html/reference/build_with_cmake.md (rev 0) +++ branches/cmake/doc/ja/html/reference/build_with_cmake.md 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1,32 @@ +# cmakeを使ったビルド + +- 実験的に cmake を使用してビルドすることができます +- cmake https://cmake.org/ + +## cmakeのバージョン + +- Visual Studio 2005 をサポートしている cmake の最後のバージョンは 3.11.4 です +- 2005 以外の Visual Studio を使用する場合は特に制限はありません +- Visual Studio 2017 インストーラーで、オプションを選べば cmake をインストールできます + +## ライブラリのビルド + +- teraterm が使用するライブラリをビルドして準備しておきます +- `lib/build_library_with_cmake.md` を参照してください +- ライブラリは `develop.txt` を参照してください + +## teratermのビルド + +- ソースツリーのトップから、次のようにコマンドを実行します + ``` + mkdir build_vs2005 + cd build_vs2005 + "c:\Program Files (x86)\CMake-3.11.4\bin\cmake.exe" .. -G "Visual Studio 8 2005" + ``` + - パスが通っていれば cmake はフルパスで書く必要はありません + - `-G` オプションの後ろは使用する Visual Studio のバージョンに合わせて調整します +- sln ファイルが生成されるので Visual Studio で開くことができます +- cmakeを使ってビルドする場合は次のコマンドを実行します + ``` + cmake --build . --config release + ``` Modified: branches/cmake/libs/build_library_with_cmake.md =================================================================== --- branches/cmake/libs/build_library_with_cmake.md 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/libs/build_library_with_cmake.md 2019-03-10 14:34:42 UTC (rev 7475) @@ -2,18 +2,41 @@ # libフォルダ - teratermが利用する外部のライブラリをビルドするためのフォルダ -- コンパイラ向けに各々ビルドする +- コンパイラ向けに各々ビルド - 1度ビルドしてライブラリを生成しておく +# 準備 + +## Visual Studio + +- cmake + - PATHが通してあればok + - cygwinのcmakeはつかえない(Visual Studioをサポートしていない) + - Visual Studio 2005 を使う場合は cmake 3.11.4 を使用する必要がある +- perl + - OpenSSL のコンパイル、ドキュメントファイルの文字コード・改行コード変換に必要 + - ActivePerl 5.8 以上、または cygwin perl + - PATHが通っていなければ自動で探す + +## MinGW 共通 (experimental) + +- Cygwin,MSYS2,linux(wsl)上のMinGWでビルド可能 +- 各環境で動作するcmake,make,(MinGW)gcc,perlが必要 + # ビルド手順 +必要なアーカイブを自動的にダウンロードするので、 +インターネットが利用できる環境でビルドする必要がある + ## Visual Studioの場合 ### batファイルを使用する場合 +- 自動的にビルド - buildall_cmake.bat を実行 -- cmakeを選択 - コンパイルに使用する Visual Studioを選ぶ +- VS2005の場合はcmake 3.11.4 をダウンロードして + libs\cmake-3.11.4-win32-x86 にインストールする ### cmakeを使用する場合 @@ -21,12 +44,11 @@ - `cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P buildall.cmake` - `cmake -DCMAKE_GENERATOR="Visual Studio 15 2017 Win64" -P buildall.cmake` - Visual Studio 2005の場合は、cmakeのバージョン3.11.4以前を使用する - - `cmake -DCMAKE_GENERATOR="Visual Studio 8 2005" -P buildall.cmake` + - cmake が libs\cmake-3.11.4-win32-x86 にインストールしてある場合 + `"libs\cmake-3.11.4-win32-x86\bin\cmake.exe" -DCMAKE_GENERATOR="Visual Studio 8 2005" -P buildall.cmake` ## MinGW 共通 -- Cygwin,MSYS2,linux(wsl)上のMinGWでビルドできる -- 各環境で動作するcmake,make,(MinGW)gcc,perlが必要 - 各々の環境のcmakeを使って `cmake -DCMAKE_GENERATOR="Unix Makefiles" -P buildall.cmake` を実行 @@ -43,11 +65,12 @@ ## download アーカイブダウンロードフォルダ -- ダウンロードしたアーカイブファイルが置かれます -- 自動でダウンロードされます +- ダウンロードしたアーカイブファイルが置かれる +- 自動でダウンロードされる - ダウンロードされていると再利用する +- ビルド後、参照する必要がなければ削除できる ## build ビルドフォルダ -- build/oniguruma_{compiler}/ などの下でビルドされます -- ビルド後は参照する必要がなければ削除できます。 +- build/oniguruma_{compiler}/ などの下でビルドされる +- ビルド後、参照する必要がなければ削除できる Modified: branches/cmake/libs/buildall_cmake.bat =================================================================== --- branches/cmake/libs/buildall_cmake.bat 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/libs/buildall_cmake.bat 2019-03-10 14:34:42 UTC (rev 7475) @@ -2,25 +2,9 @@ setlocal cd /d %~dp0 +set CMAKE="cmake.exe2" set opt= -:retry_cmake -set CMAKE=%~dp0cmake-3.11.4-win32-x86\bin\cmake.exe -echo 1. \x8E\xA9\x95\xAA\x82\xCCcmake.exe\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9(PATH\x82\xF0\x92ʂ\xB5\x82Ă\xA0\x82\xE9) -echo 2. VS2005\x82ł\xE0\x8Eg\x97p\x82ł\xAB\x82\xE9cmake\x8Eg\x97p\x82\xB7\x82\xE9 -echo (\x95K\x97v\x82Ȃ玩\x93\xAE\x82Ń_\x83E\x83\x93\x83\x8D\x81[\x83h\x82\xB5\x82āA\x82\xB1\x82̃t\x83H\x83\x8B\x83_\x82ɃC\x83\x93\x83X\x83g\x81[\x83\x8B\x82\xB5\x82܂\xB7) -if exist %CMAKE% echo \x83C\x83\x93\x83X\x83g\x81[\x83\x8B\x8Dς\xDD(%CMAKE%) - -set /p no="select no " -if "%no%" == "1" set CMAKE="cmake.exe" & goto finish_cmake - -if exist %CMAKE% goto finish_cmake -echo @echo off > ..\cmake.bat -echo %CMAKE% %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> ..\cmake.bat -call getcmake.bat - -:finish_cmake - :retry_vs echo 1. Visual Studio 15 2017 echo 2. Visual Studio 14 2015 @@ -29,18 +13,18 @@ echo 5. Visual Studio 10 2010 echo 6. Visual Studio 9 2008 echo 7. Visual Studio 8 2005 -echo 9. Visual Studio NMake -echo z. Cygwin MinGW Release + Unix Makefiles +rem echo 9. Visual Studio NMake (experimental) +rem echo z. Cygwin MinGW Release + Unix Makefiles (experimental) set /p no="select no " echo %no% -if "%no%" == "1" set GENERATOR="Visual Studio 15 2017" & chcp 65001 & goto build_all +if "%no%" == "1" set GENERATOR="Visual Studio 15 2017" & goto build_all if "%no%" == "2" set GENERATOR="Visual Studio 14 2015" & goto build_all if "%no%" == "3" set GENERATOR="Visual Studio 12 2013" & goto build_all if "%no%" == "4" set GENERATOR="Visual Studio 11 2012" & goto build_all if "%no%" == "5" set GENERATOR="Visual Studio 10 2010" & goto build_all if "%no%" == "6" set GENERATOR="Visual Studio 9 2008" & goto build_all -if "%no%" == "7" set GENERATOR="Visual Studio 8 2005" & goto build_all +if "%no%" == "7" set GENERATOR="Visual Studio 8 2005" & call :cmake_3_11_4 & goto build_all_2 if "%no%" == "9" set GENERATOR="NMake Makefiles" & set OPT=-DCMAKE_BUILD_TYPE=Release & goto build_all if "%no%" == "z" set GENERATOR="Unix Makefiles" & set OPT=-DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake & goto build_all echo ? retry @@ -47,6 +31,15 @@ goto retry_vs :build_all +where %CMAKE% +if %errorlevel% == 0 goto build_all_2 +set CMAKE="C:\Program Files\CMake\bin\cmake.exe" +if exist %CMAKE% echo %CMAKE% \x82\xF0\x8Eg\x97p & goto build_all_2 +echo cmake\x82\xAA\x8C\xA9\x82\xA9\x82\xE8\x82܂\xB9\x82\xF1 +pause +exit + +:build_all_2 set C=%CMAKE% -DCMAKE_GENERATOR=%GENERATOR% %OPT% -P buildall.cmake echo %C% title %C% @@ -57,3 +50,26 @@ echo build complete endlocal pause +exit + +:cmake_3_11_4 +set CMAKE=%~dp0cmake-3.11.4-win32-x86\bin\cmake.exe +echo 1. \x8E\xA9\x95\xAA\x82\xCCcmake.exe\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9(PATH\x82\xF0\x92ʂ\xB5\x82Ă\xA0\x82\xE9) +echo 2. VS2005\x82ł\xE0\x8Eg\x97p\x82ł\xAB\x82\xE9cmake\x8Eg\x97p\x82\xB7\x82\xE9 +echo (\x95K\x97v\x82Ȃ玩\x93\xAE\x82Ń_\x83E\x83\x93\x83\x8D\x81[\x83h\x82\xB5\x82āA\x82\xB1\x82̃t\x83H\x83\x8B\x83_\x82ɃC\x83\x93\x83X\x83g\x81[\x83\x8B\x82\xB7\x82\xE9) +if exist %CMAKE% echo \x83C\x83\x93\x83X\x83g\x81[\x83\x8B\x8Dς\xDD(%CMAKE%) + +set /p no="select no " +echo %no% +if "%no%" == "2" goto download + +set CMAKE="cmake.exe" +where %CMAKE% +goto finish_cmake + +:download +if exist %CMAKE% goto finish_cmake +call getcmake.bat + +:finish_cmake +exit /b Modified: branches/cmake/libs/openssl.cmake =================================================================== --- branches/cmake/libs/openssl.cmake 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/libs/openssl.cmake 2019-03-10 14:34:42 UTC (rev 7475) @@ -4,51 +4,51 @@ #### if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "")) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - # multi-configuration - execute_process( - COMMAND ${CMAKE_COMMAND} - -DCMAKE_GENERATOR=${CMAKE_GENERATOR} - -DCMAKE_CONFIGURATION_TYPE=Release - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake - -P openssl.cmake - ) - execute_process( - COMMAND ${CMAKE_COMMAND} - -DCMAKE_GENERATOR=${CMAKE_GENERATOR} - -DCMAKE_CONFIGURATION_TYPE=Debug - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake - -P openssl.cmake - ) - return() + # multi-configuration + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Release + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P openssl.cmake + ) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P openssl.cmake + ) + return() elseif("$ENV{MSYSTEM}" MATCHES "MINGW32") - # mingw on msys2 - # single-configuration - if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE Release) - endif() + # mingw on msys2 + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") - # mingw - # single-configuration - if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") - set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake") - endif() - if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE Release) - endif() + # mingw + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") - # VS nmake - # single-configuration - if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") - set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake") - endif() - if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE Release) - endif() + # VS nmake + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() else() - # single-configuration - if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE Release) - endif() + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() endif() endif() @@ -86,17 +86,17 @@ if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") find_program( - PERL perl - ) + PERL perl + ) else() - # CYGWIN + # CYGWIN / Active Perl find_program( - PERL perl.exe - HINTS c:/Perl64/bin - HINTS c:/Perl/bin - HINTS c:/cygwin/usr/bin - HINTS c:/cygwin64/usr/bin - ) + PERL perl.exe + HINTS c:/Perl64/bin + HINTS c:/Perl/bin + HINTS c:/cygwin/usr/bin + HINTS c:/cygwin64/usr/bin + ) endif() if(${PERL} STREQUAL "PERL-NOTFOUND") @@ -121,183 +121,184 @@ ######################################## if((${CMAKE_GENERATOR} MATCHES "Visual Studio") OR - (${CMAKE_GENERATOR} MATCHES "NMake Makefiles")) + (${CMAKE_GENERATOR} MATCHES "NMake Makefiles")) ######################################## VS if(${CMAKE_GENERATOR} MATCHES "NMake Makefiles") elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") - find_program( - VCVARS32 vcvarsall.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build" - HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Auxiliary/Build" - HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build" - ) + find_program( + VCVARS32 vcvarsall.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build" + HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Auxiliary/Build" + HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 14 2015") - find_program( - VCVARS32 vcvars32.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin" - ) + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 12 2013") - find_program( - VCVARS32 vcvars32.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin" - ) + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 11 2012") - find_program( - VCVARS32 vcvars32.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin" - ) + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 10 2010") - find_program( - VCVARS32 vcvars32.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin" - ) + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 9 2008") - find_program( - VCVARS32 vcvars32.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin" - ) + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 8 2005") - find_program( - VCVARS32 vcvars32.bat - HINTS "C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin" - ) + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin" + ) else() - message(FATAL_ERROR "CMAKE_GENERATOR ${CMAKE_GENERATOR} not supported") - endif() + message(FATAL_ERROR "CMAKE_GENERATOR ${CMAKE_GENERATOR} not supported") + endif() if(VCVARS32-NOTFOUND) - message(FATAL_ERROR "vcvars32.bat not found") + message(FATAL_ERROR "vcvars32.bat not found") endif() if(${CMAKE_GENERATOR} MATCHES "Win64") - set(CONFIG_TARGET "VC-WIN64A") - set(DO_MS "ms\\do_win64a.bat") + set(CONFIG_TARGET "VC-WIN64A") + set(DO_MS "ms\\do_win64a.bat") else() - set(CONFIG_TARGET "VC-WIN32") - set(DO_MS "ms\\do_ms.bat") + set(CONFIG_TARGET "VC-WIN32") + set(DO_MS "ms\\do_ms.bat") endif() if(("${CMAKE_BUILD_TYPE}" STREQUAL "Release") OR ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "Release")) else() - set(CONFIG_TARGET "debug-${CONFIG_TARGET}") + set(CONFIG_TARGET "debug-${CONFIG_TARGET}") endif() file(WRITE "${SRC_DIR}/build_cmake.bat" - "cd %~dp0\n" - "setlocal\n" - ) + "cd %~dp0\n" + "setlocal\n" + ) file(TO_NATIVE_PATH ${PERL} PERL_N) file(TO_NATIVE_PATH ${INSTALL_DIR} INSTALL_DIR_N) file(TO_NATIVE_PATH ${VCVARS32} VCVARS32_N) string(REGEX REPLACE [[^(.*)\\.*$]] [[\1]] PERL_N_PATH ${PERL_N}) file(APPEND "${SRC_DIR}/build_cmake.bat" - "del crypto\\buildinf.h\n" - "setlocal\n" - "set PATH=${PERL_N_PATH}\n" - "perl Configure no-asm ${CONFIG_TARGET} --prefix=${INSTALL_DIR_N}\n" - "call ${DO_MS}\n" - "endlocal\n" - ) + "del crypto\\buildinf.h\n" + "setlocal\n" + "set PATH=${PERL_N_PATH}\n" + "perl Configure no-asm ${CONFIG_TARGET} --prefix=${INSTALL_DIR_N}\n" + "call ${DO_MS}\n" + "endlocal\n" + ) if(${CMAKE_GENERATOR} MATCHES "Visual Studio 8 2005") - ## Visual Studio 2005 特別処理 - # include,libパスの設定 - file(APPEND "${SRC_DIR}/build_cmake.bat" - "set SDK=C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\n" - "set INCLUDE=%SDK%\\Include;%INCLUDE%\n" - "set LIB=%SDK%\\lib;%LIB%\n" - ) + ## Visual Studio 2005 特別処理 + # include,libパスの設定 + file(APPEND "${SRC_DIR}/build_cmake.bat" + "set SDK=C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\n" + "set INCLUDE=%SDK%\\Include;%INCLUDE%\n" + "set LIB=%SDK%\\lib;%LIB%\n" + ) endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017 Win64") - file(APPEND "${SRC_DIR}/build_cmake.bat" - "call \"${VCVARS32_N}\" x86_amd64 10.0.17134.0\n" - ) + file(APPEND "${SRC_DIR}/build_cmake.bat" + "call \"${VCVARS32_N}\" x86_amd64 10.0.17134.0\n" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") - file(APPEND "${SRC_DIR}/build_cmake.bat" - "call \"${VCVARS32_N}\" x86 10.0.17134.0\n" - ) + file(APPEND "${SRC_DIR}/build_cmake.bat" + "call \"${VCVARS32_N}\" x86 10.0.17134.0\n" + ) elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio") - file(APPEND "${SRC_DIR}/build_cmake.bat" - "call \"${VCVARS32_N}\"\n" - ) + file(APPEND "${SRC_DIR}/build_cmake.bat" + "call \"${VCVARS32_N}\"\n" + ) endif() file(APPEND "${SRC_DIR}/build_cmake.bat" - "nmake -f ms\\nt.mak install ${NMAKE_OPTION}\n" - ) + "set PATH=${PERL_N_PATH};%PATH%\n" + "nmake -f ms\\nt.mak install ${NMAKE_OPTION}\n" + ) set(BUILD_CMAKE_BAT "${SRC_DIR}/build_cmake.bat") file(TO_NATIVE_PATH ${BUILD_CMAKE_BAT} BUILD_CMAKE_BAT_N) execute_process( - COMMAND cmd /c ${BUILD_CMAKE_BAT_N} - WORKING_DIRECTORY ${SRC_DIR} - RESULT_VARIABLE rv - ) + COMMAND cmd /c ${BUILD_CMAKE_BAT_N} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) if(NOT rv STREQUAL "0") - message(FATAL_ERROR "cmake build fail ${rv}") + message(FATAL_ERROR "cmake build fail ${rv}") endif() else() ######################################## MinGW execute_process( - COMMAND "uname" -s - OUTPUT_VARIABLE ov) + COMMAND "uname" -s + OUTPUT_VARIABLE ov) string(REGEX MATCH "[A-Za-z0-9]+" UNAME_S ${ov}) if("${UNAME_S}" STREQUAL "CYGWIN") - find_program( - MAKE make.exe - HINTS c:/cygwin/usr/bin - HINTS c:/cygwin64/usr/bin - ) + find_program( + MAKE make.exe + HINTS c:/cygwin/usr/bin + HINTS c:/cygwin64/usr/bin + ) elseif(("${UNAME_S}" STREQUAL "MINGW32") OR ("${UNAME_S}" STREQUAL "MINGW64")) - find_program( - MAKE make - ) + find_program( + MAKE make + ) elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") - find_program( - MAKE make - ) + find_program( + MAKE make + ) else() - message(FATAL_ERROR "unsported") + message(FATAL_ERROR "unsported") endif() set(ENV{PATH} "/usr/bin;/bin") if("${UNAME_S}" STREQUAL "MINGW32") - set(CMAKE_C_COMPILER "cc") - set(PATH "/mingw32/bin:/usr/local/bin:/usr/bin:/bin") + set(CMAKE_C_COMPILER "cc") + set(PATH "/mingw32/bin:/usr/local/bin:/usr/bin:/bin") elseif("${UNAME_S}" STREQUAL "MINGW64") - set(CMAKE_C_COMPILER "cc") - set(PATH "/mingw64/bin:/usr/local/bin:/usr/bin:/bin") + set(CMAKE_C_COMPILER "cc") + set(PATH "/mingw64/bin:/usr/local/bin:/usr/bin:/bin") else() - include(${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake) - set(ENV{PREFIX} i686-w64-mingw32) - set(ENV{CC} ${CMAKE_C_COMPILER}) - set(ENV{AR} "i686-w64-mingw32-ar") - set(ENV{RANLIB} "i686-w64-mingw32-ranlib") - set(PATH "/usr/bin:/bin") + include(${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake) + set(ENV{PREFIX} i686-w64-mingw32) + set(ENV{CC} ${CMAKE_C_COMPILER}) + set(ENV{AR} "i686-w64-mingw32-ar") + set(ENV{RANLIB} "i686-w64-mingw32-ranlib") + set(PATH "/usr/bin:/bin") endif() if("${UNAME_S}" STREQUAL "MINGW64") - set(CONFIG_NAME "mingw64") + set(CONFIG_NAME "mingw64") else() - set(CONFIG_NAME "mingw") + set(CONFIG_NAME "mingw") endif() execute_process( - COMMAND ${CMAKE_COMMAND} -E env "PATH=/usr/bin:/bin" ${PERL} ./Configure ${CONFIG_NAME} --prefix=${INSTALL_DIR} - WORKING_DIRECTORY ${SRC_DIR} - RESULT_VARIABLE rv - ) + COMMAND ${CMAKE_COMMAND} -E env "PATH=/usr/bin:/bin" ${PERL} ./Configure ${CONFIG_NAME} --prefix=${INSTALL_DIR} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) if(NOT rv STREQUAL "0") - message(FATAL_ERROR "cmake configure fail ${rv}") + message(FATAL_ERROR "cmake configure fail ${rv}") endif() execute_process( - COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} CC=${CMAKE_C_COMPILER} - WORKING_DIRECTORY ${SRC_DIR} - RESULT_VARIABLE rv - ) + COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} CC=${CMAKE_C_COMPILER} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) if(NOT rv STREQUAL "0") - message(FATAL_ERROR "cmake build fail ${rv}") + message(FATAL_ERROR "cmake build fail ${rv}") endif() execute_process( - COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} install - WORKING_DIRECTORY ${SRC_DIR} - RESULT_VARIABLE rv - ) + COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} install + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) if(NOT rv STREQUAL "0") - message(FATAL_ERROR "cmake install fail ${rv}") + message(FATAL_ERROR "cmake install fail ${rv}") endif() endif() Modified: branches/cmake/teraterm/common/compat_win.cpp =================================================================== --- branches/cmake/teraterm/common/compat_win.cpp 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/common/compat_win.cpp 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,5 +1,5 @@ /* - * (C) 2018 TeraTerm Project + * (C) 2019 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,10 +28,11 @@ /* compat_win */ +#include <windows.h> +#include <tchar.h> #include "compat_win.h" -HINSTANCE hDll_msimg32; -HMODULE hDll_user32; +#include "dllutil.h" BOOL (WINAPI *pAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPCRECT,MONITORENUMPROC,LPARAM); @@ -38,32 +39,36 @@ DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext); UINT (WINAPI *pGetDpiForWindow)(HWND hwnd); BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); +int (WINAPI *pAddFontResourceExA)(LPCSTR name, DWORD fl, PVOID res); +int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res); +BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR name, DWORD fl, PVOID pdv); +BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); -typedef struct { - const char *ApiName; - void **func; -} APIInfo; - -typedef struct { - const char *DllName; - HINSTANCE *hDll; - const APIInfo *APIInfoPtr; - size_t APIInfoCount; -} DllInfo; - static const APIInfo Lists_user32[] = { { "SetLayeredWindowAttributes", (void **)&pSetLayeredWindowAttributes }, { "SetThreadDpiAwarenessContext", (void **)&pSetThreadDpiAwarenessContext }, - { "GetDpiForWindow", (void **)&pGetDpiForWindow } + { "GetDpiForWindow", (void **)&pGetDpiForWindow }, + { NULL }, }; - + static const APIInfo Lists_msimg32[] = { { "AlphaBlend", (void **)&pAlphaBlend }, + { NULL }, }; - + +static const APIInfo Lists_gdi32[] = { + { "AddFontResourceExA", (void **)&pAddFontResourceExA }, + { "RemoveFontResourceExA", (void **)&pRemoveFontResourceExA }, + { "AddFontResourceExW", (void **)&pAddFontResourceExW }, + { "RemoveFontResourceExW", (void **)&pRemoveFontResourceExW }, + { NULL }, +}; + static const DllInfo DllInfos[] = { - { "user32.dll", &hDll_user32, Lists_user32, _countof(Lists_user32) }, - { "msimg32.dll", &hDll_msimg32, Lists_msimg32, _countof(Lists_msimg32) }, + { _T("user32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_user32 }, + { _T("msimg32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_msimg32 }, + { _T("gdi32.dll"), DLL_LOAD_LIBRARY_SYSTEM, DLL_ACCEPT_NOT_EXIST, Lists_gdi32 }, + { NULL }, }; void WinCompatInit() @@ -72,24 +77,5 @@ if (done) return; done = TRUE; - for (size_t i = 0; i < _countof(DllInfos); i++) { - const DllInfo *pDllInfo = &DllInfos[i]; - - char dllName[MAX_PATH]; - GetSystemDirectoryA(dllName, sizeof(dllName)); - strcat_s(dllName, sizeof(dllName), "/"); - strcat_s(dllName, sizeof(dllName), pDllInfo->DllName); - - HINSTANCE hDll = LoadLibraryA(dllName); - *pDllInfo->hDll = hDll; - - if (hDll != NULL) { - const APIInfo *pApiInfo = pDllInfo->APIInfoPtr; - for (size_t j = 0; j < pDllInfo->APIInfoCount; j++) { - void **func = pApiInfo->func; - *func = (void *)GetProcAddress(hDll, pApiInfo->ApiName); - pApiInfo++; - } - } - } + DLLGetApiAddressFromLists(DllInfos); } Modified: branches/cmake/teraterm/common/compat_win.h =================================================================== --- branches/cmake/teraterm/common/compat_win.h 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/common/compat_win.h 2019-03-10 14:34:42 UTC (rev 7475) @@ -47,22 +47,24 @@ #define WM_DPICHANGED 0x02E0 #endif -#if 0 -// BLENDFUNCTION\x82Ɠ\xAF\x88\xEA -typedef struct _BGBLENDFUNCTION -{ - BYTE BlendOp; - BYTE BlendFlags; - BYTE SourceConstantAlpha; - BYTE AlphaFormat; -}BGBLENDFUNCTION; -#endif extern BOOL (WINAPI *pAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); extern BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPCRECT,MONITORENUMPROC,LPARAM); extern DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext); extern UINT (WINAPI *pGetDpiForWindow)(HWND hwnd); extern BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); +extern int (WINAPI *pAddFontResourceExA)(LPCSTR name, DWORD fl, PVOID res); +extern int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res); +extern BOOL (WINAPI *pRemoveFontResourceExA)(LPCSTR name, DWORD fl, PVOID pdv); +extern BOOL (WINAPI *pRemoveFontResourceExW)(LPCWSTR name, DWORD fl, PVOID pdv); +#ifdef UNICODE +#define pAddFontResourceEx pAddFontResourceExW +#define pRemoveFontResourceEx pRemoveFontResourceExW +#else +#define pAddFontResourceEx pAddFontResourceExA +#define pRemoveFontResourceEx pRemoveFontResourceExA +#endif // !UNICODE + void WinCompatInit(); #ifdef __cplusplus Added: branches/cmake/teraterm/common/dllutil.cpp =================================================================== --- branches/cmake/teraterm/common/dllutil.cpp (rev 0) +++ branches/cmake/teraterm/common/dllutil.cpp 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1,284 @@ +/* + * (C) 2019 TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <windows.h> +#include <tchar.h> +#include <assert.h> +#include <crtdbg.h> + +#include "dllutil.h" + +#ifdef _DEBUG +#define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__) +#define free(p) _free_dbg((p), _NORMAL_BLOCK) +#define _strdup(s) _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__) +#endif + +typedef struct { + const TCHAR *dllName; + DLLLoadFlag LoadFlag; + HMODULE handle; + int refCount; +} HandleList_t; + +static HandleList_t *HandleList; +static int HandleListCount; + +static HMODULE GetHandle(const TCHAR *dllName, DLLLoadFlag LoadFlag) +{ + TCHAR dllPath[MAX_PATH]; + HMODULE module; + int i; + HandleList_t *p; + int r; + + if (LoadFlag == DLL_GET_MODULE_HANDLE) { + module = GetModuleHandle(dllName); + assert(module != NULL); + return module; + } + + // \x88ȑO\x82Ƀ\x8D\x81[\x83h\x82\xB5\x82\xBD? + p = HandleList; + for (i = 0; i < HandleListCount; i++) { + if (_tcscmp(p->dllName, dllName) == 0) { + p->refCount++; + return p->handle; + } + p++; + } + + // \x90V\x82\xBD\x82Ƀ\x8D\x81[\x83h\x82\xB7\x82\xE9 + dllPath[0] = 0; + switch (LoadFlag) { + case DLL_LOAD_LIBRARY_SYSTEM: + r = GetSystemDirectory(dllPath, _countof(dllPath)); + assert(r != 0); + if (r == 0) return NULL; + break; + case DLL_LOAD_LIBRARY_CURRENT: + r = GetModuleFileName(NULL, dllPath, _countof(dllPath)); + assert(r != 0); + if (r == 0) return NULL; + *_tcsrchr(dllPath, _T('\\')) = 0; + break; + default: + return NULL; + } + _tcscat_s(dllPath, _countof(dllPath), _T("\\")); + _tcscat_s(dllPath, _countof(dllPath), dllName); + module = LoadLibrary(dllPath); + if (module == NULL) { + // \x91\xB6\x8D݂\xB5\x82Ȃ\xA2,dll\x82\xB6\x82\xE1\x82Ȃ\xA2? + return NULL; + } + + // \x83\x8A\x83X\x83g\x82ɒlj\xC1 + HandleListCount++; + HandleList = (HandleList_t *)realloc(HandleList, sizeof(HandleList_t)*HandleListCount); + p = &HandleList[i]; + p->dllName = _tcsdup(dllName); + p->handle = module; + p->LoadFlag = LoadFlag; + p->refCount = 1; + return module; +} + +static void FreeHandle(const TCHAR *dllName, DLLLoadFlag LoadFlag) +{ + int i; + HandleList_t *p; + + if (LoadFlag == DLL_GET_MODULE_HANDLE) { + // \x82\xBB\x82̂܂ܒu\x82\xA2\x82Ă\xA8\x82\xAD + return; + } + + // \x83\x8A\x83X\x83g\x82\xA9\x82\xE7\x8D폜\x82\xB7\x82\xE9 + p = HandleList; + for (i = 0; i < HandleListCount; i++) { + if (_tcscmp(p->dllName, dllName) != 0) { + continue; + } + + // \x8C\xA9\x82\xA9\x82\xC1\x82\xBD + p->refCount--; + if (p->refCount > 0) { + continue; + } + + // free + FreeLibrary(p->handle); + free((void *)p->dllName); + memcpy(p, p+1, sizeof(*p) + (HandleListCount - i - 1)); + HandleListCount--; + HandleList = (HandleList_t *)realloc(HandleList, sizeof(HandleList_t)*HandleListCount); + return; + } + // \x83\x8A\x83X\x83g\x82Ɍ\xA9\x82\xA9\x82\xE7\x82Ȃ\xA9\x82\xC1\x82\xBD +} + +/** + * DLL\x93\xE0\x82̊\x94\x82ւ̃A\x83h\x83\x8C\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9 + * @param[in,out] pFunc \x8A\x94\x82ւ̃A\x83h\x83\x8C\x83X + * \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2\x8E\x9E\x82\xCDNULL\x82\xAA\x91\xE3\x93\xFC\x82\xB3\x82\xEA\x82\xE9 + * @param[in] FuncFlag \x8A\x94\x82\xAA\x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2\x82Ƃ\xAB\x82̓\xAE\x8D\xEC + * DLL_ACCEPT_NOT_EXIST \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xAD\x82Ă\xE0ok + * DLL_ERROR_NOT_EXIST \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2\x8Fꍇ\x83G\x83\x89\x81[ + * @retval NO_ERROR \x83G\x83\x89\x81[\x82Ȃ\xB5 + * @retval ERROR_FILE_NOT_FOUND DLL\x82\xAA\x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2(\x95s\x90\xB3\x82ȃt\x83@\x83C\x83\x8B) + * @retval ERROR_PROC_NOT_FOUND \x8A\x94\x83G\x83\x93\x83g\x83\x8A\x82\xAA\x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2 + */ +DWORD DLLGetApiAddress(const TCHAR *dllPath, DLLLoadFlag LoadFlag, + const char *ApiName, void **pFunc) +{ + HMODULE hDll = GetHandle(dllPath, LoadFlag); + if (hDll == NULL) { + *pFunc = NULL; + return ERROR_FILE_NOT_FOUND; + } else { + *pFunc = GetProcAddress(hDll, ApiName); + if (*pFunc == NULL) { + return ERROR_PROC_NOT_FOUND; + } + return NO_ERROR; // = 0 + } +} + +/** + * DLL\x93\xE0\x82̕\xA1\x90\x94\x82̊\x94\x82ւ̃A\x83h\x83\x8C\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9 + * @param[in] FuncFlag \x8A\x94\x82\xAA\x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2\x82Ƃ\xAB\x82̓\xAE\x8D\xEC + * DLL_ACCEPT_NOT_EXIST \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xAD\x82Ă\xE0ok + * DLL_ERROR_NOT_EXIST \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2\x8Fꍇ\x83G\x83\x89\x81[ + * @retval NO_ERROR \x83G\x83\x89\x81[\x82Ȃ\xB5 + * @retval ERROR_FILE_NOT_FOUND DLL\x82\xAA\x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2(\x95s\x90\xB3\x82ȃt\x83@\x83C\x83\x8B) + * @retval ERROR_PROC_NOT_FOUND \x8A\x94\x83G\x83\x93\x83g\x83\x8A\x82\xAA\x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2 + */ +DWORD DLLGetApiAddressFromList(const TCHAR *dllPath, DLLLoadFlag LoadFlag, + DLLFuncFlag FuncFlag, const APIInfo *ApiInfo) +{ + HMODULE hDll = GetHandle(dllPath, LoadFlag); + if (hDll == NULL) { + while(ApiInfo->ApiName != NULL) { + void **func = ApiInfo->func; + *func = NULL; + ApiInfo++; + } + return ERROR_FILE_NOT_FOUND; + } else { + BOOL exist_all = TRUE; + const APIInfo *p = ApiInfo; + + // \x83A\x83h\x83\x8C\x83X\x8E擾 + while(p->ApiName != NULL) { + void **func = p->func; + *func = (void *)GetProcAddress(hDll, p->ApiName); + if (*func == NULL) { + exist_all = FALSE; + } + p++; + } + + // \x82\xB7\x82ׂČ\xA9\x82\xA9\x82\xC1\x82\xBD or \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2API\x82\xAA\x82\xA0\x82\xC1\x82Ă\xE0ok + if (exist_all || FuncFlag == DLL_ACCEPT_NOT_EXIST) { + return NO_ERROR; + } + + // \x8C\xA9\x82\xA9\x82\xE7\x82Ȃ\xA2API\x82\xAA\x82\xA0\x82\xC1\x82\xBD\x82̂ŃG\x83\x89\x81[ + p = ApiInfo; + while(p->ApiName != NULL) { + void **func = p->func; + *func = NULL; + p++; + } + FreeHandle(dllPath, LoadFlag); + return ERROR_PROC_NOT_FOUND; + } +} + +void DLLGetApiAddressFromLists(const DllInfo *dllInfos) +{ + while (dllInfos->DllName != NULL) { + DLLGetApiAddressFromList(dllInfos->DllName, + dllInfos->LoadFlag, + dllInfos->FuncFlag, + dllInfos->APIInfoPtr); + dllInfos++; + } +} + +static void SetupLoadLibraryPath(void) +{ + BOOL (WINAPI *pSetDefaultDllDirectories)(DWORD); + BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR); + const TCHAR *kernel32 = _T("kernel32.dll"); + +#if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32) +#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 +#endif + + // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82́A + // \x8C\x9F\x8D\xF5\x83p\x83X\x82\xF0 %WINDOWS%\system32 \x82݂̂ɐݒ肷\x82\xE9 + DLLGetApiAddress(kernel32, DLL_GET_MODULE_HANDLE, + "SetDefaultDllDirectories", (void **)&pSetDefaultDllDirectories); + if (pSetDefaultDllDirectories != NULL) { + pSetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32); + return; + } + + // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ă\xE0 + // SetDllDirectory() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82\xCD + // \x83J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xBE\x82\xAF\x82ł\xE0\x8C\x9F\x8D\xF5\x83p\x83X\x82\xA9\x82\xE7\x82͂\xB8\x82\xB5\x82Ă\xA8\x82\xAD\x81B + DLLGetApiAddress(kernel32, DLL_GET_MODULE_HANDLE, + "SetDllDirectoryA", (void **)&pSetDllDirectoryA); + if (pSetDllDirectoryA != NULL) { + pSetDllDirectoryA(""); + } +} + +void DLLInit() +{ + HandleList = NULL; + HandleListCount = 0; + SetupLoadLibraryPath(); +} + +void DLLExit() +{ + int i; + for (i = 0; i < HandleListCount; i++) { + HandleList_t *p = &HandleList[i]; + if (p->LoadFlag != DLL_GET_MODULE_HANDLE) { + FreeLibrary(p->handle); + } + free((void *)p->dllName); + } + free(HandleList); + HandleList = NULL; + HandleListCount = 0; +} Copied: branches/cmake/teraterm/common/dllutil.h (from rev 7474, branches/cmake/teraterm/common/compat_win.h) =================================================================== --- branches/cmake/teraterm/common/dllutil.h (rev 0) +++ branches/cmake/teraterm/common/dllutil.h 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1,66 @@ +/* + * (C) 2019 TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + DLL_GET_MODULE_HANDLE, + DLL_LOAD_LIBRARY_SYSTEM, + DLL_LOAD_LIBRARY_CURRENT, +} DLLLoadFlag; + +typedef enum { + DLL_ACCEPT_NOT_EXIST, + DLL_ERROR_NOT_EXIST, +} DLLFuncFlag; + +typedef struct { + const char *ApiName; + void **func; +} APIInfo; + +typedef struct { + const TCHAR *DllName; + DLLLoadFlag LoadFlag; + DLLFuncFlag FuncFlag; + const APIInfo *APIInfoPtr; +} DllInfo; + +void DLLInit(); +void DLLExit(); +void DLLGetApiAddressFromLists(const DllInfo *dllInfos); +DWORD DLLGetApiAddressFromList(const TCHAR *dllPath, DLLLoadFlag LoadFlag, + DLLFuncFlag FuncFlag, const APIInfo *ApiInfo); +DWORD DLLGetApiAddress(const TCHAR *dllPath, DLLLoadFlag LoadFlag, + const char *ApiName, void **pFunc); + +#ifdef __cplusplus +} +#endif Modified: branches/cmake/teraterm/keycode/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/keycode/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/keycode/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,16 +1,5 @@ project(keycode) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - if(USE_UNICODE_API) add_definitions(-DUNICODE -D_UNICODE) endif() @@ -38,5 +27,4 @@ target_link_libraries( keycode - gdi32 ) Modified: branches/cmake/teraterm/teraterm/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/teraterm/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -35,6 +35,8 @@ ../common/win16api.h ../common/win16api.c ../common/dlglib_tmpl.cpp + ../common/codemap.h + ../common/compat_w95.h ../common/compat_win.cpp ../common/compat_win.h ../common/tmfc.cpp @@ -44,7 +46,8 @@ ../common/i18n.h ../common/win16api.h ../common/win16api.c - ../ttpcmn/language.h + ../common/dllutil.cpp + ../common/dllutil.h ../common/codeconv.h ../common/codeconv.cpp # @@ -118,6 +121,7 @@ ttplug.h ttsetup.c ttsetup.h + tt-version.rc ttwinman.c ttwinman.h ttwsk.c @@ -177,7 +181,6 @@ target_link_libraries( teraterm - ${UNICOWS_LIB} ttpcmn ttpfile ttpset Modified: branches/cmake/teraterm/teraterm/buffer.c =================================================================== --- branches/cmake/teraterm/teraterm/buffer.c 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/buffer.c 2019-03-10 14:34:42 UTC (rev 7475) @@ -2410,7 +2410,7 @@ TempAttr = CurAttr; TempSel = CurSel; } -#if 1 +#if 0 { OutputDebugPrintf("(%d,%d)[%d],%d\n", i, j - PageStart, count, CurAttr.Attr); bufA[lenA] = 0; Modified: branches/cmake/teraterm/teraterm/teraterm.cpp =================================================================== --- branches/cmake/teraterm/teraterm/teraterm.cpp 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/teraterm.cpp 2019-03-10 14:34:42 UTC (rev 7475) @@ -30,6 +30,7 @@ /* TERATERM.EXE, main */ #include <crtdbg.h> +#include <tchar.h> #include "teraterm.h" #include "tttypes.h" #include "commlib.h" @@ -45,36 +46,101 @@ #include "tekwin.h" #include "ttdde.h" #include "keyboard.h" +#include "dllutil.h" #include "compat_win.h" #include "compat_w95.h" #include "dlglib.h" #include "teraterml.h" -static void init() + + +typedef struct { + const TCHAR *FaceName; + bool found; +} EnumFontInfo; + +static int CALLBACK EnumFontExProc( + ENUMLOGFONT* lpelf, NEWTEXTMETRIC* lpntm, + int nFontType, LPARAM lParam) { - typedef BOOL (WINAPI *pSetDllDir)(LPCSTR); - typedef BOOL (WINAPI *pSetDefDllDir)(DWORD); + EnumFontInfo *info = (EnumFontInfo *)lParam; + if (nFontType == DEVICE_FONTTYPE) { + // \x90ڑ\xB1\x82\xB3\x82ꂽ\x83f\x83o\x83C\x83X(\x83v\x83\x8A\x83\x93\x83^\x82Ȃ\xC7)\x93\xE0\x82̃t\x83H\x83\x93\x83g + return 1; + } + const TCHAR *FaceName = lpelf->elfLogFont.lfFaceName; + if (_tcscmp(info->FaceName, FaceName) == 0) { + info->found = true; + return 0; + } + return 1; +} - HMODULE module; - pSetDllDir setDllDir; - pSetDefDllDir setDefDllDir; +BOOL isExistFont(const TCHAR *FaceName) +{ + HDC hDC = GetDC(NULL); + LOGFONT lf; + memset(&lf, 0, sizeof(lf)); + lf.lfCharSet = DEFAULT_CHARSET;// SHIFTJIS_CHARSET; + lf.lfPitchAndFamily = 0; - if ((module = GetModuleHandleA("kernel32.dll")) != NULL) { - if ((setDefDllDir = (pSetDefDllDir)GetProcAddress(module, "SetDefaultDllDirectories")) != NULL) { - // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82́A\x8C\x9F\x8D\xF5\x83p\x83X\x82\xF0 %WINDOWS%\system32 \x82݂̂ɐݒ肷\x82\xE9 - (*setDefDllDir)((DWORD)0x00000800); // LOAD_LIBRARY_SEARCH_SYSTEM32 + EnumFontInfo info; + info.FaceName = FaceName; + info.found = false; + EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)EnumFontExProc, (LPARAM)&info, 0); + ReleaseDC(NULL, hDC); + return info.found; +} + +static BOOL AddFontFlag; +static TCHAR TSpecialFont[MAX_PATH]; + +static void LoadSpecialFont() +{ + if (!isExistFont(_T("Tera Special"))) { + int r; + + if (GetModuleFileName(NULL, TSpecialFont,_countof(TSpecialFont)) == 0) { + AddFontFlag = FALSE; + return; } - else if ((setDllDir = (pSetDllDir)GetProcAddress(module, "SetDllDirectoryA")) != NULL) { - // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ă\xE0\x81ASetDllDirectory() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82\xCD - // \x83J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xBE\x82\xAF\x82ł\xE0\x8C\x9F\x8D\xF5\x83p\x83X\x82\xA9\x82\xE7\x82͂\xB8\x82\xB5\x82Ă\xA8\x82\xAD\x81B - (*setDllDir)(""); + *_tcsrchr(TSpecialFont, _T('\\')) = 0; + _tcscat_s(TSpecialFont, _T("\\TSPECIAL1.TTF")); + + if (pAddFontResourceEx != NULL) { + // teraterm.exe\x82݂̂ŗL\x8C\xF8\x82ȃt\x83H\x83\x93\x83g\x82ƂȂ\xE9\x81B + // remove\x82\xB5\x82Ȃ\xAD\x82Ă\xE0\x8FI\x97\xB9\x82\xB7\x82\xE9\x82\xC6OS\x82\xA9\x82\xE7\x82Ȃ\xAD\x82Ȃ\xE9 + r = pAddFontResourceEx(TSpecialFont, FR_PRIVATE, NULL); + } else { + // \x83V\x83X\x83e\x83\x80\x91S\x91̂Ŏg\x82\xA6\x82\xE9\x83t\x83H\x83\x93\x83g\x82ƂȂ\xE9 + // remove\x82\xB5\x82Ȃ\xA2\x82\xC6OS\x82\xAA\x92͂܂܂ƂȂ\xE9 + r = AddFontResource(TSpecialFont); } + if (r != 0) { + AddFontFlag = TRUE; + } } +} +static void UnloadSpecialFont() +{ + if (AddFontFlag) { + if (pRemoveFontResourceEx != NULL) { + pRemoveFontResourceEx(TSpecialFont, FR_PRIVATE, NULL); + } else { + RemoveFontResource(TSpecialFont); + } + } +} + +static void init() +{ + DLLInit(); WinCompatInit(); if (pSetThreadDpiAwarenessContext) { pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); } + LoadSpecialFont(); } // Tera Term main engine @@ -292,5 +358,8 @@ delete m_pMainWnd; m_pMainWnd = NULL; + UnloadSpecialFont(); + DLLExit(); + return msg.wParam; } Modified: branches/cmake/teraterm/teraterm/ttdialog.c =================================================================== --- branches/cmake/teraterm/teraterm/ttdialog.c 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/ttdialog.c 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2007-2018 TeraTerm Project + * (C) 2007-2019 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: branches/cmake/teraterm/teraterm/ttermpro.vcproj =================================================================== --- branches/cmake/teraterm/teraterm/ttermpro.vcproj 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/ttermpro.vcproj 2019-03-10 14:34:42 UTC (rev 7475) @@ -393,6 +393,18 @@ RelativePath="..\common\win16api.c" > </File> + <File + RelativePath="..\common\compat_win.cpp" + > + </File> + <File + RelativePath="..\common\dllutil.cpp" + > + </File> + <File + RelativePath="..\common\codeconv.cpp" + > + </File> </Filter> <Filter Name="Header Files" Modified: branches/cmake/teraterm/teraterm/vtdisp.c =================================================================== --- branches/cmake/teraterm/teraterm/vtdisp.c 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/vtdisp.c 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2005-2018 TeraTerm Project + * (C) 2005-2019 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -113,7 +113,8 @@ // caret variables static int CaretStatus; static BOOL CaretEnabled = TRUE; -BOOL IMEstat; /* IME Status TRUE=IME ON */ +BOOL IMEstat; /* IME Status TRUE=IME ON */ +BOOL IMEShowingCandidate; /* \x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x95\\x8E\xA6\x8F\xF3\x8B\xB5 TRUE=\x95\\x8E\xA6\x92\x86 */ // ---- device context and status flags static HDC VTDC = NULL; /* Device context for VT window */ @@ -1577,14 +1578,15 @@ // AlphaBlend \x82̃A\x83h\x83\x8C\x83X\x82\xF0\x93ǂݍ\x9E\x82\xDD if(BGUseAlphaBlendAPI) { - BGAlphaBlend = pAlphaBlend; + if(pAlphaBlend != NULL) + BGAlphaBlend = pAlphaBlend; + else + BGAlphaBlend = AlphaBlendWithoutAPI; } else { BGAlphaBlend = NULL; } - if(!BGAlphaBlend) - BGAlphaBlend = AlphaBlendWithoutAPI; } void BGExchangeColor() { @@ -2196,6 +2198,15 @@ CaretX = (CursorX-WinOrgX)*FontWidth; CaretY = (CursorY-WinOrgY)*FontHeight; + + if (IMEstat && IMEShowingCandidate) { + // IME ON && \x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x95\\x8E\xA6\x92\x86\x82̏ꍇ\x82݂̂̏\x88\x97\x9D + // \x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82\xAA\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x8F\xF3\x91Ԃ\xC5 + // \x83z\x83X\x83g\x82\xA9\x82\xE7\x82̃G\x83R\x81[\x82\xF0\x8E\xF3\x90M\x82\xB5\x82\xC4caret\x88ʒu\x82\xAA\x95ω\xBB\x82\xB5\x82\xBD\x8Fꍇ\x81A + // \x95ϊ\xB7\x83E\x83B\x83\x93\x83h\x83E\x82̈ʒu\x82\xF0\x8DX\x90V\x82\xB7\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9 + SetConversionWindow(HVTWin,CaretX,CaretY); + } + if (ts.CursorShape!=IdVCur) { if (ts.CursorShape==IdHCur) { CaretY = CaretY+FontHeight-CurWidth; Modified: branches/cmake/teraterm/teraterm/vtdisp.h =================================================================== --- branches/cmake/teraterm/teraterm/vtdisp.h 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/vtdisp.h 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,6 +1,6 @@ /* * Copyright (C) 1994-1998 T. Teranishi - * (C) 2008-2017 TeraTerm Project + * (C) 2008-2019 TeraTerm Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,6 +130,7 @@ extern TCharAttr DefCharAttr; extern BOOL IMEstat; +extern BOOL IMEShowingCandidate; #define SCROLL_BOTTOM 1 #define SCROLL_LINEDOWN 2 Modified: branches/cmake/teraterm/teraterm/vtterm.c =================================================================== --- branches/cmake/teraterm/teraterm/vtterm.c 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/vtterm.c 2019-03-10 14:34:42 UTC (rev 7475) @@ -52,8 +52,9 @@ #include "telnet.h" #include "ttime.h" #include "clipboar.h" -#include "../ttpcmn/language.h" #include "codeconv.h" +#include "codeconv.h" +#include "codeconv.h" #include "vtterm.h" @@ -5522,7 +5523,6 @@ { int ret; char mbchar[2]; - unsigned short cset; // Unicode\x82\xA9\x82\xE7DEC\x93\xC1\x8Eꕶ\x8E\x9A\x82ւ̃}\x83b\x83s\x83\x93\x83O if (ts.UnicodeDecSpMapping) { @@ -5534,19 +5534,18 @@ } // Unicode -> \x93\xE0\x95\x94\x83R\x81[\x83h(ts.CodePage)\x82֕ϊ\xB7\x82\xB5\x82ďo\x97\xCD - if (ts.CodePage == 932) { - ret = (int)UTF32ToCP932(code, mbchar, 2); - } else { - if (code >= 0x10000) { - goto unknown; - } - wchar_t wchar; - wchar = (wchar_t)code; - ret = WideCharToMultiByte(ts.CodePage, 0, &wchar, 1, mbchar, 2, NULL, NULL); + mblen = UTF32ToMBCP(code, ts.CodePage, mbchar, 2); +#if 1 // U+203e OVERLINE \x93\xC1\x95ʏ\x88\x97\x9D + if (code == 0x203e && ts.CodePage == 932) { + // U+203e\x82\xCD0x7e'~'\x82ɕϊ\xB7\x82\xB3\x82\xEA\x82\xE9 + // \x96\xB3\x97\x9D\x82\xE2\x82芿\x8E\x9A\x8Fo\x97͂\xB7\x82\xE9 + mbchar[0] = 0; // \x82\xB1\x82\xCC0\x82̂\xBD\x82߁A\x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82ɕ\xB6\x8E\x9A\x97\xA4\x82܂\xAD\x93\xFC\x82\xE7\x82Ȃ\xA2 + mbchar[1] = 0x7e; + mblen = 2; } - switch (ret) { +#endif + switch (mblen) { case 0: - unknown: PutChar('?'); if (ts.UnknownUnicodeCharaAsWide) { PutChar('?'); Modified: branches/cmake/teraterm/teraterm/vtwin.cpp =================================================================== --- branches/cmake/teraterm/teraterm/vtwin.cpp 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/vtwin.cpp 2019-03-10 14:34:42 UTC (rev 7475) @@ -180,6 +180,7 @@ ON_WM_VSCROLL() ON_WM_DEVICECHANGE() ON_MESSAGE(WM_IME_STARTCOMPOSITION,OnIMEStartComposition) + ON_MESSAGE(WM_IME_ENDCOMPOSITION,OnIMEEndComposition) ON_MESSAGE(WM_IME_COMPOSITION,OnIMEComposition) ON_MESSAGE(WM_INPUTLANGCHANGE,OnIMEInputChange) ON_MESSAGE(WM_IME_NOTIFY,OnIMENotify) @@ -3099,6 +3100,8 @@ LRESULT CVTWindow::OnIMEStartComposition(WPARAM wParam, LPARAM lParam) { + IMEShowingCandidate = TRUE; + // \x88ʒu\x82\xF0\x92ʒm\x82\xB7\x82\xE9 int CaretX = (CursorX-WinOrgX)*FontWidth; int CaretY = (CursorY-WinOrgY)*FontHeight; @@ -3107,6 +3110,12 @@ return CFrameWnd::DefWindowProc(WM_IME_STARTCOMPOSITION,wParam,lParam); } +LRESULT CVTWindow::OnIMEEndComposition(WPARAM wParam, LPARAM lParam) +{ + IMEShowingCandidate = FALSE; + return CFrameWnd::DefWindowProc(WM_IME_ENDCOMPOSITION,wParam,lParam); +} + LRESULT CVTWindow::OnIMEComposition(WPARAM wParam, LPARAM lParam) { if (CanUseIME()) { @@ -3145,7 +3154,10 @@ LRESULT CVTWindow::OnIMENotify(WPARAM wParam, LPARAM lParam) { - if (wParam == IMN_SETOPENSTATUS) { + switch (wParam) { + case IMN_SETOPENSTATUS: { + // \x93\xFC\x97̓R\x83\x93\x83e\x83L\x83X\x83g\x82̊J\x95\xF3\x91Ԃ\xAA\x8DX\x90V\x82\xB3\x82\xEA\x82\xE9(IME On/OFF) + // IME\x82\xCCOn/Off\x82\xF0\x8E擾\x82\xB7\x82\xE9 IMEstat = GetIMEOpenStatus(); @@ -3156,8 +3168,32 @@ // \x95`\x89\xE6 ChangeCaret(); + + break; } + // \x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x8Fʒm + // IME_OPENCANDIDATE / IMN_CLOSECANDIDATE \x83T\x83|\x81[\x83g\x8F\xF3\x8B\xB5 + // + // IME status + // --------------------------------+---------- + // MS IME \x93\xFA\x96{\x8C\xEA(Windows 10 1809) suport + // Google \x93\xFA\x96{\x8C\xEA\x93\xFC\x97\xCD(2.24.3250.0) not support + // + // WM_IME_STARTCOMPOSITION, WM_IME_ENDCOMPOSITION\x82݂̂Ŕ\xBB\x92\xE8\x89\\x82\xBE\x82\xAA + // \x94O\x82ׂ̈\xB1\x82̃\x81\x83b\x83Z\x81[\x83W\x82\xE0\x8F\x88\x97\x9D\x82\xB7\x82\xE9 + case IMN_OPENCANDIDATE: + // \x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x8AJ\x82\xB1\x82\xA4\x82Ƃ\xB5\x82Ă\xA2\x82\xE9 + IMEShowingCandidate = TRUE; + break; + case IMN_CLOSECANDIDATE: + // \x8C\xF3\x95\xE2\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x95\xB6\x82悤\x82Ƃ\xB5\x82Ă\xA2\x82\xE9 + IMEShowingCandidate = FALSE; + break; + default: + break; + } + return CFrameWnd::DefWindowProc(WM_IME_NOTIFY,wParam,lParam); } @@ -6202,6 +6238,9 @@ case WM_IME_STARTCOMPOSITION : OnIMEStartComposition(wp, lp); break; + case WM_IME_ENDCOMPOSITION : + OnIMEEndComposition(wp, lp); + break; case WM_IME_COMPOSITION: OnIMEComposition(wp, lp); break; Modified: branches/cmake/teraterm/teraterm/vtwin.h =================================================================== --- branches/cmake/teraterm/teraterm/vtwin.h 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/teraterm/vtwin.h 2019-03-10 14:34:42 UTC (rev 7475) @@ -136,7 +136,8 @@ afx_msg LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam); //--> afx_msg LRESULT OnIMEStartComposition(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnIMEComposition(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnIMEEndComposition(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnIMEComposition(UINT wParam, LONG lParam); afx_msg LRESULT OnIMEInputChange(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnIMENotify(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnIMERequest(WPARAM wParam, LPARAM lParam); Modified: branches/cmake/teraterm/ttpcmn/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/ttpcmn/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/ttpcmn/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,16 +1,5 @@ project(ttpcmn) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - if(USE_UNICODE_API) add_definitions(-DUNICODE -D_UNICODE) endif() @@ -57,7 +46,8 @@ ) if (MSVC) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:setupapi.dll /DELAYLOAD:user32.dll") + set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:setupapi.dll /DELAYLOAD:user32.dll") endif() add_library( @@ -72,10 +62,10 @@ ) if(MINGW) set_target_properties( - ttpcmn - PROPERTIES PREFIX "" - SUFFIX ".dll" - ) + ttpcmn + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) endif() target_link_libraries( Modified: branches/cmake/teraterm/ttpdlg/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/ttpdlg/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/ttpdlg/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -2,17 +2,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") if(MINGW) @@ -24,8 +13,6 @@ set(COMMON_SRC ../common/dlglib.c ../common/dlglib.h - ../common/dlglib_cpp.cpp - ../common/dlglib_tmpl.cpp ../common/ttlib.c ../common/ttlib.h ../common/teraterm.ico @@ -40,6 +27,7 @@ set(SRC dlg_res.h ttdlg.c + ttpdlg.def ttpdlg.rc ttpdlg-version.rc ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h @@ -63,10 +51,10 @@ if(MINGW) set_target_properties( - ttpdlg - PROPERTIES PREFIX "" - SUFFIX ".dll" - ) + ttpdlg + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) endif() target_link_libraries( @@ -81,14 +69,10 @@ ttpcmn ) -## svnversion.h -if(EXISTS ${CMAKE_SOURCE_DIR}/.svn) - INCLUDE(FindSubversion) +configure_file( + svnversion.h.in + svnversion.h @ONLY) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/svnversion.h") + file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/svnversion.h") endif() -if(Subversion_FOUND) - Subversion_WC_INFO(${CMAKE_SOURCE_DIR} TT) - FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h "#define SVNVERSION ${TT_WC_REVISION}\n") - message("rev.${TT_WC_REVISION}") -else() - FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h "#undef SVNVERSION\n") -endif() Added: branches/cmake/teraterm/ttpdlg/svnversion.h.in =================================================================== --- branches/cmake/teraterm/ttpdlg/svnversion.h.in (rev 0) +++ branches/cmake/teraterm/ttpdlg/svnversion.h.in 2019-03-10 14:34:42 UTC (rev 7475) @@ -0,0 +1 @@ +#cmakedefine SVNVERSION @SVNVERSION@ Modified: branches/cmake/teraterm/ttpfile/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/ttpfile/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/ttpfile/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,16 +1,5 @@ project(ttpfile) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") set(COMMON_SRC @@ -63,10 +52,10 @@ if(MINGW) set_target_properties( - ttpfile - PROPERTIES PREFIX "" - SUFFIX ".dll" - ) + ttpfile + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) endif() target_link_libraries( Modified: branches/cmake/teraterm/ttpmacro/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/ttpmacro/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/ttpmacro/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -3,17 +3,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - if(USE_UNICODE_API) add_definitions(-DUNICODE -D_UNICODE) endif() @@ -21,6 +10,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") set(COMMON_SRC + ../common/teraterm.h + ../common/ttcommon.h + ../common/ttddecmnd.h + ../common/tttypes.h + ../common/tt-version.h ../common/i18n.c ../common/i18n.h ../common/ttlib.c @@ -39,6 +33,7 @@ ../common/win16api.c ../common/codeconv.h ../common/codeconv.cpp + ../common/dllutil.cpp ) source_group( Modified: branches/cmake/teraterm/ttpset/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/ttpset/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/ttpset/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,16 +1,5 @@ project(ttpset) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") set(COMMON_SRC @@ -43,10 +32,10 @@ if(MINGW) set_target_properties( - ttpset - PROPERTIES PREFIX "" - SUFFIX ".dll" - ) + ttpset + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) endif() target_link_libraries( Modified: branches/cmake/teraterm/ttptek/CMakeLists.txt =================================================================== --- branches/cmake/teraterm/ttptek/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/teraterm/ttptek/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -3,17 +3,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake) -if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) -endif () - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") set(COMMON_SRC @@ -60,10 +49,10 @@ if(MINGW) set_target_properties( - ttptek - PROPERTIES PREFIX "" - SUFFIX ".dll" - ) + ttptek + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) endif() target_link_libraries( Modified: branches/cmake/ttssh2/matcher/CMakeLists.txt =================================================================== --- branches/cmake/ttssh2/matcher/CMakeLists.txt 2019-03-10 14:34:06 UTC (rev 7474) +++ branches/cmake/ttssh2/matcher/CMakeLists.txt 2019-03-10 14:34:42 UTC (rev 7475) @@ -1,13 +1,13 @@ -project(matcher) - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") - -set(SRC - matcher.c - test.c - ) - -add_executable( - matcher - ${SRC} - ) +project(matcher) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + matcher.c + test.c + ) + +add_executable( + matcher + ${SRC} + )