win32-api 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.4.7 - 4-Dec-2010
2
+ * An internal error formatting function now resorts to the default
3
+ LANGID on error 1815 (ERROR_RESOURCE_LANG_NOT_FOUND). Thanks go to
4
+ Little Snake for the spot.
5
+ * Added a default Rake task and refactored the clean task.
6
+
1
7
  == 1.4.6 - 9-Feb-2010
2
8
  * Fixed a warning that showed up with MinGW/gcc caused by an unnecessary
3
9
  pointer dereference.
data/Rakefile CHANGED
@@ -4,6 +4,17 @@ require 'rake/testtask'
4
4
  require 'rbconfig'
5
5
  include Config
6
6
 
7
+ CLEAN.include(
8
+ 'lib',
9
+ '**/*.gem', # Gem files
10
+ '**/*.rbc', # Rubinius
11
+ '**/*.o', # C object file
12
+ '**/*.log', # Ruby extension build log
13
+ '**/Makefile', # C Makefile
14
+ '**/conftest.dSYM', # OS X build directory
15
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
16
+ )
17
+
7
18
  make = CONFIG['host_os'] =~ /mingw|cygwin/i ? 'make' : 'nmake'
8
19
 
9
20
  desc 'Build the ruby.exe.manifest if it does not already exist'
@@ -26,23 +37,6 @@ task :install => [:build] do
26
37
  }
27
38
  end
28
39
 
29
- desc 'Clean any build files for Win32::API'
30
- task :clean do
31
- Dir.chdir('ext') do
32
- if File.exists?('api.so') || File.exists?('win32/api.so') ||
33
- File.exists?('api.obj') || File.exists?('Makefile')
34
- then
35
- sh "#{make} distclean"
36
- rm 'win32/api.so' if File.exists?('win32/api.so')
37
- rm 'api.so' if File.exists?('api.so')
38
- end
39
- end
40
-
41
- # Cleanup any files generated by the build_binary_gem task
42
- rm_rf('lib') if File.exists?('lib')
43
- Dir["*.gem"].each{ |f| File.delete(f) }
44
- end
45
-
46
40
  desc "Build Win32::API (but don't install it)"
47
41
  task :build => [:clean, :build_manifest] do
48
42
  Dir.chdir('ext') do
@@ -103,3 +97,5 @@ namespace 'test' do
103
97
  test.verbose = true
104
98
  end
105
99
  end
100
+
101
+ task :default => 'test:all'
@@ -17,7 +17,7 @@
17
17
  #endif
18
18
 
19
19
  #define MAX_BUF 1024
20
- #define WINDOWS_API_VERSION "1.4.5"
20
+ #define WINDOWS_API_VERSION "1.4.7"
21
21
 
22
22
  #define _T_VOID 0
23
23
  #define _T_LONG 1
@@ -56,61 +56,64 @@ static VALUE api_allocate(VALUE klass){
56
56
  * Internal use only.
57
57
  */
58
58
  char* StringError(DWORD dwError){
59
- LPVOID lpMsgBuf;
60
- static char buf[MAX_PATH];
61
- DWORD dwLen;
62
-
63
- // Assume ASCII error messages from the Windows API
64
- dwLen = FormatMessageA(
59
+ LPVOID lpMsgBuf;
60
+ static char buf[MAX_PATH];
61
+ DWORD dwLen, dwLastError;
62
+
63
+ // Assume ASCII (English) error messages from the Windows API
64
+ dwLen = FormatMessageA(
65
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
66
+ FORMAT_MESSAGE_FROM_SYSTEM |
67
+ FORMAT_MESSAGE_IGNORE_INSERTS,
68
+ NULL,
69
+ dwError,
70
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
71
+ (LPSTR)&lpMsgBuf,
72
+ 0,
73
+ NULL
74
+ );
75
+
76
+ dwLastError = GetLastError();
77
+
78
+ /* It appears that Windows doesn't necessarily ship with the DLL
79
+ * required to always use English error messages. Check for error
80
+ * ERROR_MUI_FILE_NOT_FOUND (15100) or ERROR_RESOURCE_LANG_NOT_FOUND (1815)
81
+ * and try again if necessary.
82
+ */
83
+ if(!dwLen && (dwLastError == 15100 || dwLastError == 1815)){
84
+ dwLen = FormatMessageA(
65
85
  FORMAT_MESSAGE_ALLOCATE_BUFFER |
66
86
  FORMAT_MESSAGE_FROM_SYSTEM |
67
87
  FORMAT_MESSAGE_IGNORE_INSERTS,
68
88
  NULL,
69
89
  dwError,
70
- MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
90
+ 0,
71
91
  (LPSTR)&lpMsgBuf,
72
92
  0,
73
93
  NULL
74
- );
75
-
76
- /* It appears that Windows doesn't necessarily ship with the DLL
77
- * required to always use English error messages. Check for error
78
- * ERROR_MUI_FILE_NOT_FOUND (15100), and try again if necessary.
79
- */
80
- if(!dwLen && GetLastError() == 15100){
81
- dwLen = FormatMessageA(
82
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
83
- FORMAT_MESSAGE_FROM_SYSTEM |
84
- FORMAT_MESSAGE_IGNORE_INSERTS,
85
- NULL,
86
- dwError,
87
- 0,
88
- (LPSTR)&lpMsgBuf,
89
- 0,
90
- NULL
91
- );
92
- }
94
+ );
95
+ }
93
96
 
94
- if(!dwLen){
95
- rb_raise(
96
- cAPIError,
97
- "Attempt to format message failed (error = '%d')",
98
- GetLastError()
99
- );
100
- }
97
+ if(!dwLen){
98
+ rb_raise(
99
+ cAPIError,
100
+ "Attempt to format message failed (error = '%d')",
101
+ GetLastError()
102
+ );
103
+ }
101
104
 
102
- memset(buf, 0, MAX_PATH);
105
+ memset(buf, 0, MAX_PATH);
103
106
 
104
- /* remove \r\n */
107
+ // Remove \r\n at end of string.
105
108
  #ifdef HAVE_STRNCPY_S
106
- strncpy_s(buf, MAX_PATH, lpMsgBuf, dwLen - 2);
109
+ strncpy_s(buf, MAX_PATH, lpMsgBuf, dwLen - 2);
107
110
  #else
108
- strncpy(buf, lpMsgBuf, dwLen - 2);
111
+ strncpy(buf, lpMsgBuf, dwLen - 2);
109
112
  #endif
110
113
 
111
- LocalFree(lpMsgBuf);
114
+ LocalFree(lpMsgBuf);
112
115
 
113
- return buf;
116
+ return buf;
114
117
  }
115
118
 
116
119
  /*
@@ -941,6 +944,6 @@ void Init_api(){
941
944
 
942
945
  /* Constants */
943
946
 
944
- /* 1.4.5: The version of the win32-api library */
947
+ /* 1.4.7: The version of the win32-api library */
945
948
  rb_define_const(cAPI, "VERSION", rb_str_new2(WINDOWS_API_VERSION));
946
949
  }
@@ -21,7 +21,7 @@ class TC_Win32_API < Test::Unit::TestCase
21
21
  end
22
22
 
23
23
  def test_version
24
- assert_equal('1.4.5', API::VERSION)
24
+ assert_equal('1.4.7', API::VERSION)
25
25
  end
26
26
 
27
27
  def test_constructor_basic
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'win32-api'
5
- spec.version = '1.4.6'
5
+ spec.version = '1.4.7'
6
6
  spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 4
9
+ - 7
10
+ version: 1.4.7
5
11
  platform: ruby
6
12
  authors:
7
13
  - Daniel J. Berger
@@ -10,19 +16,25 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2010-02-09 00:00:00 -07:00
19
+ date: 2010-12-04 00:00:00 -07:00
14
20
  default_executable:
15
21
  dependencies:
16
22
  - !ruby/object:Gem::Dependency
17
23
  name: test-unit
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
21
27
  requirements:
22
28
  - - ">="
23
29
  - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 2
33
+ - 0
34
+ - 6
24
35
  version: 2.0.6
25
- version:
36
+ type: :development
37
+ version_requirements: *id001
26
38
  description: " The Win32::API library is meant as a replacement for the Win32API\n library that ships as part of the standard library. It contains several\n advantages over Win32API, including callback support, raw function\n pointers, an additional string type, and more.\n"
27
39
  email: djberg96@gmail.com
28
40
  executables: []
@@ -55,21 +67,29 @@ rdoc_options: []
55
67
  require_paths:
56
68
  - lib
57
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
58
71
  requirements:
59
72
  - - ">="
60
73
  - !ruby/object:Gem::Version
74
+ hash: 51
75
+ segments:
76
+ - 1
77
+ - 8
78
+ - 2
61
79
  version: 1.8.2
62
- version:
63
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
64
82
  requirements:
65
83
  - - ">="
66
84
  - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
67
88
  version: "0"
68
- version:
69
89
  requirements: []
70
90
 
71
91
  rubyforge_project: win32utils
72
- rubygems_version: 1.3.5
92
+ rubygems_version: 1.3.7
73
93
  signing_key:
74
94
  specification_version: 3
75
95
  summary: A superior replacement for Win32API